55#if __cplusplus >= 201703L
62#if __cplusplus < 201103L
63#pragma error "C++ minimum version required is 11"
78#if __cplusplus >= 202002L
80#define make_poly_enc(char_t, lit) utf42::visit_poly_enc<char_t>( \
92#define make_poly_enc(char_t, lit) utf42::visit_poly_enc<char_t>( \
113#if __cplusplus >= 202002L
115#define cons_poly_enc(lit) utf42::poly_enc{ \
125#define cons_poly_enc(lit) utf42::poly_enc{ \
154 std::is_same<T, char>::value ||
155 std::is_same<T, wchar_t>::value ||
156#if __cplusplus >= 202002L
157 std::is_same<T, char8_t>::value ||
159 std::is_same<T, char16_t>::value ||
160 std::is_same<T, char32_t>::value
164#if __cplusplus >= 201703L
175#if __cplusplus >= 201703L
177 template<
typename char_t>
197 template<
typename char_t>
223 template<std::
size_t N>
225 : m_pData(
pStr), m_nSize(
N - 1) {
226 static_assert(
N > 0,
"basic_string_view: invalid length");
248 std::basic_string<char_t>
str()
const {
249 return std::basic_string<char_t>(m_pData, m_nSize);
259#if __cplusplus >= 202002L
268 concept CharacterType = is_character_v<T>;
277 concept IntegralType = std::is_integral_v<T>;
286 concept FloatingPointType = std::is_floating_point_v<T>;
302#if __cplusplus >= 202002L
328#if __cplusplus >= 202002L
347#if __cplusplus >= 202002L
348 template<CharacterType
char_t>
352 template<
typename char_t>
359#if __cplusplus >= 202002L
360 template<CharacterType
char_t>
365 template<
typename char_t>
367 static_assert(
false,
"Unsupported character type");
380 constexpr basic_string_view<wchar_t> poly_enc::visit<wchar_t>() const noexcept {
384#if __cplusplus >= 202002L
387 constexpr basic_string_view<char8_t> poly_enc::visit<char8_t>() const noexcept {
394 constexpr basic_string_view<char16_t> poly_enc::visit<char16_t>() const noexcept {
400 constexpr basic_string_view<char32_t> poly_enc::visit<char32_t>() const noexcept {
416#if __cplusplus >= 202002L
417 template<CharacterType
char_t>
418 consteval std::basic_string_view<char_t>
420 return oPolyEnv.visit<char_t>();
423 template<
typename char_t>
424 constexpr basic_string_view<char_t>
432#undef LIB_UTF_42_CHAR_TYPE
A class that provides a lightweight, non-owning view of a string.
Definition utf42.h:198
constexpr pointer data() const noexcept
Get a pointer to the underlying character data.
Definition utf42.h:241
constexpr basic_string_view()
Default constructor initializes to an empty string view.
Definition utf42.h:209
constexpr basic_string_view(nullptr_t)=delete
Deleted constructor from nullptr to avoid unintended usage.
constexpr basic_string_view(const char_t(&pStr)[N])
Constructor from a C-style string.
Definition utf42.h:224
const char_t * pointer
Pointer type to characters.
Definition utf42.h:200
constexpr size_type length() const noexcept
Get the length of the string.
Definition utf42.h:234
std::size_t size_type
Type for sizes of the string.
Definition utf42.h:203
std::basic_string< char_t > str() const
Convert to std::basic_string for further manipulation.
Definition utf42.h:248
Main namespace of the library.
constexpr basic_string_view< char_t > visit_poly_enc(const poly_enc &oPolyEnv)
Selects the appropriate encoded string view for a given character type.
Definition utf42.h:425
Type trait that checks whether a type is a supported character type.
Definition utf42.h:161
Container holding all character-encoded views of a string literal.
Definition utf42.h:298
constexpr basic_string_view< char_t > visit() const noexcept
Selects the appropriate encoded string view for a given character type.
Definition utf42.h:366
basic_string_view< char16_t > TXT_CHAR_16
UTF-16 character literal.
Definition utf42.h:305
constexpr poly_enc(const basic_string_view< char > txt_char, const basic_string_view< wchar_t > txt_char_w, const basic_string_view< char16_t > txt_char_16, const basic_string_view< char32_t > txt_char_32) noexcept
Constructs a polymorphic encoding container.
Definition utf42.h:317
basic_string_view< char > TXT_CHAR
Narrow character literal.
Definition utf42.h:300
basic_string_view< char32_t > TXT_CHAR_32
UTF-32 character literal.
Definition utf42.h:306
basic_string_view< wchar_t > TXT_CHAR_W
Wide character literal.
Definition utf42.h:301