Qx v0.7
Qt Extensions Library
|
The StringLiteral template class acts as a literal class type wrapper around a raw string that effectively allows the string to be used as a non-type template parameter. More...
#include <qx/utility/qx-stringliteral.h>
Public Types | |
using | data_t = C |
using | view_t |
Public Member Functions | |
constexpr | StringLiteral (const C(&str)[N]) |
constexpr C * | data () const |
constexpr | operator QLatin1StringView () const |
constexpr | operator QStringView () const |
constexpr | operator std::basic_string_view< C > () const |
constexpr std::strong_ordering | operator<=> (const StringLiteral &other) const =default |
constexpr bool | operator== (const StringLiteral &other) const =default |
constexpr size_t | size () const |
constexpr std::basic_string_view< C > | std_view () const |
constexpr view_t | view () const |
Static Public Attributes | |
static constexpr size_t | size_v = N - 1 |
Related Symbols | |
(Note that these are not member symbols.) | |
template<string_literal S, size_t N2> | |
constexpr auto | operator+ (const S &a, const typename S::data_t(&b)[N2]) |
template<string_literal S> | |
constexpr auto | operator+ (const S &a, typename S::data_t b) |
template<typename StringLiteralA, typename StringLiteralB> | |
constexpr auto | operator+ (const StringLiteralA &a, const StringLiteralA &b) |
template<size_t N1, string_literal S> | |
constexpr auto | operator+ (const typename S::data_t(&a)[N1], const S &b) |
template<string_literal S> | |
constexpr auto | operator+ (typename S::data_t a, const S &b) |
The template parameters of this class allow the underlying character type to be auto-detected by the nature of the literal string used to construct it, so a template that takes Qx::StringLiteral can accept multiple string types, as shown in the following example.
If you want to use compile-time literals of a fixed size, use the type-specific derivatives of this class (i.e CStringLiteral, WStringLiteral, U8StringLiteral, etc.)
using Qx::StringLiteral< C, N >::data_t = C |
The storage type for the string.
using Qx::StringLiteral< C, N >::view_t |
The type of view used by the view() method, if any.
|
inlineconstexpr |
Wraps the raw string str of length N.
|
inlineconstexpr |
Returns a pointer to the raw string.
|
inlineconstexpr |
Allows the StringLiteral to be converted to a QLatin1StringView.
Requires C to be char
.
|
inlineconstexpr |
Allows the StringLiteral to be converted to a QLatin1StringView.
Requires C to be char16_t
.
|
inlineconstexpr |
Allows the StringLiteral to be converted to a std::basic_string_view of the appropriate type.
|
constexprdefault |
Returns the ordering of other relative to this
.
|
constexprdefault |
Returns true
if the StringLiteral is equal to other; otherwise, returns false
.
|
inlineconstexpr |
Returns the size of the string.
|
inlineconstexpr |
Returns a std style view of the string.
|
inlineconstexpr |
Returns a Qt type view of the string.
Requires C to be char
or char16_t
|
Returns a string which is the result of concatenating a and b.
|
Returns a string which is the result of concatenating a and b.
|
Returns a string which is the result of concatenating a and b.
|
Returns a string which is the result of concatenating a and b.
|
Returns a string which is the result of concatenating a and b.
|
staticconstexpr |
The size of the string.
This variable is easy to use at compile-time given it's a static member.