Adobe Source Libraries 2.0.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
name_t and static_name_t

Classes

class  static_name_t
 Utility wrapper to construct name_t with strings of static storage duration. More...
class  name_t
 A character string class for immutable strings. More...
struct  promote< static_name_t >
struct  hash< adobe::name_t >
struct  hash< adobe::static_name_t >

Functions

constexpr static_name_t operator""_name (const char *str, std::size_t n)

Detailed Description

Details
name_t is holding onto a closed_hash_map on the backside that maps from a name_t's hash to its string. When a name_t is constructed, its hash is used to find the unique string pointer common to all name_ts with that same string.
Although static_name_t and name_t are related, their hash values are quite different. static_name_t's hash is of its string, whereas name_t's hash is a reinterpret_cast of its unique string pointer in the underlying string map. Both hashes will point to the same unique string in the string map, making for very fast conversion from a static_name_t to a name_t.

Function Documentation

◆ operator""_name()

static_name_t operator""_name ( const char * str,
std::size_t n )
constexpr

User defined literal to convert a compile-time string into a static_name_t. It has been defined in the adobe::literals namespace to avoid namespace pollution.

Example
using namespace adobe::literals;

adobe::static_name_t foo("foo"_name); // OK, creation via user defined literal
adobe::name_t        bar(foo); // OK, implicit promotion to a name_t
adobe::name_t        baz("baz"_name); // OK, creation and then promotion
The adobe namespace itself uses the literals namespace, so you do not need to specify using namespace adobe::literals if you are already using namespace adobe:
using namespace adobe;

static_name_t foo("foo"_name); // OK
name_t        bar("bar"_name); // OK

Definition at line 204 of file name.hpp.