6#ifndef MIMICPP_STRING_HPP
7#define MIMICPP_STRING_HPP
102 template <
typename T>
104 :
public std::false_type
112 template <
typename T>
120 :
public std::true_type
129 :
public std::true_type
138 :
public std::true_type
147 :
public std::true_type
156 :
public std::true_type
165 :
public std::true_type
174 :
public std::true_type
196 template <satisfies<is_
character> Char>
252 template <
typename T>
259 template <
typename T>
266 template <
typename T>
267 requires std::is_pointer_v<T>
271 using char_t = std::remove_const_t<std::remove_pointer_t<T>>;
272 using view_t = std::basic_string_view<char_t>;
275 static constexpr view_t view(
const std::remove_pointer_t<T>* str)
noexcept
285 template <
typename T>
286 requires std::is_array_v<T>
295 template <
typename Char,
typename Traits,
typename Allocator>
299 using string_t = std::basic_string<Char, Traits, Allocator>;
300 using view_t = std::basic_string_view<Char, Traits>;
312 template <
typename Char,
typename Traits>
316 using view_t = std::basic_string_view<Char, Traits>;
334 template <
typename T>
338 requires std::regular<string_char_t<T>>;
339 requires std::ranges::contiguous_range<string_view_t<T>>;
340 requires std::ranges::sized_range<string_view_t<T>>;
341 requires std::ranges::borrowed_range<string_view_t<T>>;
342 requires std::same_as<
344 std::ranges::range_value_t<string_view_t<T>>>;
368 template <satisfies<is_
character> Char>
376 template <
typename String>
379 &&
requires(
const string_case_fold_converter<string_char_t<String>> converter,
string_view_t<String> view)
381 { std::invoke(converter, std::move(view)) } -> std::ranges::forward_range;
383 &&
requires(std::invoke_result_t<string_case_fold_converter<string_char_t<String>>,
string_view_t<String>> normalized)
385 requires std::same_as<
387 std::ranges::range_value_t<
decltype(normalized)>>;
391namespace mimicpp::detail
393 template <
typename View,
typename Char>
395 && std::ranges::borrowed_range<View>
396 && std::ranges::contiguous_range<View>
397 && std::ranges::sized_range<View>
398 && std::same_as<Char, std::ranges::range_value_t<View>>;
401#ifndef MIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER
410 template <detail::compatible_
string_view_with<
char> String>
412 constexpr auto operator ()(String&& str)
const
414 return std::views::all(std::forward<String>(str))
415 | std::views::transform(
416 [](
const char c)
noexcept
420 return static_cast<char>(
421 static_cast<unsigned char>(std::toupper(c)));
428#if __has_include(<uni_algo/case.h>) \
429 && __has_include(<uni_algo/conv.h>)
430#include <uni_algo/case.h>
431#include <uni_algo/conv.h>
433 #error "Unable to find uni_algo includes."
443 template <detail::compatible_
string_view_with<
char> String>
445 constexpr auto operator ()(String&& str)
const
447 return una::cases::to_casefold_utf8(
449 std::ranges::data(str),
450 std::ranges::size(str)
462 template <detail::compatible_
string_view_with<
wchar_t> String>
464 constexpr auto operator ()(String&& str)
const
466 return una::cases::to_casefold_utf16(
468 std::ranges::data(str),
469 std::ranges::size(str)
481 template <detail::compatible_
string_view_with<
char8_t> String>
483 constexpr auto operator ()(String&& str)
const
485 return una::cases::to_casefold_utf8(
487 std::ranges::data(str),
488 std::ranges::size(str)
500 template <detail::compatible_
string_view_with<
char16_t> String>
502 constexpr auto operator ()(String&& str)
const
504 return una::cases::to_casefold_utf16(
506 std::ranges::data(str),
507 std::ranges::size(str)
519 template <detail::compatible_
string_view_with<
char32_t> String>
521 constexpr auto operator ()(String&& str)
const
523 return una::utf8to32<char8_t, char32_t>(
524 una::cases::to_casefold_utf8(
527 std::ranges::data(str),
528 std::ranges::size(str)
Determines, whether the given type supports string normalization.
Definition String.hpp:377
Determines, whether the given type can be used as a string-type.
Definition String.hpp:335
constexpr bool is_character_v
Convenience boolean-constant to the result of is_character trait.
Definition String.hpp:113
constexpr StringViewT string_literal_prefix< char16_t >
char16_t specialization.
Definition String.hpp:226
constexpr StringViewT string_literal_prefix< wchar_t >
wchar_t specialization.
Definition String.hpp:212
constexpr StringViewT string_literal_prefix< char32_t >
char32_t specialization.
Definition String.hpp:233
constexpr StringViewT string_literal_prefix< char >
char specialization.
Definition String.hpp:205
constexpr StringViewT string_literal_prefix< char8_t >
char8_t specialization.
Definition String.hpp:219
constexpr StringViewT string_literal_prefix
Primary template, yielding an empty string.
Definition String.hpp:198
decltype(string_traits< std::remove_cvref_t< T > >::view(std::declval< T & >())) string_view_t
Computes the view type for the given string.
Definition String.hpp:253
typename string_traits< std::remove_cvref_t< T > >::char_t string_char_t
Computes the character type for the given string.
Definition String.hpp:260
Definition BoostTest.hpp:20
std::basic_string_view< CharT, CharTraitsT > StringViewT
Definition Fwd.hpp:208
Primary template, which always yields false.
Definition String.hpp:105
Primary template, purposely undefined.
Definition String.hpp:369
std::remove_const_t< std::remove_pointer_t< T > > char_t
Definition String.hpp:271
std::basic_string_view< char_t > view_t
Definition String.hpp:272
static constexpr view_t view(const std::remove_pointer_t< T > *str) noexcept
Definition String.hpp:275
std::basic_string_view< Char, Traits > view_t
Definition String.hpp:300
std::basic_string< Char, Traits, Allocator > string_t
Definition String.hpp:299
static constexpr view_t view(const string_t &str) noexcept
Definition String.hpp:303
Char char_t
Definition String.hpp:298
static constexpr view_t view(view_t str) noexcept
Definition String.hpp:319
std::basic_string_view< Char, Traits > view_t
Definition String.hpp:316
Char char_t
Definition String.hpp:315