cppx-core
pointers-from-string_view.hpp
Go to the documentation of this file.
1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi").
2 #include <cppx-core/collections/is_empty.hpp> // cppx::is_empty
3 #include <cppx-core/language/syntax/type-assemblers.hpp> // cppx::(P_, Raw_array_of_)
4 #include <cppx-core/language/types/C_str_.hpp> // cppx::C_str_
5 
6 #include <string_view> // std::string_view
7 
8 namespace cppx
9 {
10  CPPX_USE_STD( basic_string_view );
11 
12  template< class Char>
14 
15  template< class Char >
16  inline auto p_first_of( const basic_string_view<Char>& view ) noexcept
17  -> C_str_<Char>
18  { return (is_empty( view )? empty_c_string<Char> : view.data()); }
19 
20  template< class Char >
21  inline auto p_beyond_of( const basic_string_view<Char>& view ) noexcept
22  -> C_str_<Char>
23  { return p_first_of( view ) + view.size(); }
24 
25 } // namespace cppx
P_< Const_< Char > > C_str_
Definition: C_str_.hpp:33
constexpr Raw_array_of_< 1, const Char > empty_c_string
C_str for char const*; Wide_c_str for wchar_t const*; and Mutable_c_str and Mutable_wide_c_str as dit...
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
auto p_first_of(const basic_string_view< Char > &view) noexcept -> C_str_< Char >
Simple type builders Type_, P_, R_, Raw_array_ and Raw_array_of_.
auto is_empty(const Collection &c) -> Truth
Definition: is_empty.hpp:33
Item[n] Raw_array_of_
Creates a raw array type of a specified size.
auto p_beyond_of(const basic_string_view< Char > &view) noexcept -> C_str_< Char >