File indexing completed on 2025-01-18 10:09:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef RANGES_V3_VIEW_C_STR_HPP
0014 #define RANGES_V3_VIEW_C_STR_HPP
0015
0016 #include <type_traits>
0017
0018 #include <range/v3/range_fwd.hpp>
0019
0020 #include <range/v3/iterator/unreachable_sentinel.hpp>
0021 #include <range/v3/utility/static_const.hpp>
0022 #include <range/v3/view/delimit.hpp>
0023 #include <range/v3/view/subrange.hpp>
0024
0025 #include <range/v3/detail/prologue.hpp>
0026
0027 namespace ranges
0028 {
0029
0030 namespace detail
0031 {
0032 template<typename T>
0033 struct is_char_type_ : std::false_type
0034 {};
0035
0036 template<>
0037 struct is_char_type_<char> : std::true_type
0038 {};
0039
0040 template<>
0041 struct is_char_type_<wchar_t> : std::true_type
0042 {};
0043
0044 template<>
0045 struct is_char_type_<char16_t> : std::true_type
0046 {};
0047
0048 template<>
0049 struct is_char_type_<char32_t> : std::true_type
0050 {};
0051
0052 template<typename T>
0053 using is_char_type = is_char_type_<meta::_t<std::remove_cv<T>>>;
0054 }
0055
0056
0057
0058
0059 namespace views
0060 {
0061
0062
0063 struct c_str_fn
0064 {
0065
0066 template(typename Char, std::size_t N)(
0067 requires detail::is_char_type<Char>::value)
0068 ranges::subrange<Char *> operator()(Char (&sz)[N]) const
0069 {
0070 return {&sz[0], &sz[N - 1]};
0071 }
0072
0073
0074 template(typename Char)(
0075 requires detail::is_char_type<Char>::value)
0076 ranges::delimit_view<
0077 ranges::subrange<Char *, ranges::unreachable_sentinel_t>,
0078 meta::_t<std::remove_cv<Char>>>
0079 operator()(Char * sz) const volatile
0080 {
0081 using ch_t = meta::_t<std::remove_cv<Char>>;
0082 return ranges::views::delimit(sz, ch_t(0));
0083 }
0084 };
0085
0086
0087
0088 RANGES_INLINE_VARIABLE(c_str_fn, c_str)
0089 }
0090 }
0091
0092 #include <range/v3/detail/epilogue.hpp>
0093
0094 #endif