![]() |
Gamedev Framework (gf)
0.10.0
A C++14 framework for 2D games
|
A gf::Id represents an identifier that has been computed from a string. Technically, it's a message digest from the Fowler–Noll–Vo 1a hash function.
There are two ways to get an id from a string. The first one is to call gf::hash with the string. You can use a C string or a std::string
or anything that can be converted to a gf::StringRef.
The second one is to use the user-defined literal _id
. First, you have to include a using namespace
directive in order to be able to use this user-defined literal.
Then, you can use the user-defined literal on literal strings.
The main advantage is that the id is computed at compile-time.
So, you can even use this property to compute a switch statement on a string.