|
-
-
-
-
-
-
-
-
-
-
-
-
- #ifndef RANGES_V3_VIEW_C_STR_HPP
- #define RANGES_V3_VIEW_C_STR_HPP
-
- #include <type_traits>
-
- #include <range/v3/range_fwd.hpp>
-
- #include <range/v3/iterator/unreachable_sentinel.hpp>
- #include <range/v3/utility/static_const.hpp>
- #include <range/v3/view/delimit.hpp>
- #include <range/v3/view/subrange.hpp>
-
- namespace ranges
- {
-
- namespace detail
- {
- template<typename T>
- struct is_char_type_ : std::false_type
- {};
-
- template<>
- struct is_char_type_<char> : std::true_type
- {};
-
- template<>
- struct is_char_type_<wchar_t> : std::true_type
- {};
-
- template<>
- struct is_char_type_<char16_t> : std::true_type
- {};
-
- template<>
- struct is_char_type_<char32_t> : std::true_type
- {};
-
- template<typename T>
- using is_char_type = is_char_type_<meta::_t<std::remove_cv<T>>>;
- }
-
-
-
-
- namespace views
- {
-
-
- struct c_str_fn
- {
-
- template<typename Char, std::size_t N>
- auto operator()(Char (&sz)[N]) const -> CPP_ret(ranges::subrange<Char *>)(
- requires detail::is_char_type<Char>::value)
- {
- return {&sz[0], &sz[N - 1]};
- }
-
-
- template<typename Char>
- auto operator()(Char * sz) const volatile
- -> CPP_ret(ranges::delimit_view<
- ranges::subrange<Char *, ranges::unreachable_sentinel_t>,
- meta::_t<std::remove_cv<Char>>>)(
- requires detail::is_char_type<Char>::value)
- {
- using ch_t = meta::_t<std::remove_cv<Char>>;
- return ranges::views::delimit(sz, ch_t(0));
- }
- };
-
-
-
- RANGES_INLINE_VARIABLE(c_str_fn, c_str)
- }
- }
-
- #endif
|