doc: more on hashed strings (close #559)

This commit is contained in:
Michele Caini
2020-09-24 00:09:45 +02:00
parent c0a7f84382
commit 6e040fa87c

View File

@@ -115,7 +115,8 @@ human-readable identifiers in the codebase while using their numeric
counterparts at runtime, thus without affecting performance.<br/>
The class has an implicit `constexpr` constructor that chews a bunch of
characters. Once created, all what one can do with it is getting back the
original string or converting it into a number.<br/>
original string through the `data` member function or converting the instance
into a number.<br/>
The good part is that a hashed string can be used wherever a constant expression
is required and no _string-to-number_ conversion will take place at runtime if
used carefully.
@@ -137,6 +138,19 @@ more user-friendly:
constexpr auto str = "text"_hs;
```
Finally, in case users need to create hashed strings at runtime, this class also
offers the necessary functionalities:
```
std::string orig{"text"};
// create a full-featured hashed string...
entt::hashed_string str{orig.c_str()};
// ... or compute only the unique identifier
const auto hash = entt::hashed_string::value(orig.c_str());
```
## Wide characters
The hashed string has a design that is close to that of an `std::basic_string`.