|
GMP 0.3.0
Generative Metaprogramming library for C++
|
A compile-time string type with fixed length and constexpr operations. More...
#include <fixed_string.hpp>
Public Types | |
| using | size_type = std::size_t |
Public Member Functions | |
| constexpr | fixed_string (const char(&str)[N+1]) |
| Construct a fixed string from a string literal. | |
| constexpr | fixed_string (std::string_view sv) |
| Construct a fixed string from a string view of matching length. | |
| consteval char | operator[] (size_type pos) const noexcept |
| Element access. | |
| consteval const char * | data () const noexcept |
| Get a pointer to the underlying null-terminated character data. | |
| constexpr auto | to_string_view () const noexcept |
Convert the fixed string to std::string_view. | |
| constexpr | operator char const * () const noexcept |
Implicitly convert to const char*. | |
| consteval size_type | size () const noexcept |
| Capacity. | |
| consteval size_type | length () const noexcept |
| Get the number of stored characters. | |
| consteval bool | empty () const noexcept |
| Check whether the fixed string is empty. | |
| consteval size_type | find (const char *str, size_type pos=0) const noexcept |
| Modifiers. | |
| template<auto Pos, auto Count = fixed_string::npos> | |
| consteval auto | substr (constant_arg_t< Pos >, constant_arg_t< Count >=constant_arg< fixed_string::npos >) const noexcept |
| Extract a compile-time substring. | |
Public Attributes | |
| char | data_ [N+1] |
Static Public Attributes | |
| static constexpr size_type | npos |
Friends | |
| consteval auto | operator<=> (fixed_string const &, fixed_string const &)=default |
fixed_string<N> stores N characters plus a trailing null terminator and is intended for non-type template parameter and compile-time string manipulation use cases.
| N | The number of characters excluding the null terminator. |
Definition at line 36 of file fixed_string.hpp.
| using gmp::fixed_string< N >::size_type = std::size_t |
Definition at line 37 of file fixed_string.hpp.
|
inlineconstexpr |
| str | The source character array including the terminating null byte. |
Definition at line 45 of file fixed_string.hpp.
References gmp::fixed_string< N >::data_, and gmp::enum_values().
|
inlineconstexpr |
| sv | The source string view. |
Definition at line 54 of file fixed_string.hpp.
References gmp::fixed_string< N >::data_, and gmp::enum_values().
|
inlinenoexcept |
Definition at line 76 of file fixed_string.hpp.
References gmp::fixed_string< N >::data_.
|
inlinenoexcept |
true if the string contains no characters, otherwise false. Definition at line 112 of file fixed_string.hpp.
|
inlinenoexcept |
Operations
Find the first occurrence of a C-string inside the fixed string.
| str | The substring to search for. |
| pos | The starting position of the search. |
npos if not found. Definition at line 124 of file fixed_string.hpp.
References gmp::enum_values(), and gmp::fixed_string< N >::to_string_view().
|
inlinenoexcept |
Definition at line 105 of file fixed_string.hpp.
|
inlineconstexprnoexcept |
Definition at line 90 of file fixed_string.hpp.
References gmp::fixed_string< N >::data_.
|
inlinenoexcept |
Access a character at the specified compile-time index.
| pos | The zero-based character position. |
pos. Definition at line 66 of file fixed_string.hpp.
References gmp::fixed_string< N >::data_, and gmp::enum_values().
|
inlinenoexcept |
Get the number of stored characters.
Definition at line 98 of file fixed_string.hpp.
Referenced by gmp::type_name().
|
inlinenoexcept |
| Pos | The starting position. |
| Count | The number of characters to extract, or npos for the suffix. |
| The | compile-time starting position wrapper. |
| The | compile-time count wrapper. |
fixed_string containing the selected substring. Definition at line 140 of file fixed_string.hpp.
References gmp::fixed_string< N >::data_, and gmp::enum_values().
|
inlineconstexprnoexcept |
Definition at line 83 of file fixed_string.hpp.
References gmp::fixed_string< N >::data_.
Referenced by gmp::fixed_string< N >::find().
|
friend |
| char gmp::fixed_string< N >::data_[N+1] |
Definition at line 154 of file fixed_string.hpp.
Referenced by gmp::fixed_string< N >::data(), gmp::fixed_string< N >::fixed_string(), gmp::fixed_string< N >::fixed_string(), gmp::fixed_string< N >::operator char const *(), gmp::fixed_string< N >::operator[](), gmp::fixed_string< N >::substr(), and gmp::fixed_string< N >::to_string_view().
|
staticconstexpr |
Definition at line 38 of file fixed_string.hpp.