Implements a constexpr string that can be used for compile time computations. More...
#include <seqan3/range/container/constexpr_string.hpp>
Public Member Functions | |
Constructors, destructor and assignment | |
constexpr | constexpr_string ()=default |
Default default constructor. | |
constexpr | constexpr_string (constexpr_string const &)=default |
Default copy constructor. | |
constexpr | constexpr_string (constexpr_string &&)=default |
Default move constructor. | |
constexpr constexpr_string & | operator= (constexpr_string const &)=default |
Default copy-assignment operator. | |
constexpr constexpr_string & | operator= (constexpr_string &&)=default |
Default move-assignment operator. | |
constexpr | constexpr_string (const char(&_lit)[N+1]) noexcept |
Construction from literal. More... | |
constexpr | constexpr_string (std::array< char, N > const &src) noexcept |
Construction from char array. More... | |
constexpr | constexpr_string (const char c) noexcept |
Construction from char. More... | |
~constexpr_string ()=default | |
Default destructor. | |
Element access | |
constexpr reference | operator[] (size_t pos) noexcept |
Access an element in the string. More... | |
constexpr const_reference | operator[] (size_t pos) const noexcept |
Access an element in the string. More... | |
std::string | string () const |
Returns the content represented as std::string. More... | |
constexpr const char * | c_str () const noexcept |
Returns the content represented as 0-terminated c-style string. More... | |
Capacity | |
constexpr size_type | size () const noexcept |
Returns the size. | |
constexpr size_type | max_size () const noexcept |
Returns the maximal capacity (same as size()). | |
constexpr bool | empty () const noexcept |
Determines whether the string is empty. | |
Iterators | |
constexpr iterator | begin () noexcept |
Returns the begin to the string. | |
constexpr const_iterator | begin () const noexcept |
Returns the begin to the string. More... | |
constexpr const_iterator | cbegin () const noexcept |
Returns the begin to the string. More... | |
constexpr iterator | end () noexcept |
Returns iterator pass the end of the string. | |
constexpr const_iterator | end () const noexcept |
Returns iterator pass the end of the string. More... | |
constexpr const_iterator | cend () const noexcept |
Returns iterator pass the end of the string. More... | |
Operations | |
template<size_t N2> | |
constexpr constexpr_string< N+N2 > | operator+ (constexpr_string< N2 > const &rhs) const noexcept |
Concatenates two constexpr_strings. More... | |
constexpr void | swap (constexpr_string &other) noexcept |
Swaps the contents. More... | |
Comparison | |
template<size_t N2> | |
constexpr bool | operator== (constexpr_string< N2 > const &rhs) const noexcept |
Compares two strings lexicographically. More... | |
template<size_t N2> | |
constexpr bool | operator!= (constexpr_string< N2 > const &rhs) const noexcept |
Compares two strings lexicographically. More... | |
template<size_t N2> | |
constexpr bool | operator< (constexpr_string< N2 > const &rhs) const noexcept |
Compares two strings lexicographically. More... | |
template<size_t N2> | |
constexpr bool | operator<= (constexpr_string< N2 > const &rhs) const noexcept |
Compares two strings lexicographically. More... | |
template<size_t N2> | |
constexpr bool | operator> (constexpr_string< N2 > const &rhs) const noexcept |
Compares two strings lexicographically. More... | |
template<size_t N2> | |
constexpr bool | operator>= (constexpr_string< N2 > const &rhs) const noexcept |
Compares two strings lexicographically. More... | |
Protected Types | |
using | data_type = std::array< char, N+1 > |
Alias for the underlying data type. | |
Protected Member Functions | |
template<size_t N1> | |
constexpr | constexpr_string (constexpr_string< N1 > const &lhs, constexpr_string< N - N1 > const &rhs) noexcept |
Constructs new constexpr_string by merging two other constexpr_strings. More... | |
Protected Attributes | |
data_type | lit |
The internal string stored as array including \0-byte as last character. | |
Friends | |
template<size_t N2> | |
class | constexpr_string |
Gives access to the merge constructor to constexpr_string with different size. | |
Related Functions | |
(Note that these are not member functions.) | |
Operations | |
template<size_t N> | |
constexpr void | swap (constexpr_string< N > &lhs, constexpr_string< N > &rhs) |
Exchanges the given values. More... | |
Deduction guides | |
template<size_t N> | |
constexpr_string (const char(&)[N]) -> constexpr_string< N - 1 > | |
Deduces constexpr_string from string literals. More... | |
template<size_t N> | |
constexpr_string (std::array< char, N > const &) -> constexpr_string< N > | |
Deduces constexpr_string from std::array of type char. More... | |
constexpr_string (const char) -> constexpr_string< 1 > | |
Deduces constexpr_string from char. More... | |
Implements a constexpr string that can be used for compile time computations.
N | The size of the constexpr string. |
This class provides a string type that can be constructed, evaluated and operated on at compile time. The stored string can be accessed as either a std::string or a c-style string through the respective member functions. All operations are constexpr except the conversion functions.
Internally the string stores an array of size N+1
containing the 0
-byte to allow conversion to c-style strings. This also means that when creating an instance of this string from a string literal containing a 0
-byte the size of this instance is one less.
|
inlineprotectednoexcept |
Constructs new constexpr_string by merging two other constexpr_strings.
lhs | left-hand-side of constexpr_string to merge. |
rhs | right-hand-side of constexpr_string to merge. |
No-throw guarantee.
|
inlinenoexcept |
Construction from literal.
_lit | The literal to construct the string for. |
No-throw guarantee.
|
inlinenoexcept |
Construction from char array.
src | The char array to construct the constexpr_string for. |
No-throw guarantee.
|
inlinenoexcept |
Construction from char.
c | The character to construct the constexpr_string for. |
No-throw guarantee.
|
inlinenoexcept |
Returns the begin to the string.
|
inlinenoexcept |
Returns the content represented as 0-terminated c-style string.
const char *
The stored string.No-throw guarantee.
Constant.
|
inlinenoexcept |
Returns the begin to the string.
|
inlinenoexcept |
Returns iterator pass the end of the string.
|
inlinenoexcept |
Returns iterator pass the end of the string.
|
inlinenoexcept |
Compares two strings lexicographically.
bool
true
if the corresponding comparison holds, false
otherwise.No-throw guarantee.
Linear in the size of the strings.
|
inlinenoexcept |
Concatenates two constexpr_strings.
rhs | The right-hand-side to concat with. |
constexpr_string<N + N2>
The new constexpr_string with size N
+ N2
.No-throw guarantee.
Linear in the size of the strings.
|
inlinenoexcept |
Compares two strings lexicographically.
bool
true
if the corresponding comparison holds, false
otherwise.No-throw guarantee.
Linear in the size of the strings.
|
inlinenoexcept |
Compares two strings lexicographically.
bool
true
if the corresponding comparison holds, false
otherwise.No-throw guarantee.
Linear in the size of the strings.
|
inlinenoexcept |
Compares two strings lexicographically.
bool
true
if the corresponding comparison holds, false
otherwise.No-throw guarantee.
Linear in the size of the strings.
|
inlinenoexcept |
Compares two strings lexicographically.
bool
true
if the corresponding comparison holds, false
otherwise.No-throw guarantee.
Linear in the size of the strings.
|
inlinenoexcept |
Compares two strings lexicographically.
bool
true
if the corresponding comparison holds, false
otherwise.No-throw guarantee.
Linear in the size of the strings.
|
inlinenoexcept |
Access an element in the string.
No-throw guarantee.
Constant.
|
inlinenoexcept |
Access an element in the string.
No-throw guarantee.
Constant.
|
inline |
Returns the content represented as std::string.
std::string
The stored string.Strong exception guarantee. No data is modified.
Linear in the size of the string.
|
inlinenoexcept |
Swaps the contents.
Both strings must have the same size in order to swap them.
Constant.
|
related |
Deduces constexpr_string from string literals.
|
related |
Deduces constexpr_string from std::array of type char.
|
related |
Deduces constexpr_string from char.
|
related |
Exchanges the given values.
N | The size of the constexpr_string. |
lhs | The left operand. |
rhs | The right operand. |
No-throw guarantee.
Constant.