|
cli20 0.1.2
A C++20 typed-schema command-line parser
|
Compile-time string type usable as a non-type template parameter. More...
#include <string_literal.hh>
Public Member Functions | |
| consteval | StringLiteral (const char(&str)[N]) noexcept |
| Constructs from a C string literal, copying all N characters. | |
| consteval auto | size () const noexcept -> std::size_t |
| Returns the string length excluding the null terminator. | |
| consteval auto | data () const noexcept -> const char * |
| Returns a raw pointer to the first character. | |
| consteval auto | view () const noexcept -> std::string_view |
| Returns a std::string_view over the stored characters. | |
| constexpr auto | operator[] (std::size_t i) const noexcept -> char |
| Returns the character at index i. | |
| consteval auto | operator== (const StringLiteral &) const noexcept -> bool=default |
| Equality comparison (compares the underlying arrays). | |
Public Attributes | |
| std::array< char, N > | value {} |
| Raw character storage (null-terminated, length N). | |
Compile-time string type usable as a non-type template parameter.
C++20 allows class-type NTTPs provided the type satisfies structural requirements. StringLiteral<N> wraps a null-terminated character array so that string names such as "verbose" can appear directly in template argument lists:
| N | Total storage size including the null terminator. |
Definition at line 24 of file string_literal.hh.
|
inlineconstevalnoexcept |
Constructs from a C string literal, copying all N characters.
| str | Null-terminated string literal of length N. |
Definition at line 34 of file string_literal.hh.
|
inlinenodiscardconstevalnoexcept |
Returns a raw pointer to the first character.
Definition at line 54 of file string_literal.hh.
|
constevaldefaultnoexcept |
Equality comparison (compares the underlying arrays).
|
inlinenodiscardconstexprnoexcept |
Returns the character at index i.
| i | Zero-based character index. |
Definition at line 77 of file string_literal.hh.
|
inlinenodiscardconstevalnoexcept |
Returns the string length excluding the null terminator.
Definition at line 44 of file string_literal.hh.
|
inlinenodiscardconstevalnoexcept |
Returns a std::string_view over the stored characters.
The returned view does not include the null terminator.
Definition at line 66 of file string_literal.hh.
| std::array<char, N> cli::StringLiteral< N >::value {} |
Raw character storage (null-terminated, length N).
Definition at line 26 of file string_literal.hh.