literal_string
Synopsis
Declared in <folly/Utility.h>
template<
typename C,
std::size_t N>
struct literal_string;
Description
A structural type representing a literal string. A structural type may be a non‐type template argument.
May at times be useful since language‐level literal strings are not allowed as non‐type template arguments.
This may typically be used with vtag for passing the literal string as a constant‐expression via a non‐type template argument.
Example:
template <size_t N, literal_string<char, N> Str> void do_something_with_literal_string(vtag_t<Str>);
void do_something() { do_something_with_literal_string(vtag<literal_string{"foobar"}>); }
Member Functions
Name |
Description |
|
Constructs the structural string from a character array literal. |
Returns a null‐terminated pointer to the characters. |
|
Returns a pointer to the underlying characters. |
|
Returns the length of the string, excluding the null terminator. |
|
Converts the literal to a string‐like type. |