|
@ -4,8 +4,7 @@ |
|
|
#ifndef PEP_DATATYPES_STRING_VIEW_HH |
|
|
#ifndef PEP_DATATYPES_STRING_VIEW_HH |
|
|
#define PEP_DATATYPES_STRING_VIEW_HH |
|
|
#define PEP_DATATYPES_STRING_VIEW_HH |
|
|
|
|
|
|
|
|
#if (__cplusplus >= 201606) // std::string_view is C++17.
|
|
|
#include <string_view> |
|
|
# include <string_view> |
|
|
|
|
|
|
|
|
|
|
|
namespace pEp |
|
|
namespace pEp |
|
|
{ |
|
|
{ |
|
@ -17,42 +16,6 @@ namespace pEp |
|
|
typedef std::u32string_view u32string_view; |
|
|
typedef std::u32string_view u32string_view; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#else // in C++11 / C++14 use boost::string_view instead.
|
|
|
|
|
|
# include <boost/utility/string_view.hpp> |
|
|
|
|
|
|
|
|
|
|
|
namespace pEp |
|
|
|
|
|
{ |
|
|
|
|
|
template<class CharT> |
|
|
|
|
|
using basic_string_view = boost::basic_string_view<CharT>; |
|
|
|
|
|
|
|
|
|
|
|
typedef boost::string_view string_view; |
|
|
|
|
|
typedef boost::u16string_view u16string_view; |
|
|
|
|
|
typedef boost::u32string_view u32string_view; |
|
|
|
|
|
|
|
|
|
|
|
// boost::string_view does not provide these operations, neither by boost nor by the stdlib. :-(
|
|
|
|
|
|
template<class CharT> |
|
|
|
|
|
inline |
|
|
|
|
|
std::basic_string<CharT>& operator+=(std::basic_string<CharT>& s, const basic_string_view<CharT> v) |
|
|
|
|
|
{ |
|
|
|
|
|
s.append(v.data(), v.size()); |
|
|
|
|
|
return s; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<class CharT> |
|
|
|
|
|
inline |
|
|
|
|
|
std::basic_string<CharT> operator+(std::basic_string<CharT> s, const basic_string_view<CharT> v) |
|
|
|
|
|
{ |
|
|
|
|
|
return s += v; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// using ::std::operator+=;
|
|
|
|
|
|
// using ::boost::operator+=;
|
|
|
|
|
|
} // end of namespace pEp
|
|
|
|
|
|
|
|
|
|
|
|
#endif // C++17 switch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace pEp |
|
|
namespace pEp |
|
|
{ |
|
|
{ |
|
|
constexpr |
|
|
constexpr |
|
|