跳转至

cf::ui::core::StaticToken

Compile-time type-safe token with zero runtime overhead. More...

#include <token.hpp>

Public Types

Name
using T value_type
Value type stored in this token.

Public Functions

Name
StaticToken() =delete
Default constructor is deleted.
StaticToken(constStaticToken & ) =delete
Copy constructor is deleted.
StaticToken & operator=(constStaticToken & ) =delete
Copy assignment operator is deleted.
cf::expected< T *, TokenError > get()
Type-safe value accessor for registry.
cf::expected< constT *, TokenError > get_const()
Const version of value accessor.

Public Attributes

Name
constexpruint64_t hash_value
Compile-time hash of the token name.

Detailed Description

template <typenameT ,
uint64_t Hash>
class cf::ui::core::StaticToken;

Compile-time type-safe token with zero runtime overhead.

Template Parameters:

  • T Value type stored in this token.
  • Hash Compile-time hash of the token name.

Note: Thread-safe for all operations via TokenRegistry's shared_mutex.

Warning: Do not use the same Hash value with different T types.

StaticToken provides compile-time type safety and hash-based lookup. The token type and hash are template parameters, enabling complete compiler optimization.

// Define a token at compile time
using CounterToken = StaticToken<int, "counter"_hash>;

// Register and use
TokenRegistry::get().register_token<CounterToken>(42);
auto result = CounterToken::get();
if (result) { int value = *result; }

Public Types Documentation

using value_type

using cf::ui::core::StaticToken< T, Hash >::value_type =  T;

Value type stored in this token.

Public Functions Documentation

function StaticToken

StaticToken() =delete

Default constructor is deleted.

function StaticToken

StaticToken(
    constStaticToken & 
) =delete

Copy constructor is deleted.

function operator=

StaticToken & operator=(
    constStaticToken & 
) =delete

Copy assignment operator is deleted.

function get

static cf::expected< T *, TokenError > get()

Type-safe value accessor for registry.

Exceptions:

  • None
  • None

Template Parameters:

  • T Value type stored in this token.
  • T Value type stored in this token.
  • Hash Compile-time hash of the token name.

Return:

Since:

  • 0.1
  • 0.1

Note:

Warning:

  • None
  • None

Type-safe value accessor for registry (implementation).

function get_const

static cf::expected< constT *, TokenError > get_const()

Const version of value accessor.

Exceptions:

  • None
  • None

Template Parameters:

  • T Value type stored in this token.
  • T Value type stored in this token.
  • Hash Compile-time hash of the token name.

Return:

Since:

  • 0.1
  • 0.1

Note:

Warning:

  • None
  • None

Const version of value accessor (implementation).

Public Attributes Documentation

variable hash_value

static constexpruint64_t hash_value = Hash;

Compile-time hash of the token name.


Updated on 2026-03-09 at 10:14:00 +0000