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>
337 requires std::regular<string_char_t<T>>;
338 requires std::ranges::contiguous_range<string_view_t<T>>;
339 requires std::ranges::sized_range<string_view_t<T>>;
340 requires std::ranges::borrowed_range<string_view_t<T>>;
341 requires std::same_as<
343 std::ranges::range_value_t<string_view_t<T>>>;
367 template <satisfies<is_
character> Char>
375 template <
typename String>
378 &&
requires(
const string_case_fold_converter<string_char_t<String>> converter,
string_view_t<String> view) {
379 { std::invoke(converter, std::move(view)) } -> std::ranges::forward_range;
380 } &&
requires(std::invoke_result_t<string_case_fold_converter<string_char_t<String>>,
string_view_t<String>> normalized) {
381 requires std::same_as<
383 std::ranges::range_value_t<
decltype(normalized)>>;
387namespace mimicpp::detail
389 template <
typename View,
typename Char>
391 && std::ranges::borrowed_range<View>
392 && std::ranges::contiguous_range<View>
393 && std::ranges::sized_range<View>
394 && std::same_as<Char, std::ranges::range_value_t<View>>;
397#ifndef MIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER
406 template <detail::compatible_
string_view_with<
char> String>
410 return std::views::all(std::forward<String>(str))
411 | std::views::transform(
412 [](
const char c)
noexcept {
415 return static_cast<char>(
416 static_cast<unsigned char>(std::toupper(c)));
423 #if __has_include(<uni_algo/case.h>) \
424 && __has_include(<uni_algo/conv.h>)
425 #include <uni_algo/case.h>
426 #include <uni_algo/conv.h>
428 #error "Unable to find uni_algo includes."
438 template <detail::compatible_
string_view_with<
char> String>
440 constexpr auto operator()(String&& str)
const
442 return una::cases::to_casefold_utf8(
444 std::ranges::data(str),
445 std::ranges::size(str)});
456 template <detail::compatible_
string_view_with<
wchar_t> String>
458 constexpr auto operator()(String&& str)
const
460 return una::cases::to_casefold_utf16(
462 std::ranges::data(str),
463 std::ranges::size(str)});
474 template <detail::compatible_
string_view_with<
char8_t> String>
476 constexpr auto operator()(String&& str)
const
478 return una::cases::to_casefold_utf8(
480 std::ranges::data(str),
481 std::ranges::size(str)});
492 template <detail::compatible_
string_view_with<
char16_t> String>
494 constexpr auto operator()(String&& str)
const
496 return una::cases::to_casefold_utf16(
498 std::ranges::data(str),
499 std::ranges::size(str)});
510 template <detail::compatible_
string_view_with<
char32_t> String>
512 constexpr auto operator()(String&& str)
const
514 return una::utf8to32<char8_t, char32_t>(
515 una::cases::to_casefold_utf8(
518 std::ranges::data(str),
519 std::ranges::size(str)})));
Determines, whether the given type supports string normalization.
Definition String.hpp:376
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:343
Primary template, which always yields false.
Definition String.hpp:105
constexpr auto operator()(String &&str) const
Definition String.hpp:408
Primary template, purposely undefined.
Definition String.hpp:368
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