6#ifndef MIMICPP_STRING_HPP
7#define MIMICPP_STRING_HPP
45 :
public std::false_type
61 :
public std::true_type
70 :
public std::true_type
79 :
public std::true_type
88 :
public std::true_type
97 :
public std::true_type
106 :
public std::true_type
115 :
public std::true_type
136 template <
typename T>
143 template <
typename T>
150 template <
typename T>
151 requires std::is_pointer_v<T>
155 using char_t = std::remove_const_t<std::remove_pointer_t<T>>;
156 using view_t = std::basic_string_view<char_t>;
159 static constexpr view_t view(
const std::remove_pointer_t<T>* str)
noexcept
169 template <
typename T>
170 requires std::is_array_v<T>
180 template <
typename Char,
typename Traits,
typename Allocator>
184 using string_t = std::basic_string<Char, Traits, Allocator>;
185 using view_t = std::basic_string_view<Char, Traits>;
198 template <
typename Char,
typename Traits>
202 using view_t = std::basic_string_view<Char, Traits>;
220 template <
typename T>
224 requires std::ranges::contiguous_range<string_view_t<T>>;
225 requires std::ranges::sized_range<string_view_t<T>>;
226 requires std::ranges::borrowed_range<string_view_t<T>>;
227 requires std::same_as<
229 std::ranges::range_value_t<string_view_t<T>>>;
251 template <satisfies<is_
character> Char>
259 template <
typename String>
262 &&
requires(
const string_case_fold_converter<string_char_t<String>> converter,
string_view_t<String> view)
264 { std::invoke(converter, std::move(view)) } -> std::ranges::forward_range;
266 &&
requires(std::invoke_result_t<string_case_fold_converter<string_char_t<String>>,
string_view_t<String>> normalized)
268 requires std::same_as<
270 std::ranges::range_value_t<
decltype(normalized)>>;
274namespace mimicpp::detail
276 template <
typename View,
typename Char>
278 && std::ranges::borrowed_range<View>
279 && std::ranges::contiguous_range<View>
280 && std::ranges::sized_range<View>
281 && std::same_as<Char, std::ranges::range_value_t<View>>;
284#ifndef MIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER
293 template <detail::compatible_
string_view_with<
char> String>
295 constexpr auto operator ()(String&& str)
const
297 return std::views::all(std::forward<String>(str))
298 | std::views::transform(
299 [](
const char c)
noexcept
303 return static_cast<char>(
304 static_cast<unsigned char>(std::toupper(c)));
314#include <unicodelib.h>
315#include <unicodelib_encodings.h>
324 template <detail::compatible_
string_view_with<
char> String>
326 constexpr auto operator ()(String&& str)
const
328 return unicode::utf8::encode(
329 unicode::to_case_fold(
330 unicode::utf8::decode(
332 std::ranges::data(str),
333 std::ranges::size(str)
345 template <detail::compatible_
string_view_with<
wchar_t> String>
347 constexpr auto operator ()(String&& str)
const
349 return unicode::to_wstring(
350 unicode::to_case_fold(
353 std::ranges::data(str),
354 std::ranges::size(str)
366 template <detail::compatible_
string_view_with<
char8_t> String>
368 constexpr auto operator ()(String&& str)
const
370 const std::string caseFolded = std::invoke(
373 std::bit_cast<const char*>(std::ranges::data(str)),
374 std::ranges::size(str)
377 return std::u8string{
391 template <detail::compatible_
string_view_with<
char16_t> String>
393 constexpr auto operator ()(String&& str)
const
395 return unicode::utf16::encode(
396 unicode::to_case_fold(
397 unicode::utf16::decode(
399 std::ranges::data(str),
400 std::ranges::size(str)
412 template <detail::compatible_
string_view_with<
char32_t> String>
414 constexpr auto operator ()(String&& str)
const
416 return unicode::to_case_fold(
418 std::ranges::data(str),
419 std::ranges::size(str)
Determines, whether the given type supports string normalization.
Definition String.hpp:260
Determines, whether the given type can be used as a string-type.
Definition String.hpp:221
constexpr bool is_character_v
Convenience boolean-constant to the result of is_character trait.
Definition String.hpp:54
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:137
typename string_traits< std::remove_cvref_t< T > >::char_t string_char_t
Computes the character type for the given string.
Definition String.hpp:144
Definition BoostTest.hpp:20
Primary template, which always yields false.
Definition String.hpp:46
Primary template, purposely undefined.
Definition String.hpp:252
std::remove_const_t< std::remove_pointer_t< T > > char_t
Definition String.hpp:155
std::basic_string_view< char_t > view_t
Definition String.hpp:156
static constexpr view_t view(const std::remove_pointer_t< T > *str) noexcept
Definition String.hpp:159
std::basic_string_view< Char, Traits > view_t
Definition String.hpp:185
std::basic_string< Char, Traits, Allocator > string_t
Definition String.hpp:184
static constexpr view_t view(const string_t &str) noexcept
Definition String.hpp:188
Char char_t
Definition String.hpp:183
static constexpr view_t view(view_t str) noexcept
Definition String.hpp:205
std::basic_string_view< Char, Traits > view_t
Definition String.hpp:202
Char char_t
Definition String.hpp:201