11 #ifndef NONSTD_SV_LITE_H_INCLUDED 12 #define NONSTD_SV_LITE_H_INCLUDED 14 #define string_view_lite_MAJOR 1 15 #define string_view_lite_MINOR 1 16 #define string_view_lite_PATCH 0 18 #define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH) 20 #define nssv_STRINGIFY( x ) nssv_STRINGIFY_( x ) 21 #define nssv_STRINGIFY_( x ) #x 25 #define nssv_STRING_VIEW_DEFAULT 0 26 #define nssv_STRING_VIEW_NONSTD 1 27 #define nssv_STRING_VIEW_STD 2 29 #if !defined( nssv_CONFIG_SELECT_STRING_VIEW ) 30 # define nssv_CONFIG_SELECT_STRING_VIEW ( nssv_HAVE_STD_STRING_VIEW ? nssv_STRING_VIEW_STD : nssv_STRING_VIEW_NONSTD ) 33 #if defined( nssv_CONFIG_SELECT_STD_STRING_VIEW ) || defined( nssv_CONFIG_SELECT_NONSTD_STRING_VIEW ) 34 # error nssv_CONFIG_SELECT_STD_STRING_VIEW and nssv_CONFIG_SELECT_NONSTD_STRING_VIEW are deprecated and removed, please use nssv_CONFIG_SELECT_STRING_VIEW=nssv_STRING_VIEW_... 37 #ifndef nssv_CONFIG_STD_SV_OPERATOR 38 # define nssv_CONFIG_STD_SV_OPERATOR 0 41 #ifndef nssv_CONFIG_USR_SV_OPERATOR 42 # define nssv_CONFIG_USR_SV_OPERATOR 1 45 #ifdef nssv_CONFIG_CONVERSION_STD_STRING 46 # define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS nssv_CONFIG_CONVERSION_STD_STRING 47 # define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS nssv_CONFIG_CONVERSION_STD_STRING 50 #ifndef nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 51 # define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1 54 #ifndef nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 55 # define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1 61 #ifndef nssv_CPLUSPLUS 62 # if defined(_MSVC_LANG ) && !defined(__clang__) 63 # define nssv_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG ) 65 # define nssv_CPLUSPLUS __cplusplus 69 #define nssv_CPP98_OR_GREATER ( nssv_CPLUSPLUS >= 199711L ) 70 #define nssv_CPP11_OR_GREATER ( nssv_CPLUSPLUS >= 201103L ) 71 #define nssv_CPP11_OR_GREATER_ ( nssv_CPLUSPLUS >= 201103L ) 72 #define nssv_CPP14_OR_GREATER ( nssv_CPLUSPLUS >= 201402L ) 73 #define nssv_CPP17_OR_GREATER ( nssv_CPLUSPLUS >= 201703L ) 74 #define nssv_CPP20_OR_GREATER ( nssv_CPLUSPLUS >= 202000L ) 76 # define nssv_HAVE_STD_STRING_VIEW 0 78 #define nssv_USES_STD_STRING_VIEW ( (nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_STD) || ((nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_DEFAULT) && nssv_HAVE_STD_STRING_VIEW) ) 80 #define nssv_HAVE_STARTS_WITH ( nssv_CPP20_OR_GREATER || !nssv_USES_STD_STRING_VIEW ) 81 #define nssv_HAVE_ENDS_WITH nssv_HAVE_STARTS_WITH 87 #if nssv_USES_STD_STRING_VIEW 89 #include <string_view> 93 #if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 97 template<
class CharT,
class Traits,
class Allocator = std::allocator<CharT> >
98 std::basic_string<CharT, Traits, Allocator>
99 to_string( std::basic_string_view<CharT, Traits> v, Allocator
const & a = Allocator() )
101 return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
104 template<
class CharT,
class Traits,
class Allocator >
105 std::basic_string_view<CharT, Traits>
106 to_string_view( std::basic_string<CharT, Traits, Allocator>
const & s )
108 return std::basic_string_view<CharT, Traits>( s.data(), s.size() );
113 #if nssv_CONFIG_STD_SV_OPERATOR 115 using namespace std::literals::string_view_literals;
119 #if nssv_CONFIG_USR_SV_OPERATOR 121 inline namespace literals {
122 inline namespace string_view_literals {
140 constexpr
std::wstring_view operator "" _sv(
const wchar_t* str,
size_t len ) noexcept
147 #endif // nssv_CONFIG_USR_SV_OPERATOR 151 #endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 163 using std::operator==;
164 using std::operator!=;
165 using std::operator<;
166 using std::operator<=;
167 using std::operator>;
168 using std::operator>=;
170 using std::operator<<;
174 #else // nssv_HAVE_STD_STRING_VIEW 193 #if defined(_MSC_VER ) && !defined(__clang__) 194 # define nssv_COMPILER_MSVC_VER (_MSC_VER ) 195 # define nssv_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) ) 197 # define nssv_COMPILER_MSVC_VER 0 198 # define nssv_COMPILER_MSVC_VERSION 0 201 #define nssv_COMPILER_VERSION( major, minor, patch ) (10 * ( 10 * major + minor) + patch) 203 #if defined(__clang__) 204 # define nssv_COMPILER_CLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) 206 # define nssv_COMPILER_CLANG_VERSION 0 209 #if defined(__GNUC__) && !defined(__clang__) 210 # define nssv_COMPILER_GNUC_VERSION nssv_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) 212 # define nssv_COMPILER_GNUC_VERSION 0 216 #define nssv_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) ) 221 # define nssv_HAS_CPP0X _HAS_CPP0X 223 # define nssv_HAS_CPP0X 0 228 #if nssv_COMPILER_MSVC_VER >= 1900 229 # undef nssv_CPP11_OR_GREATER 230 # define nssv_CPP11_OR_GREATER 1 233 #define nssv_CPP11_90 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1500) 234 #define nssv_CPP11_100 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1600) 235 #define nssv_CPP11_110 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1700) 236 #define nssv_CPP11_120 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1800) 237 #define nssv_CPP11_140 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1900) 238 #define nssv_CPP11_141 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1910) 240 #define nssv_CPP14_000 (nssv_CPP14_OR_GREATER) 241 #define nssv_CPP17_000 (nssv_CPP17_OR_GREATER) 245 #define nssv_HAVE_CONSTEXPR_11 nssv_CPP11_140 246 #define nssv_HAVE_EXPLICIT_CONVERSION nssv_CPP11_140 247 #define nssv_HAVE_INLINE_NAMESPACE nssv_CPP11_140 248 #define nssv_HAVE_NOEXCEPT nssv_CPP11_140 249 #define nssv_HAVE_NULLPTR nssv_CPP11_100 250 #define nssv_HAVE_REF_QUALIFIER nssv_CPP11_140 251 #define nssv_HAVE_UNICODE_LITERALS nssv_CPP11_140 252 #define nssv_HAVE_USER_DEFINED_LITERALS nssv_CPP11_140 253 #define nssv_HAVE_WCHAR16_T nssv_CPP11_100 254 #define nssv_HAVE_WCHAR32_T nssv_CPP11_100 256 #if ! ( ( nssv_CPP11 && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) ) 257 # define nssv_HAVE_STD_DEFINED_LITERALS nssv_CPP11_140 262 #define nssv_HAVE_CONSTEXPR_14 nssv_CPP14_000 266 #define nssv_HAVE_NODISCARD nssv_CPP17_000 270 #define nssv_HAVE_STD_HASH nssv_CPP11_120 274 #if nssv_HAVE_CONSTEXPR_11 275 # define nssv_constexpr constexpr 277 # define nssv_constexpr 280 #if nssv_HAVE_CONSTEXPR_14 281 # define nssv_constexpr14 constexpr 283 # define nssv_constexpr14 286 #if nssv_HAVE_EXPLICIT_CONVERSION 287 # define nssv_explicit explicit 289 # define nssv_explicit 292 #if nssv_HAVE_INLINE_NAMESPACE 293 # define nssv_inline_ns inline 295 # define nssv_inline_ns 298 #if nssv_HAVE_NOEXCEPT 299 # define nssv_noexcept noexcept 301 # define nssv_noexcept 312 #if nssv_HAVE_NULLPTR 313 # define nssv_nullptr nullptr 315 # define nssv_nullptr NULL 318 #if nssv_HAVE_NODISCARD 319 # define nssv_nodiscard [[nodiscard]] 321 # define nssv_nodiscard 334 #if nssv_CPP11_OR_GREATER 335 # include <type_traits> 340 #if defined(__clang__) 341 # pragma clang diagnostic ignored "-Wreserved-user-defined-literal" 342 # pragma clang diagnostic push 343 # pragma clang diagnostic ignored "-Wuser-defined-literals" 344 #elif defined(__GNUC__) 345 # pragma GCC diagnostic push 346 # pragma GCC diagnostic ignored "-Wliteral-suffix" 349 #if nssv_COMPILER_MSVC_VERSION >= 140 350 # define nssv_SUPPRESS_MSGSL_WARNING(expr) [[gsl::suppress(expr)]] 351 # define nssv_SUPPRESS_MSVC_WARNING(code, descr) __pragma(warning(suppress: code) ) 352 # define nssv_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes)) 354 # define nssv_SUPPRESS_MSGSL_WARNING(expr) 355 # define nssv_SUPPRESS_MSVC_WARNING(code, descr) 356 # define nssv_DISABLE_MSVC_WARNINGS(codes) 359 #if defined(__clang__) 360 # define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop") 361 #elif defined(__GNUC__) 362 # define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop") 363 #elif nssv_COMPILER_MSVC_VERSION >= 140 364 # define nssv_RESTORE_WARNINGS() __pragma(warning(pop )) 366 # define nssv_RESTORE_WARNINGS() 380 namespace
nonstd {
namespace sv_lite {
385 class Traits = std::char_traits<CharT>
403 typedef Traits traits_type;
404 typedef CharT value_type;
406 typedef CharT * pointer;
407 typedef CharT
const * const_pointer;
408 typedef CharT & reference;
409 typedef CharT
const & const_reference;
411 typedef const_pointer iterator;
412 typedef const_pointer const_iterator;
413 typedef std::reverse_iterator< const_iterator > reverse_iterator;
414 typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
416 typedef std::size_t size_type;
417 typedef std::ptrdiff_t difference_type;
426 #if nssv_CPP11_OR_GREATER 430 : data_( other.
data_)
431 , size_( other.
size_)
442 , size_( Traits::length(s) )
447 #if nssv_CPP11_OR_GREATER 448 nssv_constexpr14 basic_string_view & operator=( basic_string_view
const & other ) nssv_noexcept =
default;
450 nssv_constexpr14 basic_string_view & operator=( basic_string_view
const & other ) nssv_noexcept
460 nssv_constexpr const_iterator begin()
const nssv_noexcept {
return data_; }
461 nssv_constexpr const_iterator end()
const nssv_noexcept {
return data_ + size_; }
463 nssv_constexpr const_iterator cbegin()
const nssv_noexcept {
return begin(); }
464 nssv_constexpr const_iterator cend()
const nssv_noexcept {
return end(); }
466 nssv_constexpr const_reverse_iterator rbegin()
const nssv_noexcept {
return const_reverse_iterator( end() ); }
467 nssv_constexpr const_reverse_iterator rend()
const nssv_noexcept {
return const_reverse_iterator( begin() ); }
469 nssv_constexpr const_reverse_iterator crbegin()
const nssv_noexcept {
return rbegin(); }
470 nssv_constexpr const_reverse_iterator crend()
const nssv_noexcept {
return rend(); }
474 nssv_constexpr size_type size()
const nssv_noexcept {
return size_; }
475 nssv_constexpr size_type length()
const nssv_noexcept {
return size_; }
488 return data_at( pos );
495 return data_at( pos );
498 throw std::out_of_range(
"nonst::string_view::at()");
501 nssv_constexpr const_reference front()
const {
return data_at( 0 ); }
502 nssv_constexpr const_reference back()
const {
return data_at( size() - 1 ); }
530 size_type copy( CharT * dest, size_type n, size_type pos = 0 )
const 533 throw std::out_of_range(
"nonst::string_view::copy()");
535 const size_type rlen = (
std::min)( n, size() - pos );
537 (
void) Traits::copy( dest,
data() + pos, rlen );
542 nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos )
const 545 throw std::out_of_range(
"nonst::string_view::substr()");
557 return size() == other.
size() ? 0 : size() < other.
size() ? -1 : 1;
560 nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other )
const 562 return substr( pos1, n1 ).compare( other );
565 nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other, size_type pos2, size_type n2 )
const 567 return substr( pos1, n1 ).compare( other.substr( pos2, n2 ) );
575 nssv_constexpr int compare( size_type pos1, size_type n1, CharT
const * s )
const 580 nssv_constexpr int compare( size_type pos1, size_type n1, CharT
const * s, size_type n2 )
const 589 nssv_constexpr bool starts_with( basic_string_view v )
const nssv_noexcept
591 return size() >= v.
size() && compare( 0, v.
size(), v ) == 0;
606 nssv_constexpr bool ends_with( basic_string_view v )
const nssv_noexcept
608 return size() >= v.
size() && compare( size() - v.
size(), npos, v ) == 0;
628 : to_pos( std::search( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
648 nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos )
const nssv_noexcept
650 if ( size() < v.
size() )
656 const_iterator last = cbegin() + (
std::min)( size() - v.
size(), pos ) + v.
size();
657 const_iterator
result = std::find_end( cbegin(), last, v.cbegin(), v.cend(), Traits::eq );
659 return result != last ? size_type( result - cbegin() ) : npos;
662 nssv_constexpr14 size_type rfind( CharT c, size_type pos = npos )
const nssv_noexcept
667 nssv_constexpr14 size_type rfind( CharT
const * s, size_type pos, size_type n )
const 672 nssv_constexpr14 size_type rfind( CharT
const * s, size_type pos = npos )
const 679 nssv_constexpr size_type find_first_of( basic_string_view v, size_type pos = 0 )
const nssv_noexcept
683 : to_pos( std::find_first_of( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
686 nssv_constexpr size_type find_first_of( CharT c, size_type pos = 0 )
const nssv_noexcept
691 nssv_constexpr size_type find_first_of( CharT
const * s, size_type pos, size_type n )
const 696 nssv_constexpr size_type find_first_of( CharT
const * s, size_type pos = 0 )
const 703 nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos )
const nssv_noexcept
708 ? find_last_of( v, size() - 1 )
709 : to_pos( std::find_first_of( const_reverse_iterator( cbegin() + pos + 1 ), crend(), v.cbegin(), v.cend(), Traits::eq ) );
712 nssv_constexpr size_type find_last_of( CharT c, size_type pos = npos )
const nssv_noexcept
717 nssv_constexpr size_type find_last_of( CharT
const * s, size_type pos, size_type count )
const 722 nssv_constexpr size_type find_last_of( CharT
const * s, size_type pos = npos )
const 729 nssv_constexpr size_type find_first_not_of( basic_string_view v, size_type pos = 0 )
const nssv_noexcept
733 : to_pos( std::find_if( cbegin() + pos, cend(), not_in_view( v ) ) );
736 nssv_constexpr size_type find_first_not_of( CharT c, size_type pos = 0 )
const nssv_noexcept
741 nssv_constexpr size_type find_first_not_of( CharT
const * s, size_type pos, size_type count )
const 746 nssv_constexpr size_type find_first_not_of( CharT
const * s, size_type pos = 0 )
const 753 nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos )
const nssv_noexcept
758 ? find_last_not_of( v, size() - 1 )
759 : to_pos( std::find_if( const_reverse_iterator( cbegin() + pos + 1 ), crend(), not_in_view( v ) ) );
762 nssv_constexpr size_type find_last_not_of( CharT c, size_type pos = npos )
const nssv_noexcept
767 nssv_constexpr size_type find_last_not_of( CharT
const * s, size_type pos, size_type count )
const 772 nssv_constexpr size_type find_last_not_of( CharT
const * s, size_type pos = npos )
const 779 #if nssv_CPP17_OR_GREATER 781 #elif nssv_CPP11_OR_GREATER 782 enum : size_type { npos = size_type(-1) };
784 enum { npos = size_type(-1) };
790 const basic_string_view v;
796 return npos == v.find_first_of( c );
802 return it == cend() ? npos : size_type( it - cbegin() );
805 nssv_constexpr size_type to_pos( const_reverse_iterator it )
const 807 return it == crend() ? npos : size_type( crend() - it - 1 );
812 #if nssv_BETWEEN( nssv_COMPILER_GNUC_VERSION, 1, 500 ) 815 return assert( pos < size() ), data_[pos];
824 #if nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 826 template<
class Allocator >
827 basic_string_view( std::basic_string<CharT, Traits, Allocator>
const & s ) nssv_noexcept
832 #if nssv_HAVE_EXPLICIT_CONVERSION 834 template<
class Allocator >
835 explicit operator std::basic_string<CharT, Traits, Allocator>()
const 840 #endif // nssv_HAVE_EXPLICIT_CONVERSION 842 #if nssv_CPP11_OR_GREATER 844 template<
class Allocator = std::allocator<CharT> >
845 std::basic_string<CharT, Traits, Allocator>
846 to_string( Allocator
const & a = Allocator() )
const 848 return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
853 std::basic_string<CharT, Traits>
856 return std::basic_string<CharT, Traits>( begin(), end() );
859 template<
class Allocator >
860 std::basic_string<CharT, Traits, Allocator>
863 return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
866 #endif // nssv_CPP11_OR_GREATER 868 #endif // nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 878 template<
class CharT,
class Traits >
882 {
return lhs.
compare( rhs ) == 0 ; }
884 template<
class CharT,
class Traits >
888 {
return lhs.
compare( rhs ) != 0 ; }
890 template<
class CharT,
class Traits >
894 {
return lhs.
compare( rhs ) < 0 ; }
896 template<
class CharT,
class Traits >
900 {
return lhs.
compare( rhs ) <= 0 ; }
902 template<
class CharT,
class Traits >
906 {
return lhs.
compare( rhs ) > 0 ; }
908 template<
class CharT,
class Traits >
912 {
return lhs.
compare( rhs ) >= 0 ; }
919 #if nssv_CPP11_OR_GREATER && ! nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 100, 141 ) 921 #define nssv_BASIC_STRING_VIEW_I(T,U) typename std::decay< basic_string_view<T,U> >::type 923 #if nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 140, 150 ) 924 # define nssv_MSVC_ORDER(x) , int=x 926 # define nssv_MSVC_ORDER(x) 931 template<
class CharT,
class Traits nssv_MSVC_ORDER(1) >
935 {
return lhs.
compare( rhs ) == 0; }
937 template<
class CharT,
class Traits nssv_MSVC_ORDER(2) >
939 nssv_BASIC_STRING_VIEW_I(CharT, Traits) lhs,
941 {
return lhs.size() == rhs.
size() && lhs.compare( rhs ) == 0; }
945 template<
class CharT,
class Traits nssv_MSVC_ORDER(1) >
948 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs )
nssv_noexcept 949 {
return lhs.
size() != rhs.size() || lhs.
compare( rhs ) != 0 ; }
951 template<
class CharT,
class Traits nssv_MSVC_ORDER(2) >
953 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
955 {
return lhs.compare( rhs ) != 0 ; }
959 template<
class CharT,
class Traits nssv_MSVC_ORDER(1) >
962 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs )
nssv_noexcept 963 {
return lhs.
compare( rhs ) < 0 ; }
965 template<
class CharT,
class Traits nssv_MSVC_ORDER(2) >
967 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
969 {
return lhs.compare( rhs ) < 0 ; }
973 template<
class CharT,
class Traits nssv_MSVC_ORDER(1) >
976 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs )
nssv_noexcept 977 {
return lhs.
compare( rhs ) <= 0 ; }
979 template<
class CharT,
class Traits nssv_MSVC_ORDER(2) >
981 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
983 {
return lhs.compare( rhs ) <= 0 ; }
987 template<
class CharT,
class Traits nssv_MSVC_ORDER(1) >
990 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs )
nssv_noexcept 991 {
return lhs.
compare( rhs ) > 0 ; }
993 template<
class CharT,
class Traits nssv_MSVC_ORDER(2) >
995 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
997 {
return lhs.compare( rhs ) > 0 ; }
1001 template<
class CharT,
class Traits nssv_MSVC_ORDER(1) >
1004 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs )
nssv_noexcept 1005 {
return lhs.
compare( rhs ) >= 0 ; }
1007 template<
class CharT,
class Traits nssv_MSVC_ORDER(2) >
1009 nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
1011 {
return lhs.compare( rhs ) >= 0 ; }
1013 #undef nssv_MSVC_ORDER 1014 #undef nssv_BASIC_STRING_VIEW_I 1016 #endif // nssv_CPP11_OR_GREATER 1022 template<
class Stream >
1023 void write_padding( Stream & os, std::streamsize n )
1025 for ( std::streamsize i = 0; i < n; ++i )
1026 os.rdbuf()->sputc( os.fill() );
1029 template<
class Stream,
class View >
1030 Stream & write_to_stream( Stream & os, View
const & sv )
1032 typename Stream::sentry sentry( os );
1037 const std::streamsize length =
static_cast<std::streamsize
>( sv.length() );
1040 const bool pad = ( length < os.width() );
1041 const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) ==
std::ios_base::right;
1044 write_padding( os, os.width() - length );
1047 os.rdbuf()->sputn( sv.begin(), length );
1049 if ( pad && !left_pad )
1050 write_padding( os, os.width() - length );
1060 template<
class CharT,
class Traits >
1061 std::basic_ostream<CharT, Traits> &
1063 std::basic_ostream<CharT, Traits>& os,
1066 return detail::write_to_stream( os, sv );
1073 #if nssv_HAVE_WCHAR16_T 1084 #if nssv_HAVE_USER_DEFINED_LITERALS 1090 #if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS 1112 #endif // nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS 1114 #if nssv_CONFIG_USR_SV_OPERATOR 1136 #endif // nssv_CONFIG_USR_SV_OPERATOR 1146 #if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1153 #if nssv_CPP11_OR_GREATER && nssv_COMPILER_MSVC_VERSION != 140 1155 template<
class CharT,
class Traits,
class Allocator = std::allocator<CharT> >
1156 std::basic_string<CharT, Traits, Allocator>
1157 to_string( basic_string_view<CharT, Traits> v, Allocator
const & a = Allocator() )
1159 return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
1164 template<
class CharT,
class Traits >
1165 std::basic_string<CharT, Traits>
1168 return std::basic_string<CharT, Traits>( v.begin(), v.end() );
1171 template<
class CharT,
class Traits,
class Allocator >
1172 std::basic_string<CharT, Traits, Allocator>
1173 to_string( basic_string_view<CharT, Traits> v, Allocator
const & a )
1175 return std::basic_string<CharT, Traits, Allocator>( v.begin(), v.end(), a );
1178 #endif // nssv_CPP11_OR_GREATER 1180 template<
class CharT,
class Traits,
class Allocator >
1181 basic_string_view<CharT, Traits>
1184 return basic_string_view<CharT, Traits>( s.data(), s.size() );
1189 #endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1201 #if nssv_HAVE_WCHAR16_T 1204 #if nssv_HAVE_WCHAR32_T 1210 using sv_lite::operator==;
1211 using sv_lite::operator!=;
1212 using sv_lite::operator<;
1213 using sv_lite::operator<=;
1214 using sv_lite::operator>;
1215 using sv_lite::operator>=;
1217 using sv_lite::operator<<;
1219 #if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1231 #if nssv_HAVE_STD_HASH 1233 #include <functional> 1243 return std::hash<std::string>()( std::string( v.data(), v.size() ) );
1253 return std::hash<std::wstring>()( std::wstring( v.data(), v.size() ) );
1263 return std::hash<std::u16string>()( std::u16string( v.data(), v.size() ) );
1273 return std::hash<std::u32string>()( std::u32string( v.data(), v.size() ) );
1279 #endif // nssv_HAVE_STD_HASH 1283 #endif // nssv_HAVE_STD_STRING_VIEW 1284 #endif // NONSTD_SV_LITE_H_INCLUDED constexpr bool operator<=(const optional< T > &lhs, const optional< U > &rhs)
relop
constexpr const Char * data() const
static unsigned char pad[64]
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
relop
bool operator==(fp x, fp y)
constexpr bool operator>=(const optional< T > &lhs, const optional< U > &rhs)
relop
constexpr bool operator>(const optional< T > &lhs, const optional< U > &rhs)
relop
basic_string_view< CharT, Traits > to_string_view(std::basic_string< CharT, Traits, Allocator > const &s)
std::size_t hash(const BasicJsonType &j)
hash a JSON value
basic_string_view< char > string_view
std::u16string_view u16string_view
QDebug operator<<(QDebug debug, const QwtInterval &interval)
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
basic_string_view< wchar_t > wstring_view
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
std::basic_string_view< C, T > basic_string_view
#define nssv_RESTORE_WARNINGS()
constexpr size_t size() const
#define assert(a, b, c, d)
#define nssv_DISABLE_MSVC_WARNINGS(codes)
int compare(basic_string_view other) const
std::basic_string< CharT, Traits > to_string(basic_string_view< CharT, Traits > v)
std::u32string_view u32string_view