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

literal_string [constructor]

Constructs the structural string from a character array literal.

c_str

Returns a null‐terminated pointer to the characters.

data

Returns a pointer to the underlying characters.

size

Returns the length of the string, excluding the null terminator.

operator String

Converts the literal to a string‐like type.

Data Members

Name

Description

buffer

Storage holding the literal's characters.

Created with MrDocs