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¶
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¶
Value type stored in this token.
Public Functions Documentation¶
function StaticToken¶
Default constructor is deleted.
function StaticToken¶
Copy constructor is deleted.
function operator=¶
Copy assignment operator is deleted.
function 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:
- cf::expected containing pointer to the token's value or TokenError.
- cf::expected containing pointer to the token's value or TokenError.
Since:
- 0.1
- 0.1
Note:
- Thread-safe for concurrent reads.
- Delegates to TokenRegistry::get().
Warning:
- None
- None
Type-safe value accessor for registry (implementation).
function 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:
- cf::expected containing const pointer to the token's value or TokenError.
- cf::expected containing const pointer to the token's value or TokenError.
Since:
- 0.1
- 0.1
Note:
- Thread-safe for concurrent reads.
- Delegates to TokenRegistry::get_const().
Warning:
- None
- None
Const version of value accessor (implementation).
Public Attributes Documentation¶
variable hash_value¶
Compile-time hash of the token name.
Updated on 2026-03-09 at 10:14:00 +0000