string_view.hpp
Go to the documentation of this file.
1 // Copyright 2017-2018 by Martin Moene
2 //
3 // string-view lite, a C++17-like string_view for C++98 and later.
4 // For more information see https://github.com/martinmoene/string-view-lite
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 
9 #pragma once
10 
11 #ifndef NONSTD_SV_LITE_H_INCLUDED
12 #define NONSTD_SV_LITE_H_INCLUDED
13 
14 #define string_view_lite_MAJOR 1
15 #define string_view_lite_MINOR 1
16 #define string_view_lite_PATCH 0
17 
18 #define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH)
19 
20 #define nssv_STRINGIFY( x ) nssv_STRINGIFY_( x )
21 #define nssv_STRINGIFY_( x ) #x
22 
23 // string-view lite configuration:
24 
25 #define nssv_STRING_VIEW_DEFAULT 0
26 #define nssv_STRING_VIEW_NONSTD 1
27 #define nssv_STRING_VIEW_STD 2
28 
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 )
31 #endif
32 
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_...
35 #endif
36 
37 #ifndef nssv_CONFIG_STD_SV_OPERATOR
38 # define nssv_CONFIG_STD_SV_OPERATOR 0
39 #endif
40 
41 #ifndef nssv_CONFIG_USR_SV_OPERATOR
42 # define nssv_CONFIG_USR_SV_OPERATOR 1
43 #endif
44 
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
48 #endif
49 
50 #ifndef nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
51 # define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1
52 #endif
53 
54 #ifndef nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
55 # define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1
56 #endif
57 
58 // C++ language version detection (C++20 is speculative):
59 // Note: VC14.0/1900 (VS2015) lacks too much from C++14.
60 
61 #ifndef nssv_CPLUSPLUS
62 # if defined(_MSVC_LANG ) && !defined(__clang__)
63 # define nssv_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG )
64 # else
65 # define nssv_CPLUSPLUS __cplusplus
66 # endif
67 #endif
68 
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 )
75 
76 # define nssv_HAVE_STD_STRING_VIEW 0
77 
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) )
79 
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
82 
83 //
84 // Use C++17 std::string_view:
85 //
86 
87 #if nssv_USES_STD_STRING_VIEW
88 
89 #include <string_view>
90 
91 // Extensions for std::string:
92 
93 #if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
94 
95 namespace nonstd {
96 
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() )
100 {
101  return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
102 }
103 
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 )
107 {
108  return std::basic_string_view<CharT, Traits>( s.data(), s.size() );
109 }
110 
111 // Literal operators sv and _sv:
112 
113 #if nssv_CONFIG_STD_SV_OPERATOR
114 
115 using namespace std::literals::string_view_literals;
116 
117 #endif
118 
119 #if nssv_CONFIG_USR_SV_OPERATOR
120 
121 inline namespace literals {
122 inline namespace string_view_literals {
123 
124 
125 constexpr std::string_view operator "" _sv( const char* str, size_t len ) noexcept // (1)
126 {
127  return std::string_view{ str, len };
128 }
129 
130 constexpr std::u16string_view operator "" _sv( const char16_t* str, size_t len ) noexcept // (2)
131 {
132  return std::u16string_view{ str, len };
133 }
134 
135 constexpr std::u32string_view operator "" _sv( const char32_t* str, size_t len ) noexcept // (3)
136 {
137  return std::u32string_view{ str, len };
138 }
139 
140 constexpr std::wstring_view operator "" _sv( const wchar_t* str, size_t len ) noexcept // (4)
141 {
142  return std::wstring_view{ str, len };
143 }
144 
145 }} // namespace literals::string_view_literals
146 
147 #endif // nssv_CONFIG_USR_SV_OPERATOR
148 
149 } // namespace nonstd
150 
151 #endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
152 
153 namespace nonstd {
154 
155 using std::string_view;
156 using std::wstring_view;
157 using std::u16string_view;
158 using std::u32string_view;
160 
161 // literal "sv" and "_sv", see above
162 
163 using std::operator==;
164 using std::operator!=;
165 using std::operator<;
166 using std::operator<=;
167 using std::operator>;
168 using std::operator>=;
169 
170 using std::operator<<;
171 
172 } // namespace nonstd
173 
174 #else // nssv_HAVE_STD_STRING_VIEW
175 
176 //
177 // Before C++17: use string_view lite:
178 //
179 
180 // Compiler versions:
181 //
182 // MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0)
183 // MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002)
184 // MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003)
185 // MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
186 // MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
187 // MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
188 // MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
189 // MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
190 // MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
191 // MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017)
192 
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 ) ) )
196 #else
197 # define nssv_COMPILER_MSVC_VER 0
198 # define nssv_COMPILER_MSVC_VERSION 0
199 #endif
200 
201 #define nssv_COMPILER_VERSION( major, minor, patch ) (10 * ( 10 * major + minor) + patch)
202 
203 #if defined(__clang__)
204 # define nssv_COMPILER_CLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
205 #else
206 # define nssv_COMPILER_CLANG_VERSION 0
207 #endif
208 
209 #if defined(__GNUC__) && !defined(__clang__)
210 # define nssv_COMPILER_GNUC_VERSION nssv_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
211 #else
212 # define nssv_COMPILER_GNUC_VERSION 0
213 #endif
214 
215 // half-open range [lo..hi):
216 #define nssv_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) )
217 
218 // Presence of language and library features:
219 
220 #ifdef _HAS_CPP0X
221 # define nssv_HAS_CPP0X _HAS_CPP0X
222 #else
223 # define nssv_HAS_CPP0X 0
224 #endif
225 
226 // Unless defined otherwise below, consider VC14 as C++11 for variant-lite:
227 
228 #if nssv_COMPILER_MSVC_VER >= 1900
229 # undef nssv_CPP11_OR_GREATER
230 # define nssv_CPP11_OR_GREATER 1
231 #endif
232 
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)
239 
240 #define nssv_CPP14_000 (nssv_CPP14_OR_GREATER)
241 #define nssv_CPP17_000 (nssv_CPP17_OR_GREATER)
242 
243 // Presence of C++11 language features:
244 
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
255 
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
258 #endif
259 
260 // Presence of C++14 language features:
261 
262 #define nssv_HAVE_CONSTEXPR_14 nssv_CPP14_000
263 
264 // Presence of C++17 language features:
265 
266 #define nssv_HAVE_NODISCARD nssv_CPP17_000
267 
268 // Presence of C++ library features:
269 
270 #define nssv_HAVE_STD_HASH nssv_CPP11_120
271 
272 // C++ feature usage:
273 
274 #if nssv_HAVE_CONSTEXPR_11
275 # define nssv_constexpr constexpr
276 #else
277 # define nssv_constexpr /*constexpr*/
278 #endif
279 
280 #if nssv_HAVE_CONSTEXPR_14
281 # define nssv_constexpr14 constexpr
282 #else
283 # define nssv_constexpr14 /*constexpr*/
284 #endif
285 
286 #if nssv_HAVE_EXPLICIT_CONVERSION
287 # define nssv_explicit explicit
288 #else
289 # define nssv_explicit /*explicit*/
290 #endif
291 
292 #if nssv_HAVE_INLINE_NAMESPACE
293 # define nssv_inline_ns inline
294 #else
295 # define nssv_inline_ns /*inline*/
296 #endif
297 
298 #if nssv_HAVE_NOEXCEPT
299 # define nssv_noexcept noexcept
300 #else
301 # define nssv_noexcept /*noexcept*/
302 #endif
303 
304 //#if nssv_HAVE_REF_QUALIFIER
305 //# define nssv_ref_qual &
306 //# define nssv_refref_qual &&
307 //#else
308 //# define nssv_ref_qual /*&*/
309 //# define nssv_refref_qual /*&&*/
310 //#endif
311 
312 #if nssv_HAVE_NULLPTR
313 # define nssv_nullptr nullptr
314 #else
315 # define nssv_nullptr NULL
316 #endif
317 
318 #if nssv_HAVE_NODISCARD
319 # define nssv_nodiscard [[nodiscard]]
320 #else
321 # define nssv_nodiscard /*[[nodiscard]]*/
322 #endif
323 
324 // Additional includes:
325 
326 #include <algorithm>
327 #include <cassert>
328 #include <iterator>
329 #include <limits>
330 #include <ostream>
331 #include <stdexcept>
332 #include <string> // std::char_traits<>
333 
334 #if nssv_CPP11_OR_GREATER
335 # include <type_traits>
336 #endif
337 
338 // Clang, GNUC, MSVC warning suppression macros:
339 
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"
347 #endif // __clang__
348 
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))
353 #else
354 # define nssv_SUPPRESS_MSGSL_WARNING(expr)
355 # define nssv_SUPPRESS_MSVC_WARNING(code, descr)
356 # define nssv_DISABLE_MSVC_WARNINGS(codes)
357 #endif
358 
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 ))
365 #else
366 # define nssv_RESTORE_WARNINGS()
367 #endif
368 
369 // Suppress the following MSVC (GSL) warnings:
370 // - C4455, non-gsl : 'operator ""sv': literal suffix identifiers that do not
371 // start with an underscore are reserved
372 // - C26472, gsl::t.1 : don't use a static_cast for arithmetic conversions;
373 // use brace initialization, gsl::narrow_cast or gsl::narow
374 // - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead
375 
376 nssv_DISABLE_MSVC_WARNINGS( 4455 26481 26472 )
377 //nssv_DISABLE_CLANG_WARNINGS( "-Wuser-defined-literals" )
378 //nssv_DISABLE_GNUC_WARNINGS( -Wliteral-suffix )
379 
380 namespace nonstd { namespace sv_lite {
381 
382 template
383 <
384  class CharT,
385  class Traits = std::char_traits<CharT>
386 >
387 class basic_string_view;
388 
389 //
390 // basic_string_view:
391 //
392 
393 template
394 <
395  class CharT,
396  class Traits /* = std::char_traits<CharT> */
397 >
398 class basic_string_view
399 {
400 public:
401  // Member types:
402 
403  typedef Traits traits_type;
404  typedef CharT value_type;
405 
406  typedef CharT * pointer;
407  typedef CharT const * const_pointer;
408  typedef CharT & reference;
409  typedef CharT const & const_reference;
410 
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;
415 
416  typedef std::size_t size_type;
417  typedef std::ptrdiff_t difference_type;
418 
419  // 24.4.2.1 Construction and assignment:
420 
422  : data_( nssv_nullptr )
423  , size_( 0 )
424  {}
425 
426 #if nssv_CPP11_OR_GREATER
428 #else
429  nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept
430  : data_( other.data_)
431  , size_( other.size_)
432  {}
433 #endif
434 
435  nssv_constexpr basic_string_view( CharT const * s, size_type count )
436  : data_( s )
437  , size_( count )
438  {}
439 
440  nssv_constexpr basic_string_view( CharT const * s)
441  : data_( s )
442  , size_( Traits::length(s) )
443  {}
444 
445  // Assignment:
446 
447 #if nssv_CPP11_OR_GREATER
448  nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept = default;
449 #else
450  nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept
451  {
452  data_ = other.data_;
453  size_ = other.size_;
454  return *this;
455  }
456 #endif
457 
458  // 24.4.2.2 Iterator support:
459 
460  nssv_constexpr const_iterator begin() const nssv_noexcept { return data_; }
461  nssv_constexpr const_iterator end() const nssv_noexcept { return data_ + size_; }
462 
463  nssv_constexpr const_iterator cbegin() const nssv_noexcept { return begin(); }
464  nssv_constexpr const_iterator cend() const nssv_noexcept { return end(); }
465 
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() ); }
468 
469  nssv_constexpr const_reverse_iterator crbegin() const nssv_noexcept { return rbegin(); }
470  nssv_constexpr const_reverse_iterator crend() const nssv_noexcept { return rend(); }
471 
472  // 24.4.2.3 Capacity:
473 
474  nssv_constexpr size_type size() const nssv_noexcept { return size_; }
475  nssv_constexpr size_type length() const nssv_noexcept { return size_; }
476  nssv_constexpr size_type max_size() const nssv_noexcept { return (std::numeric_limits< size_type >::max)(); }
477 
478  // since C++20
479  nssv_nodiscard nssv_constexpr bool empty() const nssv_noexcept
480  {
481  return 0 == size_;
482  }
483 
484  // 24.4.2.4 Element access:
485 
486  nssv_constexpr const_reference operator[]( size_type pos ) const
487  {
488  return data_at( pos );
489  }
490 
491  nssv_constexpr14 const_reference at( size_type pos ) const
492  {
493  if ( pos < size() )
494  {
495  return data_at( pos );
496  }
497 
498  throw std::out_of_range("nonst::string_view::at()");
499  }
500 
501  nssv_constexpr const_reference front() const { return data_at( 0 ); }
502  nssv_constexpr const_reference back() const { return data_at( size() - 1 ); }
503 
504  nssv_constexpr const_pointer data() const nssv_noexcept { return data_; }
505 
506  // 24.4.2.5 Modifiers:
507 
508  nssv_constexpr14 void remove_prefix( size_type n )
509  {
510  assert( n <= size() );
511  data_ += n;
512  size_ -= n;
513  }
514 
515  nssv_constexpr14 void remove_suffix( size_type n )
516  {
517  assert( n <= size() );
518  size_ -= n;
519  }
520 
521  nssv_constexpr14 void swap( basic_string_view & other ) nssv_noexcept
522  {
523  using std::swap;
524  swap( data_, other.data_ );
525  swap( size_, other.size_ );
526  }
527 
528  // 24.4.2.6 String operations:
529 
530  size_type copy( CharT * dest, size_type n, size_type pos = 0 ) const
531  {
532  if ( pos > size() )
533  throw std::out_of_range("nonst::string_view::copy()");
534 
535  const size_type rlen = (std::min)( n, size() - pos );
536 
537  (void) Traits::copy( dest, data() + pos, rlen );
538 
539  return rlen;
540  }
541 
542  nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos ) const
543  {
544  if ( pos > size() )
545  throw std::out_of_range("nonst::string_view::substr()");
546 
547  return basic_string_view( data() + pos, (std::min)( n, size() - pos ) );
548  }
549 
550  // compare(), 6x:
551 
552  nssv_constexpr14 int compare( basic_string_view other ) const nssv_noexcept // (1)
553  {
554  if ( const int result = Traits::compare( data(), other.data(), (std::min)( size(), other.size() ) ) )
555  return result;
556 
557  return size() == other.size() ? 0 : size() < other.size() ? -1 : 1;
558  }
559 
560  nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other ) const // (2)
561  {
562  return substr( pos1, n1 ).compare( other );
563  }
564 
565  nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other, size_type pos2, size_type n2 ) const // (3)
566  {
567  return substr( pos1, n1 ).compare( other.substr( pos2, n2 ) );
568  }
569 
570  nssv_constexpr int compare( CharT const * s ) const // (4)
571  {
572  return compare( basic_string_view( s ) );
573  }
574 
575  nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s ) const // (5)
576  {
577  return substr( pos1, n1 ).compare( basic_string_view( s ) );
578  }
579 
580  nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s, size_type n2 ) const // (6)
581  {
582  return substr( pos1, n1 ).compare( basic_string_view( s, n2 ) );
583  }
584 
585  // 24.4.2.7 Searching:
586 
587  // starts_with(), 3x, since C++20:
588 
589  nssv_constexpr bool starts_with( basic_string_view v ) const nssv_noexcept // (1)
590  {
591  return size() >= v.size() && compare( 0, v.size(), v ) == 0;
592  }
593 
594  nssv_constexpr bool starts_with( CharT c ) const nssv_noexcept // (2)
595  {
596  return starts_with( basic_string_view( &c, 1 ) );
597  }
598 
599  nssv_constexpr bool starts_with( CharT const * s ) const // (3)
600  {
601  return starts_with( basic_string_view( s ) );
602  }
603 
604  // ends_with(), 3x, since C++20:
605 
606  nssv_constexpr bool ends_with( basic_string_view v ) const nssv_noexcept // (1)
607  {
608  return size() >= v.size() && compare( size() - v.size(), npos, v ) == 0;
609  }
610 
611  nssv_constexpr bool ends_with( CharT c ) const nssv_noexcept // (2)
612  {
613  return ends_with( basic_string_view( &c, 1 ) );
614  }
615 
616  nssv_constexpr bool ends_with( CharT const * s ) const // (3)
617  {
618  return ends_with( basic_string_view( s ) );
619  }
620 
621  // find(), 4x:
622 
623  nssv_constexpr14 size_type find( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
624  {
625  return assert( v.size() == 0 || v.data() != nssv_nullptr )
626  , pos >= size()
627  ? npos
628  : to_pos( std::search( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
629  }
630 
631  nssv_constexpr14 size_type find( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
632  {
633  return find( basic_string_view( &c, 1 ), pos );
634  }
635 
636  nssv_constexpr14 size_type find( CharT const * s, size_type pos, size_type n ) const // (3)
637  {
638  return find( basic_string_view( s, n ), pos );
639  }
640 
641  nssv_constexpr14 size_type find( CharT const * s, size_type pos = 0 ) const // (4)
642  {
643  return find( basic_string_view( s ), pos );
644  }
645 
646  // rfind(), 4x:
647 
648  nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
649  {
650  if ( size() < v.size() )
651  return npos;
652 
653  if ( v.empty() )
654  return (std::min)( size(), pos );
655 
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 );
658 
659  return result != last ? size_type( result - cbegin() ) : npos;
660  }
661 
662  nssv_constexpr14 size_type rfind( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
663  {
664  return rfind( basic_string_view( &c, 1 ), pos );
665  }
666 
667  nssv_constexpr14 size_type rfind( CharT const * s, size_type pos, size_type n ) const // (3)
668  {
669  return rfind( basic_string_view( s, n ), pos );
670  }
671 
672  nssv_constexpr14 size_type rfind( CharT const * s, size_type pos = npos ) const // (4)
673  {
674  return rfind( basic_string_view( s ), pos );
675  }
676 
677  // find_first_of(), 4x:
678 
679  nssv_constexpr size_type find_first_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
680  {
681  return pos >= size()
682  ? npos
683  : to_pos( std::find_first_of( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
684  }
685 
686  nssv_constexpr size_type find_first_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
687  {
688  return find_first_of( basic_string_view( &c, 1 ), pos );
689  }
690 
691  nssv_constexpr size_type find_first_of( CharT const * s, size_type pos, size_type n ) const // (3)
692  {
693  return find_first_of( basic_string_view( s, n ), pos );
694  }
695 
696  nssv_constexpr size_type find_first_of( CharT const * s, size_type pos = 0 ) const // (4)
697  {
698  return find_first_of( basic_string_view( s ), pos );
699  }
700 
701  // find_last_of(), 4x:
702 
703  nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
704  {
705  return empty()
706  ? npos
707  : pos >= size()
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 ) );
710  }
711 
712  nssv_constexpr size_type find_last_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
713  {
714  return find_last_of( basic_string_view( &c, 1 ), pos );
715  }
716 
717  nssv_constexpr size_type find_last_of( CharT const * s, size_type pos, size_type count ) const // (3)
718  {
719  return find_last_of( basic_string_view( s, count ), pos );
720  }
721 
722  nssv_constexpr size_type find_last_of( CharT const * s, size_type pos = npos ) const // (4)
723  {
724  return find_last_of( basic_string_view( s ), pos );
725  }
726 
727  // find_first_not_of(), 4x:
728 
729  nssv_constexpr size_type find_first_not_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
730  {
731  return pos >= size()
732  ? npos
733  : to_pos( std::find_if( cbegin() + pos, cend(), not_in_view( v ) ) );
734  }
735 
736  nssv_constexpr size_type find_first_not_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
737  {
738  return find_first_not_of( basic_string_view( &c, 1 ), pos );
739  }
740 
741  nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos, size_type count ) const // (3)
742  {
743  return find_first_not_of( basic_string_view( s, count ), pos );
744  }
745 
746  nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos = 0 ) const // (4)
747  {
748  return find_first_not_of( basic_string_view( s ), pos );
749  }
750 
751  // find_last_not_of(), 4x:
752 
753  nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
754  {
755  return empty()
756  ? npos
757  : pos >= size()
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 ) ) );
760  }
761 
762  nssv_constexpr size_type find_last_not_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
763  {
764  return find_last_not_of( basic_string_view( &c, 1 ), pos );
765  }
766 
767  nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos, size_type count ) const // (3)
768  {
769  return find_last_not_of( basic_string_view( s, count ), pos );
770  }
771 
772  nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos = npos ) const // (4)
773  {
774  return find_last_not_of( basic_string_view( s ), pos );
775  }
776 
777  // Constants:
778 
779 #if nssv_CPP17_OR_GREATER
780  static nssv_constexpr size_type npos = size_type(-1);
781 #elif nssv_CPP11_OR_GREATER
782  enum : size_type { npos = size_type(-1) };
783 #else
784  enum { npos = size_type(-1) };
785 #endif
786 
787 private:
788  struct not_in_view
789  {
790  const basic_string_view v;
791 
792  nssv_constexpr not_in_view( basic_string_view v ) : v( v ) {}
793 
794  nssv_constexpr bool operator()( CharT c ) const
795  {
796  return npos == v.find_first_of( c );
797  }
798  };
799 
800  nssv_constexpr size_type to_pos( const_iterator it ) const
801  {
802  return it == cend() ? npos : size_type( it - cbegin() );
803  }
804 
805  nssv_constexpr size_type to_pos( const_reverse_iterator it ) const
806  {
807  return it == crend() ? npos : size_type( crend() - it - 1 );
808  }
809 
810  nssv_constexpr const_reference data_at( size_type pos ) const
811  {
812 #if nssv_BETWEEN( nssv_COMPILER_GNUC_VERSION, 1, 500 )
813  return data_[pos];
814 #else
815  return assert( pos < size() ), data_[pos];
816 #endif
817  }
818 
819 private:
820  const_pointer data_;
821  size_type size_;
822 
823 public:
824 #if nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
825 
826  template< class Allocator >
827  basic_string_view( std::basic_string<CharT, Traits, Allocator> const & s ) nssv_noexcept
828  : data_( s.data() )
829  , size_( s.size() )
830  {}
831 
832 #if nssv_HAVE_EXPLICIT_CONVERSION
833 
834  template< class Allocator >
835  explicit operator std::basic_string<CharT, Traits, Allocator>() const
836  {
837  return to_string( Allocator() );
838  }
839 
840 #endif // nssv_HAVE_EXPLICIT_CONVERSION
841 
842 #if nssv_CPP11_OR_GREATER
843 
844  template< class Allocator = std::allocator<CharT> >
845  std::basic_string<CharT, Traits, Allocator>
846  to_string( Allocator const & a = Allocator() ) const
847  {
848  return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
849  }
850 
851 #else
852 
853  std::basic_string<CharT, Traits>
854  to_string() const
855  {
856  return std::basic_string<CharT, Traits>( begin(), end() );
857  }
858 
859  template< class Allocator >
860  std::basic_string<CharT, Traits, Allocator>
861  to_string( Allocator const & a ) const
862  {
863  return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
864  }
865 
866 #endif // nssv_CPP11_OR_GREATER
867 
868 #endif // nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
869 };
870 
871 //
872 // Non-member functions:
873 //
874 
875 // 24.4.3 Non-member comparison functions:
876 // lexicographically compare two string views (function template):
877 
878 template< class CharT, class Traits >
882 { return lhs.compare( rhs ) == 0 ; }
883 
884 template< class CharT, class Traits >
888 { return lhs.compare( rhs ) != 0 ; }
889 
890 template< class CharT, class Traits >
894 { return lhs.compare( rhs ) < 0 ; }
895 
896 template< class CharT, class Traits >
900 { return lhs.compare( rhs ) <= 0 ; }
901 
902 template< class CharT, class Traits >
906 { return lhs.compare( rhs ) > 0 ; }
907 
908 template< class CharT, class Traits >
912 { return lhs.compare( rhs ) >= 0 ; }
913 
914 // Let S be basic_string_view<CharT, Traits>, and sv be an instance of S.
915 // Implementations shall provide sufficient additional overloads marked
916 // constexpr and noexcept so that an object t with an implicit conversion
917 // to S can be compared according to Table 67.
918 
919 #if nssv_CPP11_OR_GREATER && ! nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 100, 141 )
920 
921 #define nssv_BASIC_STRING_VIEW_I(T,U) typename std::decay< basic_string_view<T,U> >::type
922 
923 #if nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 140, 150 )
924 # define nssv_MSVC_ORDER(x) , int=x
925 #else
926 # define nssv_MSVC_ORDER(x) /*, int=x*/
927 #endif
928 
929 // ==
930 
931 template< class CharT, class Traits nssv_MSVC_ORDER(1) >
934  nssv_BASIC_STRING_VIEW_I(CharT, Traits) rhs ) nssv_noexcept
935 { return lhs.compare( rhs ) == 0; }
936 
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; }
942 
943 // !=
944 
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 ; }
950 
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 ; }
956 
957 // <
958 
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 ; }
964 
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 ; }
970 
971 // <=
972 
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 ; }
978 
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 ; }
984 
985 // >
986 
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 ; }
992 
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 ; }
998 
999 // >=
1000 
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 ; }
1006 
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 ; }
1012 
1013 #undef nssv_MSVC_ORDER
1014 #undef nssv_BASIC_STRING_VIEW_I
1015 
1016 #endif // nssv_CPP11_OR_GREATER
1017 
1018 // 24.4.4 Inserters and extractors:
1019 
1020 namespace detail {
1021 
1022 template< class Stream >
1023 void write_padding( Stream & os, std::streamsize n )
1024 {
1025  for ( std::streamsize i = 0; i < n; ++i )
1026  os.rdbuf()->sputc( os.fill() );
1027 }
1028 
1029 template< class Stream, class View >
1030 Stream & write_to_stream( Stream & os, View const & sv )
1031 {
1032  typename Stream::sentry sentry( os );
1033 
1034  if ( !os )
1035  return os;
1036 
1037  const std::streamsize length = static_cast<std::streamsize>( sv.length() );
1038 
1039  // Whether, and how, to pad:
1040  const bool pad = ( length < os.width() );
1041  const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) == std::ios_base::right;
1042 
1043  if ( left_pad )
1044  write_padding( os, os.width() - length );
1045 
1046  // Write span characters:
1047  os.rdbuf()->sputn( sv.begin(), length );
1048 
1049  if ( pad && !left_pad )
1050  write_padding( os, os.width() - length );
1051 
1052  // Reset output stream width:
1053  os.width( 0 );
1054 
1055  return os;
1056 }
1057 
1058 } // namespace detail
1059 
1060 template< class CharT, class Traits >
1061 std::basic_ostream<CharT, Traits> &
1062 operator<<(
1063  std::basic_ostream<CharT, Traits>& os,
1065 {
1066  return detail::write_to_stream( os, sv );
1067 }
1068 
1069 // Several typedefs for common character types are provided:
1070 
1073 #if nssv_HAVE_WCHAR16_T
1076 #endif
1077 
1078 }} // namespace nonstd::sv_lite
1079 
1080 //
1081 // 24.4.6 Suffix for basic_string_view literals:
1082 //
1083 
1084 #if nssv_HAVE_USER_DEFINED_LITERALS
1085 
1086 namespace nonstd {
1087 nssv_inline_ns namespace literals {
1088 nssv_inline_ns namespace string_view_literals {
1089 
1090 #if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS
1091 
1092 nssv_constexpr nonstd::sv_lite::string_view operator "" sv( const char* str, size_t len ) nssv_noexcept // (1)
1093 {
1094  return nonstd::sv_lite::string_view{ str, len };
1095 }
1096 
1097 nssv_constexpr nonstd::sv_lite::u16string_view operator "" sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
1098 {
1099  return nonstd::sv_lite::u16string_view{ str, len };
1100 }
1101 
1102 nssv_constexpr nonstd::sv_lite::u32string_view operator "" sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
1103 {
1104  return nonstd::sv_lite::u32string_view{ str, len };
1105 }
1106 
1107 nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
1108 {
1109  return nonstd::sv_lite::wstring_view{ str, len };
1110 }
1111 
1112 #endif // nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS
1113 
1114 #if nssv_CONFIG_USR_SV_OPERATOR
1115 
1116 nssv_constexpr nonstd::sv_lite::string_view operator "" _sv( const char* str, size_t len ) nssv_noexcept // (1)
1117 {
1118  return nonstd::sv_lite::string_view{ str, len };
1119 }
1120 
1121 nssv_constexpr nonstd::sv_lite::u16string_view operator "" _sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
1122 {
1123  return nonstd::sv_lite::u16string_view{ str, len };
1124 }
1125 
1126 nssv_constexpr nonstd::sv_lite::u32string_view operator "" _sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
1127 {
1128  return nonstd::sv_lite::u32string_view{ str, len };
1129 }
1130 
1131 nssv_constexpr nonstd::sv_lite::wstring_view operator "" _sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
1132 {
1133  return nonstd::sv_lite::wstring_view{ str, len };
1134 }
1135 
1136 #endif // nssv_CONFIG_USR_SV_OPERATOR
1137 
1138 }}} // namespace nonstd::literals::string_view_literals
1139 
1140 #endif
1141 
1142 //
1143 // Extensions for std::string:
1144 //
1145 
1146 #if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
1147 
1148 namespace nonstd {
1149 namespace sv_lite {
1150 
1151 // Exclude MSVC 14 (19.00): it yields ambiguous to_string():
1152 
1153 #if nssv_CPP11_OR_GREATER && nssv_COMPILER_MSVC_VERSION != 140
1154 
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() )
1158 {
1159  return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
1160 }
1161 
1162 #else
1163 
1164 template< class CharT, class Traits >
1165 std::basic_string<CharT, Traits>
1166 to_string( basic_string_view<CharT, Traits> v )
1167 {
1168  return std::basic_string<CharT, Traits>( v.begin(), v.end() );
1169 }
1170 
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 )
1174 {
1175  return std::basic_string<CharT, Traits, Allocator>( v.begin(), v.end(), a );
1176 }
1177 
1178 #endif // nssv_CPP11_OR_GREATER
1179 
1180 template< class CharT, class Traits, class Allocator >
1181 basic_string_view<CharT, Traits>
1182 to_string_view( std::basic_string<CharT, Traits, Allocator> const & s )
1183 {
1184  return basic_string_view<CharT, Traits>( s.data(), s.size() );
1185 }
1186 
1187 }} // namespace nonstd::sv_lite
1188 
1189 #endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
1190 
1191 //
1192 // make types and algorithms available in namespace nonstd:
1193 //
1194 
1195 namespace nonstd {
1196 
1198 using sv_lite::string_view;
1199 using sv_lite::wstring_view;
1200 
1201 #if nssv_HAVE_WCHAR16_T
1203 #endif
1204 #if nssv_HAVE_WCHAR32_T
1206 #endif
1207 
1208 // literal "sv"
1209 
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>=;
1216 
1217 using sv_lite::operator<<;
1218 
1219 #if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
1220 using sv_lite::to_string;
1222 #endif
1223 
1224 } // namespace nonstd
1225 
1226 // 24.4.5 Hash support (C++11):
1227 
1228 // Note: The hash value of a string view object is equal to the hash value of
1229 // the corresponding string object.
1230 
1231 #if nssv_HAVE_STD_HASH
1232 
1233 #include <functional>
1234 
1235 namespace std {
1236 
1237 template<>
1238 struct hash< nonstd::string_view >
1239 {
1240 public:
1241  std::size_t operator()( nonstd::string_view v ) const nssv_noexcept
1242  {
1243  return std::hash<std::string>()( std::string( v.data(), v.size() ) );
1244  }
1245 };
1246 
1247 template<>
1248 struct hash< nonstd::wstring_view >
1249 {
1250 public:
1251  std::size_t operator()( nonstd::wstring_view v ) const nssv_noexcept
1252  {
1253  return std::hash<std::wstring>()( std::wstring( v.data(), v.size() ) );
1254  }
1255 };
1256 
1257 template<>
1258 struct hash< nonstd::u16string_view >
1259 {
1260 public:
1261  std::size_t operator()( nonstd::u16string_view v ) const nssv_noexcept
1262  {
1263  return std::hash<std::u16string>()( std::u16string( v.data(), v.size() ) );
1264  }
1265 };
1266 
1267 template<>
1268 struct hash< nonstd::u32string_view >
1269 {
1270 public:
1271  std::size_t operator()( nonstd::u32string_view v ) const nssv_noexcept
1272  {
1273  return std::hash<std::u32string>()( std::u32string( v.data(), v.size() ) );
1274  }
1275 };
1276 
1277 } // namespace std
1278 
1279 #endif // nssv_HAVE_STD_HASH
1280 
1282 
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
Definition: sol.hpp:5339
constexpr const Char * data() const
Definition: core.h:388
static unsigned char pad[64]
Definition: SHA1.c:66
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
relop
Definition: sol.hpp:5324
bool operator==(fp x, fp y)
Definition: format-inl.h:1167
constexpr bool operator>=(const optional< T > &lhs, const optional< U > &rhs)
relop
Definition: sol.hpp:5344
lu_byte right
Definition: lparser.c:1229
constexpr bool operator>(const optional< T > &lhs, const optional< U > &rhs)
relop
Definition: sol.hpp:5334
#define nssv_nullptr
size_t size_
Definition: core.h:350
Definition: json.hpp:4042
#define nssv_inline_ns
basic_string_view< CharT, Traits > to_string_view(std::basic_string< CharT, Traits, Allocator > const &s)
const Char * data_
Definition: core.h:349
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:4680
#define nssv_noexcept
basic_string_view< char > string_view
Definition: core.h:432
std::u16string_view u16string_view
Definition: sol.hpp:1619
#define min(A, B)
Definition: Log.c:64
#define max(A, B)
Definition: Socket.h:88
Definition: chrono.h:284
QDebug operator<<(QDebug debug, const QwtInterval &interval)
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
Definition: format.h:2881
basic_string_view< wchar_t > wstring_view
Definition: core.h:433
#define nssv_constexpr
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:3471
std::basic_string_view< C, T > basic_string_view
Definition: sol.hpp:1615
#define nssv_RESTORE_WARNINGS()
Definition: any.hpp:144
j template void())
Definition: json.hpp:3707
constexpr size_t size() const
Definition: core.h:391
#define assert(a, b, c, d)
#define nssv_constexpr14
MQTTClient c
Definition: test10.c:1656
std::string to_string(const T &value)
Definition: format.h:3737
#define nssv_DISABLE_MSVC_WARNINGS(codes)
int compare(basic_string_view other) const
Definition: core.h:404
dictionary data
Definition: mqtt_test.py:22
std::basic_string< CharT, Traits > to_string(basic_string_view< CharT, Traits > v)
#define nssv_nodiscard
int len
Definition: utf-8.c:46
std::u32string_view u32string_view
Definition: sol.hpp:1620


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:47