StringLiteral< Size > Struct Template Reference
|
CPP API
|
Wrapper for string literals, that allows passing them as template arguments. Should be used with constexpr. More...
#include <string_literal.h>
Public Types | |
| using | const_pointer = const value_type * |
| using | pointer = value_type * |
| using | size_type = size_t |
| using | string_view_type = std::basic_string_view< value_type > |
| using | value_type = char |
Public Member Functions | |
| constexpr pointer | data () |
| Access the underlying array. Modification is only possible during compile time. More... | |
| constexpr const_pointer | data () const |
| Access the underlying array. More... | |
| constexpr bool | empty () const |
| Check whether the StringLiteral is empty. More... | |
| constexpr | operator string_view_type () const |
| Implicit conversion from StringLiteral to string_view. More... | |
| constexpr string_view_type | string_view () const |
| Get a string_view of this literal. Be mindful of the lifetime of the view object. More... | |
| constexpr | StringLiteral ()=default |
| Create a string filled with '\0'. Mainly used by StringLiteral internally. More... | |
| constexpr | StringLiteral (const value_type(&string_literal)[size()+1]) |
| Construct a StringLiteral. More... | |
Static Public Member Functions | |
| static constexpr size_type | size () |
| The length of the StringLiteral (not counting the trailing '\0'). More... | |
Public Attributes | |
| value_type | value [size()+1] = {} |
| Contains the actual characters. Access this through data() or string_view(). More... | |
Friends | |
| template<size_type N> | |
| constexpr friend auto | operator+ (const StringLiteral &left, const StringLiteral< N > &right) |
| Join two literals. More... | |
| template<size_type N> | |
| constexpr friend auto | operator+ (const StringLiteral &left, const value_type(&right)[N]) |
| Join two literals. More... | |
| template<size_type N> | |
| constexpr friend auto | operator+ (const value_type(&left)[N], const StringLiteral &right) |
| Join two literals. More... | |
| template<size_type N> | |
| constexpr friend auto | operator== (const StringLiteral &left, const StringLiteral< N > &right) |
| Compare two literals. More... | |
| template<size_type N> | |
| constexpr friend auto | operator== (const StringLiteral &left, const value_type(&right)[N]) |
| Compare two literals. More... | |
Detailed Description
template<size_t Size>
struct mio::StringLiteral< Size >
Wrapper for string literals, that allows passing them as template arguments. Should be used with constexpr.
Member Typedef Documentation
◆ const_pointer
| using mio::StringLiteral< Size >::const_pointer = const value_type* |
◆ pointer
| using mio::StringLiteral< Size >::pointer = value_type* |
◆ size_type
| using mio::StringLiteral< Size >::size_type = size_t |
◆ string_view_type
| using mio::StringLiteral< Size >::string_view_type = std::basic_string_view<value_type> |
◆ value_type
| using mio::StringLiteral< Size >::value_type = char |
Constructor & Destructor Documentation
◆ StringLiteral() [1/2]
|
inlineconstexpr |
Construct a StringLiteral.
Use as StringLiteral{"example string literal"}. The type of string is a const reference to a fixed-size char array.
- Parameters
-
[in] string_literal Any string literal.
◆ StringLiteral() [2/2]
|
constexprdefault |
Create a string filled with '\0'. Mainly used by StringLiteral internally.
Member Function Documentation
◆ data() [1/2]
|
inlineconstexpr |
Access the underlying array. Modification is only possible during compile time.
◆ data() [2/2]
|
inlineconstexpr |
Access the underlying array.
◆ empty()
|
inlineconstexpr |
Check whether the StringLiteral is empty.
◆ operator string_view_type()
|
inlineconstexpr |
Implicit conversion from StringLiteral to string_view.
◆ size()
|
inlinestaticconstexpr |
The length of the StringLiteral (not counting the trailing '\0').
◆ string_view()
|
inlineconstexpr |
Get a string_view of this literal. Be mindful of the lifetime of the view object.
Friends And Related Function Documentation
◆ operator+ [1/3]
|
friend |
Join two literals.
- Parameters
-
[in] left,right The strings to join. Operands can be StringLiterals or regular string literals.
- Returns
- A new StringLiteral containing the joined string.
◆ operator+ [2/3]
|
friend |
Join two literals.
- Parameters
-
[in] left,right The strings to join. Operands can be StringLiterals or regular string literals.
- Returns
- A new StringLiteral containing the joined string.
◆ operator+ [3/3]
|
friend |
Join two literals.
- Parameters
-
[in] left,right The strings to join. Operands can be StringLiterals or regular string literals.
- Returns
- A new StringLiteral containing the joined string.
◆ operator== [1/2]
|
friend |
Compare two literals.
- Parameters
-
[in] left,right The strings to compare. Operands can be StringLiterals or regular string literals.
- Returns
- Whether both strings are the same.
◆ operator== [2/2]
|
friend |
Compare two literals.
- Parameters
-
[in] left,right The strings to compare. Operands can be StringLiterals or regular string literals.
- Returns
- Whether both strings are the same.
Member Data Documentation
◆ value
| value_type mio::StringLiteral< Size >::value[size()+1] = {} |
Contains the actual characters. Access this through data() or string_view().
Generated by