span.hpp
Go to the documentation of this file.
1 //
2 // span for C++98 and later.
3 // Based on http://wg21.link/p0122r7
4 // For more information see https://github.com/martinmoene/span-lite
5 //
6 // Copyright 2018-2021 Martin Moene
7 //
8 // Distributed under the Boost Software License, Version 1.0.
9 // (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 
11 #ifndef NONSTD_SPAN_HPP_INCLUDED
12 #define NONSTD_SPAN_HPP_INCLUDED
13 
14 #define span_lite_MAJOR 0
15 #define span_lite_MINOR 10
16 #define span_lite_PATCH 3
17 
18 #define span_lite_VERSION span_STRINGIFY(span_lite_MAJOR) "." span_STRINGIFY(span_lite_MINOR) "." span_STRINGIFY(span_lite_PATCH)
19 
20 #define span_STRINGIFY( x ) span_STRINGIFY_( x )
21 #define span_STRINGIFY_( x ) #x
22 
23 // span configuration:
24 
25 #define span_SPAN_DEFAULT 0
26 #define span_SPAN_NONSTD 1
27 #define span_SPAN_STD 2
28 
29 // tweak header support:
30 
31 #ifdef __has_include
32 # if __has_include(<nonstd/span.tweak.hpp>)
33 # include <nonstd/span.tweak.hpp>
34 # endif
35 #define span_HAVE_TWEAK_HEADER 1
36 #else
37 #define span_HAVE_TWEAK_HEADER 0
38 //# pragma message("span.hpp: Note: Tweak header not supported.")
39 #endif
40 
41 // span selection and configuration:
42 
43 #define span_HAVE( feature ) ( span_HAVE_##feature )
44 
45 #ifndef span_CONFIG_SELECT_SPAN
46 # define span_CONFIG_SELECT_SPAN ( span_HAVE_STD_SPAN ? span_SPAN_STD : span_SPAN_NONSTD )
47 #endif
48 
49 #ifndef span_CONFIG_EXTENT_TYPE
50 # define span_CONFIG_EXTENT_TYPE std::size_t
51 #endif
52 
53 #ifndef span_CONFIG_SIZE_TYPE
54 # define span_CONFIG_SIZE_TYPE std::size_t
55 #endif
56 
57 #ifdef span_CONFIG_INDEX_TYPE
58 # error `span_CONFIG_INDEX_TYPE` is deprecated since v0.7.0; it is replaced by `span_CONFIG_SIZE_TYPE`.
59 #endif
60 
61 // span configuration (features):
62 
63 #ifndef span_FEATURE_WITH_CONTAINER
64 #ifdef span_FEATURE_WITH_CONTAINER_TO_STD
65 # define span_FEATURE_WITH_CONTAINER span_IN_STD( span_FEATURE_WITH_CONTAINER_TO_STD )
66 #else
67 # define span_FEATURE_WITH_CONTAINER 0
68 # define span_FEATURE_WITH_CONTAINER_TO_STD 0
69 #endif
70 #endif
71 
72 #ifndef span_FEATURE_CONSTRUCTION_FROM_STDARRAY_ELEMENT_TYPE
73 # define span_FEATURE_CONSTRUCTION_FROM_STDARRAY_ELEMENT_TYPE 0
74 #endif
75 
76 #ifndef span_FEATURE_MEMBER_AT
77 # define span_FEATURE_MEMBER_AT 0
78 #endif
79 
80 #ifndef span_FEATURE_MEMBER_BACK_FRONT
81 # define span_FEATURE_MEMBER_BACK_FRONT 1
82 #endif
83 
84 #ifndef span_FEATURE_MEMBER_CALL_OPERATOR
85 # define span_FEATURE_MEMBER_CALL_OPERATOR 0
86 #endif
87 
88 #ifndef span_FEATURE_MEMBER_SWAP
89 # define span_FEATURE_MEMBER_SWAP 0
90 #endif
91 
92 #ifndef span_FEATURE_NON_MEMBER_FIRST_LAST_SUB
93 # define span_FEATURE_NON_MEMBER_FIRST_LAST_SUB 0
94 #elif span_FEATURE_NON_MEMBER_FIRST_LAST_SUB
95 # define span_FEATURE_NON_MEMBER_FIRST_LAST_SUB_SPAN 1
96 # define span_FEATURE_NON_MEMBER_FIRST_LAST_SUB_CONTAINER 1
97 #endif
98 
99 #ifndef span_FEATURE_NON_MEMBER_FIRST_LAST_SUB_SPAN
100 # define span_FEATURE_NON_MEMBER_FIRST_LAST_SUB_SPAN 0
101 #endif
102 
103 #ifndef span_FEATURE_NON_MEMBER_FIRST_LAST_SUB_CONTAINER
104 # define span_FEATURE_NON_MEMBER_FIRST_LAST_SUB_CONTAINER 0
105 #endif
106 
107 #ifndef span_FEATURE_COMPARISON
108 # define span_FEATURE_COMPARISON 0 // Note: C++20 does not provide comparison
109 #endif
110 
111 #ifndef span_FEATURE_SAME
112 # define span_FEATURE_SAME 0
113 #endif
114 
115 #if span_FEATURE_SAME && !span_FEATURE_COMPARISON
116 # error `span_FEATURE_SAME` requires `span_FEATURE_COMPARISON`
117 #endif
118 
119 #ifndef span_FEATURE_MAKE_SPAN
120 #ifdef span_FEATURE_MAKE_SPAN_TO_STD
121 # define span_FEATURE_MAKE_SPAN span_IN_STD( span_FEATURE_MAKE_SPAN_TO_STD )
122 #else
123 # define span_FEATURE_MAKE_SPAN 0
124 # define span_FEATURE_MAKE_SPAN_TO_STD 0
125 #endif
126 #endif
127 
128 #ifndef span_FEATURE_BYTE_SPAN
129 # define span_FEATURE_BYTE_SPAN 0
130 #endif
131 
132 // Control presence of exception handling (try and auto discover):
133 
134 #ifndef span_CONFIG_NO_EXCEPTIONS
135 # if defined(_MSC_VER)
136 # include <cstddef> // for _HAS_EXCEPTIONS
137 # endif
138 # if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS)
139 # define span_CONFIG_NO_EXCEPTIONS 0
140 # else
141 # define span_CONFIG_NO_EXCEPTIONS 1
142 # undef span_CONFIG_CONTRACT_VIOLATION_THROWS
143 # undef span_CONFIG_CONTRACT_VIOLATION_TERMINATES
144 # define span_CONFIG_CONTRACT_VIOLATION_THROWS 0
145 # define span_CONFIG_CONTRACT_VIOLATION_TERMINATES 1
146 # endif
147 #endif
148 
149 // Control pre- and postcondition violation behaviour:
150 
151 #if defined( span_CONFIG_CONTRACT_LEVEL_ON )
152 # define span_CONFIG_CONTRACT_LEVEL_MASK 0x11
153 #elif defined( span_CONFIG_CONTRACT_LEVEL_OFF )
154 # define span_CONFIG_CONTRACT_LEVEL_MASK 0x00
155 #elif defined( span_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY )
156 # define span_CONFIG_CONTRACT_LEVEL_MASK 0x01
157 #elif defined( span_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY )
158 # define span_CONFIG_CONTRACT_LEVEL_MASK 0x10
159 #else
160 # define span_CONFIG_CONTRACT_LEVEL_MASK 0x11
161 #endif
162 
163 #if defined( span_CONFIG_CONTRACT_VIOLATION_THROWS )
164 # define span_CONFIG_CONTRACT_VIOLATION_THROWS_V span_CONFIG_CONTRACT_VIOLATION_THROWS
165 #else
166 # define span_CONFIG_CONTRACT_VIOLATION_THROWS_V 0
167 #endif
168 
169 #if defined( span_CONFIG_CONTRACT_VIOLATION_THROWS ) && span_CONFIG_CONTRACT_VIOLATION_THROWS && \
170  defined( span_CONFIG_CONTRACT_VIOLATION_TERMINATES ) && span_CONFIG_CONTRACT_VIOLATION_TERMINATES
171 # error Please define none or one of span_CONFIG_CONTRACT_VIOLATION_THROWS and span_CONFIG_CONTRACT_VIOLATION_TERMINATES to 1, but not both.
172 #endif
173 
174 // C++ language version detection (C++20 is speculative):
175 // Note: VC14.0/1900 (VS2015) lacks too much from C++14.
176 
177 #ifndef span_CPLUSPLUS
178 # if defined(_MSVC_LANG ) && !defined(__clang__)
179 # define span_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG )
180 # else
181 # define span_CPLUSPLUS __cplusplus
182 # endif
183 #endif
184 
185 #define span_CPP98_OR_GREATER ( span_CPLUSPLUS >= 199711L )
186 #define span_CPP11_OR_GREATER ( span_CPLUSPLUS >= 201103L )
187 #define span_CPP14_OR_GREATER ( span_CPLUSPLUS >= 201402L )
188 #define span_CPP17_OR_GREATER ( span_CPLUSPLUS >= 201703L )
189 #define span_CPP20_OR_GREATER ( span_CPLUSPLUS >= 202000L )
190 
191 // C++ language version (represent 98 as 3):
192 
193 #define span_CPLUSPLUS_V ( span_CPLUSPLUS / 100 - (span_CPLUSPLUS > 200000 ? 2000 : 1994) )
194 
195 #define span_IN_STD( v ) ( ((v) == 98 ? 3 : (v)) >= span_CPLUSPLUS_V )
196 
197 #define span_CONFIG( feature ) ( span_CONFIG_##feature )
198 #define span_FEATURE( feature ) ( span_FEATURE_##feature )
199 #define span_FEATURE_TO_STD( feature ) ( span_IN_STD( span_FEATURE( feature##_TO_STD ) ) )
200 
201 // Use C++20 std::span if available and requested:
202 
203 #if span_CPP20_OR_GREATER && defined(__has_include )
204 # if __has_include( <span> )
205 # define span_HAVE_STD_SPAN 1
206 # else
207 # define span_HAVE_STD_SPAN 0
208 # endif
209 #else
210 # define span_HAVE_STD_SPAN 0
211 #endif
212 
213 #define span_USES_STD_SPAN ( (span_CONFIG_SELECT_SPAN == span_SPAN_STD) || ((span_CONFIG_SELECT_SPAN == span_SPAN_DEFAULT) && span_HAVE_STD_SPAN) )
214 
215 //
216 // Use C++20 std::span:
217 //
218 
219 #if span_USES_STD_SPAN
220 
221 #include <span>
222 
223 namespace nonstd {
224 
225 using std::span;
226 
227 // Note: C++20 does not provide comparison
228 // using std::operator==;
229 // using std::operator!=;
230 // using std::operator<;
231 // using std::operator<=;
232 // using std::operator>;
233 // using std::operator>=;
234 } // namespace nonstd
235 
236 #else // span_USES_STD_SPAN
237 
238 #include <algorithm>
239 
240 // Compiler versions:
241 //
242 // MSVC++ 6.0 _MSC_VER == 1200 span_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0)
243 // MSVC++ 7.0 _MSC_VER == 1300 span_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002)
244 // MSVC++ 7.1 _MSC_VER == 1310 span_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003)
245 // MSVC++ 8.0 _MSC_VER == 1400 span_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005)
246 // MSVC++ 9.0 _MSC_VER == 1500 span_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008)
247 // MSVC++ 10.0 _MSC_VER == 1600 span_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010)
248 // MSVC++ 11.0 _MSC_VER == 1700 span_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012)
249 // MSVC++ 12.0 _MSC_VER == 1800 span_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013)
250 // MSVC++ 14.0 _MSC_VER == 1900 span_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015)
251 // MSVC++ 14.1 _MSC_VER >= 1910 span_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017)
252 // MSVC++ 14.2 _MSC_VER >= 1920 span_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019)
253 
254 #if defined(_MSC_VER ) && !defined(__clang__)
255 # define span_COMPILER_MSVC_VER (_MSC_VER )
256 # define span_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) )
257 #else
258 # define span_COMPILER_MSVC_VER 0
259 # define span_COMPILER_MSVC_VERSION 0
260 #endif
261 
262 #define span_COMPILER_VERSION( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) )
263 
264 #if defined(__clang__)
265 # define span_COMPILER_CLANG_VERSION span_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
266 #else
267 # define span_COMPILER_CLANG_VERSION 0
268 #endif
269 
270 #if defined(__GNUC__) && !defined(__clang__)
271 # define span_COMPILER_GNUC_VERSION span_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
272 #else
273 # define span_COMPILER_GNUC_VERSION 0
274 #endif
275 
276 // half-open range [lo..hi):
277 #define span_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) )
278 
279 // Compiler warning suppression:
280 
281 #if defined(__clang__)
282 # pragma clang diagnostic push
283 # pragma clang diagnostic ignored "-Wundef"
284 # pragma clang diagnostic ignored "-Wmismatched-tags"
285 # define span_RESTORE_WARNINGS() _Pragma( "clang diagnostic pop" )
286 
287 #elif defined __GNUC__
288 # pragma GCC diagnostic push
289 # pragma GCC diagnostic ignored "-Wundef"
290 # define span_RESTORE_WARNINGS() _Pragma( "GCC diagnostic pop" )
291 
292 #elif span_COMPILER_MSVC_VER >= 1900
293 # define span_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes))
294 # define span_RESTORE_WARNINGS() __pragma(warning(pop ))
295 
296 // Suppress the following MSVC GSL warnings:
297 // - C26439, gsl::f.6 : special function 'function' can be declared 'noexcept'
298 // - C26440, gsl::f.6 : function 'function' can be declared 'noexcept'
299 // - C26472, gsl::t.1 : don't use a static_cast for arithmetic conversions;
300 // use brace initialization, gsl::narrow_cast or gsl::narrow
301 // - C26473: gsl::t.1 : don't cast between pointer types where the source type and the target type are the same
302 // - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead
303 // - C26490: gsl::t.1 : don't use reinterpret_cast
304 
305 span_DISABLE_MSVC_WARNINGS( 26439 26440 26472 26473 26481 26490 )
306 
307 #else
308 # define span_RESTORE_WARNINGS() /*empty*/
309 #endif
310 
311 // Presence of language and library features:
312 
313 #ifdef _HAS_CPP0X
314 # define span_HAS_CPP0X _HAS_CPP0X
315 #else
316 # define span_HAS_CPP0X 0
317 #endif
318 
319 #define span_CPP11_80 (span_CPP11_OR_GREATER || span_COMPILER_MSVC_VER >= 1400)
320 #define span_CPP11_90 (span_CPP11_OR_GREATER || span_COMPILER_MSVC_VER >= 1500)
321 #define span_CPP11_100 (span_CPP11_OR_GREATER || span_COMPILER_MSVC_VER >= 1600)
322 #define span_CPP11_110 (span_CPP11_OR_GREATER || span_COMPILER_MSVC_VER >= 1700)
323 #define span_CPP11_120 (span_CPP11_OR_GREATER || span_COMPILER_MSVC_VER >= 1800)
324 #define span_CPP11_140 (span_CPP11_OR_GREATER || span_COMPILER_MSVC_VER >= 1900)
325 
326 #define span_CPP14_000 (span_CPP14_OR_GREATER)
327 #define span_CPP14_120 (span_CPP14_OR_GREATER || span_COMPILER_MSVC_VER >= 1800)
328 #define span_CPP14_140 (span_CPP14_OR_GREATER || span_COMPILER_MSVC_VER >= 1900)
329 
330 #define span_CPP17_000 (span_CPP17_OR_GREATER)
331 
332 // Presence of C++11 language features:
333 
334 #define span_HAVE_ALIAS_TEMPLATE span_CPP11_140
335 #define span_HAVE_AUTO span_CPP11_100
336 #define span_HAVE_CONSTEXPR_11 span_CPP11_140
337 #define span_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG span_CPP11_120
338 #define span_HAVE_EXPLICIT_CONVERSION span_CPP11_140
339 #define span_HAVE_INITIALIZER_LIST span_CPP11_120
340 #define span_HAVE_IS_DEFAULT span_CPP11_140
341 #define span_HAVE_IS_DELETE span_CPP11_140
342 #define span_HAVE_NOEXCEPT span_CPP11_140
343 #define span_HAVE_NULLPTR span_CPP11_100
344 #define span_HAVE_STATIC_ASSERT span_CPP11_100
345 
346 // Presence of C++14 language features:
347 
348 #define span_HAVE_CONSTEXPR_14 span_CPP14_000
349 
350 // Presence of C++17 language features:
351 
352 #define span_HAVE_DEPRECATED span_CPP17_000
353 #define span_HAVE_NODISCARD span_CPP17_000
354 #define span_HAVE_NORETURN span_CPP17_000
355 
356 // MSVC: template parameter deduction guides since Visual Studio 2017 v15.7
357 
358 #if defined(__cpp_deduction_guides)
359 # define span_HAVE_DEDUCTION_GUIDES 1
360 #else
361 # define span_HAVE_DEDUCTION_GUIDES (span_CPP17_OR_GREATER && ! span_BETWEEN( span_COMPILER_MSVC_VER, 1, 1913 ))
362 #endif
363 
364 // Presence of C++ library features:
365 
366 #define span_HAVE_ADDRESSOF span_CPP17_000
367 #define span_HAVE_ARRAY span_CPP11_110
368 #define span_HAVE_BYTE span_CPP17_000
369 #define span_HAVE_CONDITIONAL span_CPP11_120
370 #define span_HAVE_CONTAINER_DATA_METHOD (span_CPP11_140 || ( span_COMPILER_MSVC_VER >= 1500 && span_HAS_CPP0X ))
371 #define span_HAVE_DATA span_CPP17_000
372 #define span_HAVE_LONGLONG span_CPP11_80
373 #define span_HAVE_REMOVE_CONST span_CPP11_110
374 #define span_HAVE_SNPRINTF span_CPP11_140
375 #define span_HAVE_STRUCT_BINDING span_CPP11_120
376 #define span_HAVE_TYPE_TRAITS span_CPP11_90
377 
378 // Presence of byte-lite:
379 
380 #ifdef NONSTD_BYTE_LITE_HPP
381 # define span_HAVE_NONSTD_BYTE 1
382 #else
383 # define span_HAVE_NONSTD_BYTE 0
384 #endif
385 
386 // C++ feature usage:
387 
388 #if span_HAVE_ADDRESSOF
389 # define span_ADDRESSOF(x) std::addressof(x)
390 #else
391 # define span_ADDRESSOF(x) (&x)
392 #endif
393 
394 #if span_HAVE_CONSTEXPR_11
395 # define span_constexpr constexpr
396 #else
397 # define span_constexpr /*span_constexpr*/
398 #endif
399 
400 #if span_HAVE_CONSTEXPR_14
401 # define span_constexpr14 constexpr
402 #else
403 # define span_constexpr14 /*span_constexpr*/
404 #endif
405 
406 #if span_HAVE_EXPLICIT_CONVERSION
407 # define span_explicit explicit
408 #else
409 # define span_explicit /*explicit*/
410 #endif
411 
412 #if span_HAVE_IS_DELETE
413 # define span_is_delete = delete
414 #else
415 # define span_is_delete
416 #endif
417 
418 #if span_HAVE_IS_DELETE
419 # define span_is_delete_access public
420 #else
421 # define span_is_delete_access private
422 #endif
423 
424 #if span_HAVE_NOEXCEPT && ! span_CONFIG_CONTRACT_VIOLATION_THROWS_V
425 # define span_noexcept noexcept
426 #else
427 # define span_noexcept /*noexcept*/
428 #endif
429 
430 #if span_HAVE_NULLPTR
431 # define span_nullptr nullptr
432 #else
433 # define span_nullptr NULL
434 #endif
435 
436 #if span_HAVE_DEPRECATED
437 # define span_deprecated(msg) [[deprecated(msg)]]
438 #else
439 # define span_deprecated(msg) /*[[deprecated]]*/
440 #endif
441 
442 #if span_HAVE_NODISCARD
443 # define span_nodiscard [[nodiscard]]
444 #else
445 # define span_nodiscard /*[[nodiscard]]*/
446 #endif
447 
448 #if span_HAVE_NORETURN
449 # define span_noreturn [[noreturn]]
450 #else
451 # define span_noreturn /*[[noreturn]]*/
452 #endif
453 
454 // Other features:
455 
456 #define span_HAVE_CONSTRAINED_SPAN_CONTAINER_CTOR span_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG
457 #define span_HAVE_ITERATOR_CTOR span_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG
458 
459 // Additional includes:
460 
461 #if span_HAVE( ADDRESSOF )
462 # include <memory>
463 #endif
464 
465 #if span_HAVE( ARRAY )
466 # include <array>
467 #endif
468 
469 #if span_HAVE( BYTE )
470 # include <cstddef>
471 #endif
472 
473 #if span_HAVE( DATA )
474 # include <iterator> // for std::data(), std::size()
475 #endif
476 
477 #if span_HAVE( TYPE_TRAITS )
478 # include <type_traits>
479 #endif
480 
481 #if ! span_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR )
482 # include <vector>
483 #endif
484 
485 #if span_FEATURE( MEMBER_AT ) > 1
486 # include <cstdio>
487 #endif
488 
489 #if ! span_CONFIG( NO_EXCEPTIONS )
490 # include <stdexcept>
491 #endif
492 
493 // Contract violation
494 
495 #define span_ELIDE_CONTRACT_EXPECTS ( 0 == ( span_CONFIG_CONTRACT_LEVEL_MASK & 0x01 ) )
496 #define span_ELIDE_CONTRACT_ENSURES ( 0 == ( span_CONFIG_CONTRACT_LEVEL_MASK & 0x10 ) )
497 
498 #if span_ELIDE_CONTRACT_EXPECTS
499 # define span_constexpr_exp span_constexpr
500 # define span_EXPECTS( cond ) /* Expect elided */
501 #else
502 # define span_constexpr_exp span_constexpr14
503 # define span_EXPECTS( cond ) span_CONTRACT_CHECK( "Precondition", cond )
504 #endif
505 
506 #if span_ELIDE_CONTRACT_ENSURES
507 # define span_constexpr_ens span_constexpr
508 # define span_ENSURES( cond ) /* Ensures elided */
509 #else
510 # define span_constexpr_ens span_constexpr14
511 # define span_ENSURES( cond ) span_CONTRACT_CHECK( "Postcondition", cond )
512 #endif
513 
514 #define span_CONTRACT_CHECK( type, cond ) \
515  cond ? static_cast< void >( 0 ) \
516  : nonstd::span_lite::detail::report_contract_violation( span_LOCATION( __FILE__, __LINE__ ) ": " type " violation." )
517 
518 #ifdef __GNUG__
519 # define span_LOCATION( file, line ) file ":" span_STRINGIFY( line )
520 #else
521 # define span_LOCATION( file, line ) file "(" span_STRINGIFY( line ) ")"
522 #endif
523 
524 // Method enabling
525 
526 #if span_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG )
527 
528 #define span_REQUIRES_0(VA) \
529  template< bool B = (VA), typename std::enable_if<B, int>::type = 0 >
530 
531 # if span_BETWEEN( span_COMPILER_MSVC_VERSION, 1, 140 )
532 // VS 2013 and earlier seem to have trouble with SFINAE for default non-type arguments
533 # define span_REQUIRES_T(VA) \
534  , typename = typename std::enable_if< ( VA ), nonstd::span_lite::detail::enabler >::type
535 # else
536 # define span_REQUIRES_T(VA) \
537  , typename std::enable_if< (VA), int >::type = 0
538 # endif
539 
540 #define span_REQUIRES_R(R, VA) \
541  typename std::enable_if< (VA), R>::type
542 
543 #define span_REQUIRES_A(VA) \
544  , typename std::enable_if< (VA), void*>::type = nullptr
545 
546 #else
547 
548 # define span_REQUIRES_0(VA) /*empty*/
549 # define span_REQUIRES_T(VA) /*empty*/
550 # define span_REQUIRES_R(R, VA) R
551 # define span_REQUIRES_A(VA) /*empty*/
552 
553 #endif
554 
555 namespace nonstd {
556 namespace span_lite {
557 
558 // [views.constants], constants
559 
562 
563 span_constexpr const extent_t dynamic_extent = static_cast<extent_t>( -1 );
564 
565 template< class T, extent_t Extent = dynamic_extent >
566 class span;
567 
568 // Tag to select span constructor taking a container (prevent ms-gsl warning C26426):
569 
572 
573 // C++11 emulation:
574 
575 namespace std11 {
576 
577 #if span_HAVE( REMOVE_CONST )
578 
579 using std::remove_cv;
580 using std::remove_const;
581 using std::remove_volatile;
582 
583 #else
584 
585 template< class T > struct remove_const { typedef T type; };
586 template< class T > struct remove_const< T const > { typedef T type; };
587 
588 template< class T > struct remove_volatile { typedef T type; };
589 template< class T > struct remove_volatile< T volatile > { typedef T type; };
590 
591 template< class T >
592 struct remove_cv
593 {
595 };
596 
597 #endif // span_HAVE( REMOVE_CONST )
598 
599 #if span_HAVE( TYPE_TRAITS )
600 
601 using std::is_same;
602 using std::is_signed;
603 using std::integral_constant;
604 using std::true_type;
605 using std::false_type;
606 using std::remove_reference;
607 
608 #else
609 
610 template< class T, T v > struct integral_constant { enum { value = v }; };
613 
614 template< class T, class U > struct is_same : false_type{};
615 template< class T > struct is_same<T, T> : true_type{};
616 
617 template< typename T > struct is_signed : false_type {};
618 template<> struct is_signed<signed char> : true_type {};
619 template<> struct is_signed<signed int > : true_type {};
620 template<> struct is_signed<signed long> : true_type {};
621 
622 #endif
623 
624 } // namespace std11
625 
626 // C++17 emulation:
627 
628 namespace std17 {
629 
630 template< bool v > struct bool_constant : std11::integral_constant<bool, v>{};
631 
632 #if span_CPP11_120
633 
634 template< class...>
635 using void_t = void;
636 
637 #endif
638 
639 #if span_HAVE( DATA )
640 
641 using std::data;
642 using std::size;
643 
644 #elif span_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR )
645 
646 template< typename T, std::size_t N >
647 inline span_constexpr auto size( const T(&)[N] ) span_noexcept -> size_t
648 {
649  return N;
650 }
651 
652 template< typename C >
653 inline span_constexpr auto size( C const & cont ) -> decltype( cont.size() )
654 {
655  return cont.size();
656 }
657 
658 template< typename T, std::size_t N >
659 inline span_constexpr auto data( T(&arr)[N] ) span_noexcept -> T*
660 {
661  return &arr[0];
662 }
663 
664 template< typename C >
665 inline span_constexpr auto data( C & cont ) -> decltype( cont.data() )
666 {
667  return cont.data();
668 }
669 
670 template< typename C >
671 inline span_constexpr auto data( C const & cont ) -> decltype( cont.data() )
672 {
673  return cont.data();
674 }
675 
676 template< typename E >
677 inline span_constexpr auto data( std::initializer_list<E> il ) span_noexcept -> E const *
678 {
679  return il.begin();
680 }
681 
682 #endif // span_HAVE( DATA )
683 
684 #if span_HAVE( BYTE )
685 using std::byte;
686 #elif span_HAVE( NONSTD_BYTE )
687 using nonstd::byte;
688 #endif
689 
690 } // namespace std17
691 
692 // C++20 emulation:
693 
694 namespace std20 {
695 
696 #if span_HAVE( DEDUCTION_GUIDES )
697 template< class T >
698 using iter_reference_t = decltype( *std::declval<T&>() );
699 #endif
700 
701 } // namespace std20
702 
703 // Implementation details:
704 
705 namespace detail {
706 
707 /*enum*/ struct enabler{};
708 
709 template< typename T >
711 {
712  return std11::is_signed<T>::value ? x >= 0 : true;
713 }
714 
715 #if span_HAVE( TYPE_TRAITS )
716 
717 template< class Q >
718 struct is_span_oracle : std::false_type{};
719 
720 template< class T, span_CONFIG_EXTENT_TYPE Extent >
721 struct is_span_oracle< span<T, Extent> > : std::true_type{};
722 
723 template< class Q >
724 struct is_span : is_span_oracle< typename std::remove_cv<Q>::type >{};
725 
726 template< class Q >
727 struct is_std_array_oracle : std::false_type{};
728 
729 #if span_HAVE( ARRAY )
730 
731 template< class T, std::size_t Extent >
732 struct is_std_array_oracle< std::array<T, Extent> > : std::true_type{};
733 
734 #endif
735 
736 template< class Q >
737 struct is_std_array : is_std_array_oracle< typename std::remove_cv<Q>::type >{};
738 
739 template< class Q >
740 struct is_array : std::false_type {};
741 
742 template< class T >
743 struct is_array<T[]> : std::true_type {};
744 
745 template< class T, std::size_t N >
746 struct is_array<T[N]> : std::true_type {};
747 
748 #if span_CPP11_140 && ! span_BETWEEN( span_COMPILER_GNUC_VERSION, 1, 500 )
749 
750 template< class, class = void >
751 struct has_size_and_data : std::false_type{};
752 
753 template< class C >
754 struct has_size_and_data
755 <
756  C, std17::void_t<
757  decltype( std17::size(std::declval<C>()) ),
758  decltype( std17::data(std::declval<C>()) ) >
759 > : std::true_type{};
760 
761 template< class, class, class = void >
762 struct is_compatible_element : std::false_type {};
763 
764 template< class C, class E >
765 struct is_compatible_element
766 <
767  C, E, std17::void_t<
768  decltype( std17::data(std::declval<C>()) ) >
769 > : std::is_convertible< typename std::remove_pointer<decltype( std17::data( std::declval<C&>() ) )>::type(*)[], E(*)[] >{};
770 
771 template< class C >
772 struct is_container : std17::bool_constant
773 <
774  ! is_span< C >::value
775  && ! is_array< C >::value
776  && ! is_std_array< C >::value
777  && has_size_and_data< C >::value
778 >{};
779 
780 template< class C, class E >
781 struct is_compatible_container : std17::bool_constant
782 <
783  is_container<C>::value
784  && is_compatible_element<C,E>::value
785 >{};
786 
787 #else // span_CPP11_140
788 
789 template<
790  class C, class E
792  ! is_span< C >::value
793  && ! is_array< C >::value
794  && ! is_std_array< C >::value
795  && ( std::is_convertible< typename std::remove_pointer<decltype( std17::data( std::declval<C&>() ) )>::type(*)[], E(*)[] >::value)
796  // && has_size_and_data< C >::value
797  ))
798  , class = decltype( std17::size(std::declval<C>()) )
799  , class = decltype( std17::data(std::declval<C>()) )
800 >
801 struct is_compatible_container : std::true_type{};
802 
803 #endif // span_CPP11_140
804 
805 #endif // span_HAVE( TYPE_TRAITS )
806 
807 #if ! span_CONFIG( NO_EXCEPTIONS )
808 #if span_FEATURE( MEMBER_AT ) > 1
809 
810 // format index and size:
811 
812 #if defined(__clang__)
813 # pragma clang diagnostic ignored "-Wlong-long"
814 #elif defined __GNUC__
815 # pragma GCC diagnostic ignored "-Wformat=ll"
816 # pragma GCC diagnostic ignored "-Wlong-long"
817 #endif
818 
819 span_noreturn inline void throw_out_of_range( size_t idx, size_t size )
820 {
821  const char fmt[] = "span::at(): index '%lli' is out of range [0..%lli)";
822  char buffer[ 2 * 20 + sizeof fmt ];
823  sprintf( buffer, fmt, static_cast<long long>(idx), static_cast<long long>(size) );
824 
825  throw std::out_of_range( buffer );
826 }
827 
828 #else // MEMBER_AT
829 
830 span_noreturn inline void throw_out_of_range( size_t /*idx*/, size_t /*size*/ )
831 {
832  throw std::out_of_range( "span::at(): index outside span" );
833 }
834 #endif // MEMBER_AT
835 #endif // NO_EXCEPTIONS
836 
837 #if span_CONFIG( CONTRACT_VIOLATION_THROWS_V )
838 
839 struct contract_violation : std::logic_error
840 {
841  explicit contract_violation( char const * const message )
842  : std::logic_error( message )
843  {}
844 };
845 
846 inline void report_contract_violation( char const * msg )
847 {
848  throw contract_violation( msg );
849 }
850 
851 #else // span_CONFIG( CONTRACT_VIOLATION_THROWS_V )
852 
853 span_noreturn inline void report_contract_violation( char const * /*msg*/ ) span_noexcept
854 {
855  std::terminate();
856 }
857 
858 #endif // span_CONFIG( CONTRACT_VIOLATION_THROWS_V )
859 
860 } // namespace detail
861 
862 // Prevent signed-unsigned mismatch:
863 
864 #define span_sizeof(T) static_cast<extent_t>( sizeof(T) )
865 
866 template< class T >
867 inline span_constexpr size_t to_size( T size )
868 {
869  return static_cast<size_t>( size );
870 }
871 
872 //
873 // [views.span] - A view over a contiguous, single-dimension sequence of objects
874 //
875 template< class T, extent_t Extent /*= dynamic_extent*/ >
876 class span
877 {
878 public:
879  // constants and types
880 
881  typedef T element_type;
883 
884  typedef T & reference;
885  typedef T * pointer;
886  typedef T const * const_pointer;
887  typedef T const & const_reference;
888 
889  typedef size_t size_type;
890  typedef extent_t extent_type;
891 
892  typedef pointer iterator;
893  typedef const_pointer const_iterator;
894 
895  typedef std::ptrdiff_t difference_type;
896 
897  typedef std::reverse_iterator< iterator > reverse_iterator;
898  typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
899 
900 // static constexpr extent_type extent = Extent;
901  enum { extent = Extent };
902 
903  // 26.7.3.2 Constructors, copy, and assignment [span.cons]
904 
906  ( Extent == 0 ) ||
907  ( Extent == dynamic_extent )
908  )
910  : data_( span_nullptr )
911  , size_( 0 )
912  {
913  // span_EXPECTS( data() == span_nullptr );
914  // span_EXPECTS( size() == 0 );
915  }
916 
917 #if span_HAVE( ITERATOR_CTOR )
918  // Didn't yet succeed in combining the next two constructors:
919 
920  span_constexpr_exp span( std::nullptr_t, size_type count )
921  : data_( span_nullptr )
922  , size_( count )
923  {
924  span_EXPECTS( data_ == span_nullptr && count == 0 );
925  }
926 
927  template< typename It
929  std::is_convertible<decltype(*std::declval<It&>()), element_type &>::value
930  ))
931  >
932  span_constexpr_exp span( It first, size_type count )
933  : data_( to_address( first ) )
934  , size_( count )
935  {
936  span_EXPECTS(
937  ( data_ == span_nullptr && count == 0 ) ||
938  ( data_ != span_nullptr && detail::is_positive( count ) )
939  );
940  }
941 #else
942  span_constexpr_exp span( pointer ptr, size_type count )
943  : data_( ptr )
944  , size_( count )
945  {
946  span_EXPECTS(
947  ( ptr == span_nullptr && count == 0 ) ||
948  ( ptr != span_nullptr && detail::is_positive( count ) )
949  );
950  }
951 #endif
952 
953 #if span_HAVE( ITERATOR_CTOR )
954  template< typename It, typename End
956  std::is_convertible<decltype(&*std::declval<It&>()), element_type *>::value
957  && ! std::is_convertible<End, std::size_t>::value
958  ))
959  >
960  span_constexpr_exp span( It first, End last )
961  : data_( to_address( first ) )
962  , size_( to_size( last - first ) )
963  {
964  span_EXPECTS(
965  last - first >= 0
966  );
967  }
968 #else
969  span_constexpr_exp span( pointer first, pointer last )
970  : data_( first )
971  , size_( to_size( last - first ) )
972  {
973  span_EXPECTS(
974  last - first >= 0
975  );
976  }
977 #endif
978 
979  template< std::size_t N
981  (Extent == dynamic_extent || Extent == static_cast<extent_t>(N))
982  && std::is_convertible< value_type(*)[], element_type(*)[] >::value
983  ))
984  >
985  span_constexpr span( element_type ( &arr )[ N ] ) span_noexcept
986  : data_( span_ADDRESSOF( arr[0] ) )
987  , size_( N )
988  {}
989 
990 #if span_HAVE( ARRAY )
991 
992  template< std::size_t N
994  (Extent == dynamic_extent || Extent == static_cast<extent_t>(N))
995  && std::is_convertible< value_type(*)[], element_type(*)[] >::value
996  ))
997  >
998 # if span_FEATURE( CONSTRUCTION_FROM_STDARRAY_ELEMENT_TYPE )
999  span_constexpr span( std::array< element_type, N > & arr ) span_noexcept
1000 # else
1001  span_constexpr span( std::array< value_type, N > & arr ) span_noexcept
1002 # endif
1003  : data_( arr.data() )
1004  , size_( to_size( arr.size() ) )
1005  {}
1006 
1007  template< std::size_t N
1008 # if span_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG )
1009  span_REQUIRES_T((
1010  (Extent == dynamic_extent || Extent == static_cast<extent_t>(N))
1011  && std::is_convertible< value_type(*)[], element_type(*)[] >::value
1012  ))
1013 # endif
1014  >
1015  span_constexpr span( std::array< value_type, N> const & arr ) span_noexcept
1016  : data_( arr.data() )
1017  , size_( to_size( arr.size() ) )
1018  {}
1019 
1020 #endif // span_HAVE( ARRAY )
1021 
1022 #if span_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR )
1023  template< class Container
1024  span_REQUIRES_T((
1025  detail::is_compatible_container< Container, element_type >::value
1026  ))
1027  >
1028  span_constexpr span( Container & cont )
1029  : data_( std17::data( cont ) )
1030  , size_( to_size( std17::size( cont ) ) )
1031  {}
1032 
1033  template< class Container
1034  span_REQUIRES_T((
1035  std::is_const< element_type >::value
1036  && detail::is_compatible_container< Container, element_type >::value
1037  ))
1038  >
1039  span_constexpr span( Container const & cont )
1040  : data_( std17::data( cont ) )
1041  , size_( to_size( std17::size( cont ) ) )
1042  {}
1043 
1044 #endif // span_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR )
1045 
1046 #if span_FEATURE( WITH_CONTAINER )
1047 
1048  template< class Container >
1049  span_constexpr span( with_container_t, Container & cont )
1050  : data_( cont.size() == 0 ? span_nullptr : span_ADDRESSOF( cont[0] ) )
1051  , size_( to_size( cont.size() ) )
1052  {}
1053 
1054  template< class Container >
1055  span_constexpr span( with_container_t, Container const & cont )
1056  : data_( cont.size() == 0 ? span_nullptr : const_cast<pointer>( span_ADDRESSOF( cont[0] ) ) )
1057  , size_( to_size( cont.size() ) )
1058  {}
1059 #endif
1060 
1061 #if span_HAVE( IS_DEFAULT )
1062  span_constexpr span( span const & other ) span_noexcept = default;
1063 
1064  ~span() span_noexcept = default;
1065 
1066  span_constexpr14 span & operator=( span const & other ) span_noexcept = default;
1067 #else
1068  span_constexpr span( span const & other ) span_noexcept
1069  : data_( other.data_ )
1070  , size_( other.size_ )
1071  {}
1072 
1073  ~span() span_noexcept
1074  {}
1075 
1076  span_constexpr14 span & operator=( span const & other ) span_noexcept
1077  {
1078  data_ = other.data_;
1079  size_ = other.size_;
1080 
1081  return *this;
1082  }
1083 #endif
1084 
1085  template< class OtherElementType, extent_type OtherExtent
1086  span_REQUIRES_T((
1087  (Extent == dynamic_extent || OtherExtent == dynamic_extent || Extent == OtherExtent)
1088  && std::is_convertible<OtherElementType(*)[], element_type(*)[]>::value
1089  ))
1090  >
1092  : data_( other.data() )
1093  , size_( other.size() )
1094  {
1095  span_EXPECTS( OtherExtent == dynamic_extent || other.size() == to_size(OtherExtent) );
1096  }
1097 
1098  // 26.7.3.3 Subviews [span.sub]
1099 
1100  template< extent_type Count >
1102  first() const
1103  {
1105 
1106  return span< element_type, Count >( data(), Count );
1107  }
1108 
1109  template< extent_type Count >
1111  last() const
1112  {
1114 
1115  return span< element_type, Count >( data() + (size() - Count), Count );
1116  }
1117 
1118 #if span_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG )
1119  template< size_type Offset, extent_type Count = dynamic_extent >
1120 #else
1121  template< size_type Offset, extent_type Count /*= dynamic_extent*/ >
1122 #endif
1124  subspan() const
1125  {
1126  span_EXPECTS(
1127  ( detail::is_positive( Offset ) && Offset <= size() ) &&
1128  ( Count == dynamic_extent || (detail::is_positive( Count ) && Count + Offset <= size()) )
1129  );
1130 
1132  data() + Offset, Count != dynamic_extent ? Count : (Extent != dynamic_extent ? Extent - Offset : size() - Offset) );
1133  }
1134 
1136  first( size_type count ) const
1137  {
1138  span_EXPECTS( detail::is_positive( count ) && count <= size() );
1139 
1140  return span< element_type, dynamic_extent >( data(), count );
1141  }
1142 
1144  last( size_type count ) const
1145  {
1146  span_EXPECTS( detail::is_positive( count ) && count <= size() );
1147 
1148  return span< element_type, dynamic_extent >( data() + ( size() - count ), count );
1149  }
1150 
1152  subspan( size_type offset, size_type count = static_cast<size_type>(dynamic_extent) ) const
1153  {
1154  span_EXPECTS(
1155  ( ( detail::is_positive( offset ) && offset <= size() ) ) &&
1156  ( count == static_cast<size_type>(dynamic_extent) || ( detail::is_positive( count ) && offset + count <= size() ) )
1157  );
1158 
1160  data() + offset, count == static_cast<size_type>(dynamic_extent) ? size() - offset : count );
1161  }
1162 
1163  // 26.7.3.4 Observers [span.obs]
1164 
1165  span_constexpr size_type size() const span_noexcept
1166  {
1167  return size_;
1168  }
1169 
1170  span_constexpr std::ptrdiff_t ssize() const span_noexcept
1171  {
1172  return static_cast<std::ptrdiff_t>( size_ );
1173  }
1174 
1175  span_constexpr size_type size_bytes() const span_noexcept
1176  {
1177  return size() * to_size( sizeof( element_type ) );
1178  }
1179 
1180  span_nodiscard span_constexpr bool empty() const span_noexcept
1181  {
1182  return size() == 0;
1183  }
1184 
1185  // 26.7.3.5 Element access [span.elem]
1186 
1187  span_constexpr_exp reference operator[]( size_type idx ) const
1188  {
1189  span_EXPECTS( detail::is_positive( idx ) && idx < size() );
1190 
1191  return *( data() + idx );
1192  }
1193 
1194 #if span_FEATURE( MEMBER_CALL_OPERATOR )
1195  span_deprecated("replace operator() with operator[]")
1196 
1197  span_constexpr_exp reference operator()( size_type idx ) const
1198  {
1199  span_EXPECTS( detail::is_positive( idx ) && idx < size() );
1200 
1201  return *( data() + idx );
1202  }
1203 #endif
1204 
1205 #if span_FEATURE( MEMBER_AT )
1206  span_constexpr14 reference at( size_type idx ) const
1207  {
1208 #if span_CONFIG( NO_EXCEPTIONS )
1209  return this->operator[]( idx );
1210 #else
1211  if ( !detail::is_positive( idx ) || size() <= idx )
1212  {
1213  detail::throw_out_of_range( idx, size() );
1214  }
1215  return *( data() + idx );
1216 #endif
1217  }
1218 #endif
1219 
1220  span_constexpr pointer data() const span_noexcept
1221  {
1222  return data_;
1223  }
1224 
1225 #if span_FEATURE( MEMBER_BACK_FRONT )
1226 
1227  span_constexpr_exp reference front() const span_noexcept
1228  {
1229  span_EXPECTS( ! empty() );
1230 
1231  return *data();
1232  }
1233 
1234  span_constexpr_exp reference back() const span_noexcept
1235  {
1236  span_EXPECTS( ! empty() );
1237 
1238  return *( data() + size() - 1 );
1239  }
1240 
1241 #endif
1242 
1243  // xx.x.x.x Modifiers [span.modifiers]
1244 
1245 #if span_FEATURE( MEMBER_SWAP )
1246 
1247  span_constexpr14 void swap( span & other ) span_noexcept
1248  {
1249  using std::swap;
1250  swap( data_, other.data_ );
1251  swap( size_, other.size_ );
1252  }
1253 #endif
1254 
1255  // 26.7.3.6 Iterator support [span.iterators]
1256 
1257  span_constexpr iterator begin() const span_noexcept
1258  {
1259 #if span_CPP11_OR_GREATER
1260  return { data() };
1261 #else
1262  return iterator( data() );
1263 #endif
1264  }
1265 
1266  span_constexpr iterator end() const span_noexcept
1267  {
1268 #if span_CPP11_OR_GREATER
1269  return { data() + size() };
1270 #else
1271  return iterator( data() + size() );
1272 #endif
1273  }
1274 
1275  span_constexpr const_iterator cbegin() const span_noexcept
1276  {
1277 #if span_CPP11_OR_GREATER
1278  return { data() };
1279 #else
1280  return const_iterator( data() );
1281 #endif
1282  }
1283 
1284  span_constexpr const_iterator cend() const span_noexcept
1285  {
1286 #if span_CPP11_OR_GREATER
1287  return { data() + size() };
1288 #else
1289  return const_iterator( data() + size() );
1290 #endif
1291  }
1292 
1293  span_constexpr reverse_iterator rbegin() const span_noexcept
1294  {
1295  return reverse_iterator( end() );
1296  }
1297 
1298  span_constexpr reverse_iterator rend() const span_noexcept
1299  {
1300  return reverse_iterator( begin() );
1301  }
1302 
1303  span_constexpr const_reverse_iterator crbegin() const span_noexcept
1304  {
1305  return const_reverse_iterator ( cend() );
1306  }
1307 
1308  span_constexpr const_reverse_iterator crend() const span_noexcept
1309  {
1310  return const_reverse_iterator( cbegin() );
1311  }
1312 
1313 private:
1314 
1315  // Note: C++20 has std::pointer_traits<Ptr>::to_address( it );
1316 
1317 #if span_HAVE( ITERATOR_CTOR )
1318  static inline span_constexpr pointer to_address( std::nullptr_t ) span_noexcept
1319  {
1320  return nullptr;
1321  }
1322 
1323  template< typename U >
1324  static inline span_constexpr U * to_address( U * p ) span_noexcept
1325  {
1326  return p;
1327  }
1328 
1329  template< typename Ptr
1330  span_REQUIRES_T(( ! std::is_pointer<Ptr>::value ))
1331  >
1332  static inline span_constexpr pointer to_address( Ptr const & it ) span_noexcept
1333  {
1334  return to_address( it.operator->() );
1335  }
1336 #endif // span_HAVE( ITERATOR_CTOR )
1337 
1338 private:
1339  pointer data_;
1340  size_type size_;
1341 };
1342 
1343 // class template argument deduction guides:
1344 
1345 #if span_HAVE( DEDUCTION_GUIDES )
1346 
1347 template< class T, size_t N >
1348 span( T (&)[N] ) -> span<T, static_cast<extent_t>(N)>;
1349 
1350 template< class T, size_t N >
1351 span( std::array<T, N> & ) -> span<T, static_cast<extent_t>(N)>;
1352 
1353 template< class T, size_t N >
1354 span( std::array<T, N> const & ) -> span<const T, static_cast<extent_t>(N)>;
1355 
1356 #if span_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR )
1357 
1358 template< class Container >
1359 span( Container& ) -> span<typename Container::value_type>;
1360 
1361 template< class Container >
1362 span( Container const & ) -> span<const typename Container::value_type>;
1363 
1364 #endif
1365 
1366 // iterator: constraints: It satisfies contiguous_­iterator.
1367 
1368 template< class It, class EndOrSize >
1370 
1371 #endif // span_HAVE( DEDUCTION_GUIDES )
1372 
1373 // 26.7.3.7 Comparison operators [span.comparison]
1374 
1375 #if span_FEATURE( COMPARISON )
1376 #if span_FEATURE( SAME )
1377 
1378 template< class T1, extent_t E1, class T2, extent_t E2 >
1379 inline span_constexpr bool same( span<T1,E1> const & l, span<T2,E2> const & r ) span_noexcept
1380 {
1382  && l.size() == r.size()
1383  && static_cast<void const*>( l.data() ) == r.data();
1384 }
1385 
1386 #endif
1387 
1388 template< class T1, extent_t E1, class T2, extent_t E2 >
1389 inline span_constexpr bool operator==( span<T1,E1> const & l, span<T2,E2> const & r )
1390 {
1391  return
1392 #if span_FEATURE( SAME )
1393  same( l, r ) ||
1394 #endif
1395  ( l.size() == r.size() && std::equal( l.begin(), l.end(), r.begin() ) );
1396 }
1397 
1398 template< class T1, extent_t E1, class T2, extent_t E2 >
1399 inline span_constexpr bool operator<( span<T1,E1> const & l, span<T2,E2> const & r )
1400 {
1401  return std::lexicographical_compare( l.begin(), l.end(), r.begin(), r.end() );
1402 }
1403 
1404 template< class T1, extent_t E1, class T2, extent_t E2 >
1405 inline span_constexpr bool operator!=( span<T1,E1> const & l, span<T2,E2> const & r )
1406 {
1407  return !( l == r );
1408 }
1409 
1410 template< class T1, extent_t E1, class T2, extent_t E2 >
1411 inline span_constexpr bool operator<=( span<T1,E1> const & l, span<T2,E2> const & r )
1412 {
1413  return !( r < l );
1414 }
1415 
1416 template< class T1, extent_t E1, class T2, extent_t E2 >
1417 inline span_constexpr bool operator>( span<T1,E1> const & l, span<T2,E2> const & r )
1418 {
1419  return ( r < l );
1420 }
1421 
1422 template< class T1, extent_t E1, class T2, extent_t E2 >
1423 inline span_constexpr bool operator>=( span<T1,E1> const & l, span<T2,E2> const & r )
1424 {
1425  return !( l < r );
1426 }
1427 
1428 #endif // span_FEATURE( COMPARISON )
1429 
1430 // 26.7.2.6 views of object representation [span.objectrep]
1431 
1432 #if span_HAVE( BYTE ) || span_HAVE( NONSTD_BYTE )
1433 
1434 // Avoid MSVC 14.1 (1910), VS 2017: warning C4307: '*': integral constant overflow:
1435 
1436 template< typename T, extent_t Extent >
1437 struct BytesExtent
1438 {
1439 #if span_CPP11_OR_GREATER
1440  enum ET : extent_t { value = span_sizeof(T) * Extent };
1441 #else
1442  enum ET { value = span_sizeof(T) * Extent };
1443 #endif
1444 };
1445 
1446 template< typename T >
1447 struct BytesExtent< T, dynamic_extent >
1448 {
1449 #if span_CPP11_OR_GREATER
1450  enum ET : extent_t { value = dynamic_extent };
1451 #else
1452  enum ET { value = dynamic_extent };
1453 #endif
1454 };
1455 
1456 template< class T, extent_t Extent >
1458 as_bytes( span<T,Extent> spn ) span_noexcept
1459 {
1460 #if 0
1461  return { reinterpret_cast< std17::byte const * >( spn.data() ), spn.size_bytes() };
1462 #else
1464  reinterpret_cast< std17::byte const * >( spn.data() ), spn.size_bytes() ); // NOLINT
1465 #endif
1466 }
1467 
1468 template< class T, extent_t Extent >
1470 as_writable_bytes( span<T,Extent> spn ) span_noexcept
1471 {
1472 #if 0
1473  return { reinterpret_cast< std17::byte * >( spn.data() ), spn.size_bytes() };
1474 #else
1476  reinterpret_cast< std17::byte * >( spn.data() ), spn.size_bytes() ); // NOLINT
1477 #endif
1478 }
1479 
1480 #endif // span_HAVE( BYTE ) || span_HAVE( NONSTD_BYTE )
1481 
1482 // 27.8 Container and view access [iterator.container]
1483 
1484 template< class T, extent_t Extent /*= dynamic_extent*/ >
1486 {
1487  return static_cast<std::size_t>( spn.size() );
1488 }
1489 
1490 template< class T, extent_t Extent /*= dynamic_extent*/ >
1491 span_constexpr std::ptrdiff_t ssize( span<T,Extent> const & spn )
1492 {
1493  return static_cast<std::ptrdiff_t>( spn.size() );
1494 }
1495 
1496 } // namespace span_lite
1497 } // namespace nonstd
1498 
1499 // make available in nonstd:
1500 
1501 namespace nonstd {
1502 
1504 
1505 using span_lite::span;
1506 
1508 
1509 #if span_FEATURE( COMPARISON )
1510 #if span_FEATURE( SAME )
1511 using span_lite::same;
1512 #endif
1513 
1514 using span_lite::operator==;
1515 using span_lite::operator!=;
1516 using span_lite::operator<;
1517 using span_lite::operator<=;
1518 using span_lite::operator>;
1519 using span_lite::operator>=;
1520 #endif
1521 
1522 #if span_HAVE( BYTE )
1523 using span_lite::as_bytes;
1524 using span_lite::as_writable_bytes;
1525 #endif
1526 
1527 using span_lite::size;
1528 using span_lite::ssize;
1529 
1530 } // namespace nonstd
1531 
1532 #endif // span_USES_STD_SPAN
1533 
1534 // make_span() [span-lite extension]:
1535 
1536 #if span_FEATURE( MAKE_SPAN ) || span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_SPAN ) || span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_CONTAINER )
1537 
1538 #if span_USES_STD_SPAN
1539 # define span_constexpr constexpr
1540 # define span_noexcept noexcept
1541 # define span_nullptr nullptr
1542 # ifndef span_CONFIG_EXTENT_TYPE
1543 # define span_CONFIG_EXTENT_TYPE std::size_t
1544 # endif
1545 using extent_t = span_CONFIG_EXTENT_TYPE;
1546 #endif // span_USES_STD_SPAN
1547 
1548 namespace nonstd {
1549 namespace span_lite {
1550 
1551 template< class T >
1552 inline span_constexpr span<T>
1553 make_span( T * ptr, size_t count ) span_noexcept
1554 {
1555  return span<T>( ptr, count );
1556 }
1557 
1558 template< class T >
1559 inline span_constexpr span<T>
1560 make_span( T * first, T * last ) span_noexcept
1561 {
1562  return span<T>( first, last );
1563 }
1564 
1565 template< class T, std::size_t N >
1567 make_span( T ( &arr )[ N ] ) span_noexcept
1568 {
1569  return span<T, static_cast<extent_t>(N)>( &arr[ 0 ], N );
1570 }
1571 
1572 #if span_USES_STD_SPAN || span_HAVE( ARRAY )
1573 
1574 template< class T, std::size_t N >
1576 make_span( std::array< T, N > & arr ) span_noexcept
1577 {
1578  return span<T, static_cast<extent_t>(N)>( arr );
1579 }
1580 
1581 template< class T, std::size_t N >
1583 make_span( std::array< T, N > const & arr ) span_noexcept
1584 {
1585  return span<const T, static_cast<extent_t>(N)>( arr );
1586 }
1587 
1588 #endif // span_HAVE( ARRAY )
1589 
1590 #if span_USES_STD_SPAN
1591 
1592 template< class Container, class EP = decltype( std::data(std::declval<Container&>())) >
1593 inline span_constexpr auto
1594 make_span( Container & cont ) span_noexcept -> span< typename std::remove_pointer<EP>::type >
1595 {
1597 }
1598 
1599 template< class Container, class EP = decltype( std::data(std::declval<Container&>())) >
1600 inline span_constexpr auto
1601 make_span( Container const & cont ) span_noexcept -> span< const typename std::remove_pointer<EP>::type >
1602 {
1604 }
1605 
1606 #elif span_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) && span_HAVE( AUTO )
1607 
1608 template< class Container, class EP = decltype( std17::data(std::declval<Container&>())) >
1609 inline span_constexpr auto
1610 make_span( Container & cont ) span_noexcept -> span< typename std::remove_pointer<EP>::type >
1611 {
1613 }
1614 
1615 template< class Container, class EP = decltype( std17::data(std::declval<Container&>())) >
1616 inline span_constexpr auto
1617 make_span( Container const & cont ) span_noexcept -> span< const typename std::remove_pointer<EP>::type >
1618 {
1620 }
1621 
1622 #else
1623 
1624 template< class T >
1625 inline span_constexpr span<T>
1626 make_span( span<T> spn ) span_noexcept
1627 {
1628  return spn;
1629 }
1630 
1631 template< class T, class Allocator >
1632 inline span_constexpr span<T>
1633 make_span( std::vector<T, Allocator> & cont ) span_noexcept
1634 {
1635  return span<T>( with_container, cont );
1636 }
1637 
1638 template< class T, class Allocator >
1640 make_span( std::vector<T, Allocator> const & cont ) span_noexcept
1641 {
1642  return span<const T>( with_container, cont );
1643 }
1644 
1645 #endif // span_USES_STD_SPAN || ( ... )
1646 
1647 #if ! span_USES_STD_SPAN && span_FEATURE( WITH_CONTAINER )
1648 
1649 template< class Container >
1651 make_span( with_container_t, Container & cont ) span_noexcept
1652 {
1654 }
1655 
1656 template< class Container >
1658 make_span( with_container_t, Container const & cont ) span_noexcept
1659 {
1661 }
1662 
1663 #endif // ! span_USES_STD_SPAN && span_FEATURE( WITH_CONTAINER )
1664 
1665 // extensions: non-member views:
1666 // this feature implies the presence of make_span()
1667 
1668 #if span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_SPAN )
1669 
1670 template< extent_t Count, class T, extent_t Extent >
1672 first( span<T, Extent> spn )
1673 {
1674  return spn.template first<Count>();
1675 }
1676 
1677 template< class T, extent_t Extent >
1679 first( span<T, Extent> spn, size_t count )
1680 {
1681  return spn.first( count );
1682 }
1683 
1684 template< extent_t Count, class T, extent_t Extent >
1686 last( span<T, Extent> spn )
1687 {
1688  return spn.template last<Count>();
1689 }
1690 
1691 template< class T, extent_t Extent >
1693 last( span<T, Extent> spn, size_t count )
1694 {
1695  return spn.last( count );
1696 }
1697 
1698 template< size_t Offset, extent_t Count, class T, extent_t Extent >
1700 subspan( span<T, Extent> spn )
1701 {
1702  return spn.template subspan<Offset, Count>();
1703 }
1704 
1705 template< class T, extent_t Extent >
1707 subspan( span<T, Extent> spn, size_t offset, extent_t count = dynamic_extent )
1708 {
1709  return spn.subspan( offset, count );
1710 }
1711 
1712 #endif // span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_SPAN )
1713 
1714 #if span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_CONTAINER ) && span_CPP11_120
1715 
1716 template< extent_t Count, class T >
1717 span_constexpr auto
1718 first( T & t ) -> decltype( make_span(t).template first<Count>() )
1719 {
1720  return make_span( t ).template first<Count>();
1721 }
1722 
1723 template< class T >
1724 span_constexpr auto
1725 first( T & t, size_t count ) -> decltype( make_span(t).first(count) )
1726 {
1727  return make_span( t ).first( count );
1728 }
1729 
1730 template< extent_t Count, class T >
1731 span_constexpr auto
1732 last( T & t ) -> decltype( make_span(t).template last<Count>() )
1733 {
1734  return make_span(t).template last<Count>();
1735 }
1736 
1737 template< class T >
1738 span_constexpr auto
1739 last( T & t, extent_t count ) -> decltype( make_span(t).last(count) )
1740 {
1741  return make_span( t ).last( count );
1742 }
1743 
1744 template< size_t Offset, extent_t Count = dynamic_extent, class T >
1745 span_constexpr auto
1746 subspan( T & t ) -> decltype( make_span(t).template subspan<Offset, Count>() )
1747 {
1748  return make_span( t ).template subspan<Offset, Count>();
1749 }
1750 
1751 template< class T >
1752 span_constexpr auto
1753 subspan( T & t, size_t offset, extent_t count = dynamic_extent ) -> decltype( make_span(t).subspan(offset, count) )
1754 {
1755  return make_span( t ).subspan( offset, count );
1756 }
1757 
1758 #endif // span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_CONTAINER )
1759 
1760 } // namespace span_lite
1761 } // namespace nonstd
1762 
1763 // make available in nonstd:
1764 
1765 namespace nonstd {
1766 using span_lite::make_span;
1767 
1768 #if span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_SPAN ) || ( span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_CONTAINER ) && span_CPP11_120 )
1769 
1770 using span_lite::first;
1771 using span_lite::last;
1772 using span_lite::subspan;
1773 
1774 #endif // span_FEATURE( NON_MEMBER_FIRST_LAST_SUB_[SPAN|CONTAINER] )
1775 
1776 } // namespace nonstd
1777 
1778 #endif // #if span_FEATURE_TO_STD( MAKE_SPAN )
1779 
1780 #if span_CPP11_OR_GREATER && span_FEATURE( BYTE_SPAN ) && ( span_HAVE( BYTE ) || span_HAVE( NONSTD_BYTE ) )
1781 
1782 namespace nonstd {
1783 namespace span_lite {
1784 
1785 template< class T >
1786 inline span_constexpr auto
1787 byte_span( T & t ) span_noexcept -> span< std17::byte, span_sizeof(T) >
1788 {
1789  return span< std17::byte, span_sizeof(t) >( reinterpret_cast< std17::byte * >( &t ), span_sizeof(T) );
1790 }
1791 
1792 template< class T >
1793 inline span_constexpr auto
1794 byte_span( T const & t ) span_noexcept -> span< const std17::byte, span_sizeof(T) >
1795 {
1796  return span< const std17::byte, span_sizeof(t) >( reinterpret_cast< std17::byte const * >( &t ), span_sizeof(T) );
1797 }
1798 
1799 } // namespace span_lite
1800 } // namespace nonstd
1801 
1802 // make available in nonstd:
1803 
1804 namespace nonstd {
1805 using span_lite::byte_span;
1806 } // namespace nonstd
1807 
1808 #endif // span_FEATURE( BYTE_SPAN )
1809 
1810 #if span_HAVE( STRUCT_BINDING )
1811 
1812 #if span_CPP14_OR_GREATER
1813 # include <tuple>
1814 #elif span_CPP11_OR_GREATER
1815 # include <tuple>
1816 namespace std {
1817  template< std::size_t I, typename T >
1818  using tuple_element_t = typename tuple_element<I, T>::type;
1819 }
1820 #else
1821 namespace std {
1822  template< typename T >
1823  class tuple_size; /*undefined*/
1824 
1825  template< std::size_t I, typename T >
1826  class tuple_element; /* undefined */
1827 }
1828 #endif // span_CPP14_OR_GREATER
1829 
1830 namespace std {
1831 
1832 // 26.7.X Tuple interface
1833 
1834 // std::tuple_size<>:
1835 
1836 template< typename ElementType, nonstd::span_lite::extent_t Extent >
1837 class tuple_size< nonstd::span<ElementType, Extent> > : public integral_constant<size_t, static_cast<size_t>(Extent)> {};
1838 
1839 // std::tuple_size<>: Leave undefined for dynamic extent:
1840 
1841 template< typename ElementType >
1842 class tuple_size< nonstd::span<ElementType, nonstd::dynamic_extent> >;
1843 
1844 // std::tuple_element<>:
1845 
1846 template< size_t I, typename ElementType, nonstd::span_lite::extent_t Extent >
1847 class tuple_element< I, nonstd::span<ElementType, Extent> >
1848 {
1849 public:
1850 #if span_HAVE( STATIC_ASSERT )
1851  static_assert( Extent != nonstd::dynamic_extent && I < Extent, "tuple_element<I,span>: dynamic extent or index out of range" );
1852 #endif
1853  using type = ElementType;
1854 };
1855 
1856 // std::get<>(), 2 variants:
1857 
1858 template< size_t I, typename ElementType, nonstd::span_lite::extent_t Extent >
1859 span_constexpr ElementType & get( nonstd::span<ElementType, Extent> & spn ) span_noexcept
1860 {
1861 #if span_HAVE( STATIC_ASSERT )
1862  static_assert( Extent != nonstd::dynamic_extent && I < Extent, "get<>(span): dynamic extent or index out of range" );
1863 #endif
1864  return spn[I];
1865 }
1866 
1867 template< size_t I, typename ElementType, nonstd::span_lite::extent_t Extent >
1868 span_constexpr ElementType const & get( nonstd::span<ElementType, Extent> const & spn ) span_noexcept
1869 {
1870 #if span_HAVE( STATIC_ASSERT )
1871  static_assert( Extent != nonstd::dynamic_extent && I < Extent, "get<>(span): dynamic extent or index out of range" );
1872 #endif
1873  return spn[I];
1874 }
1875 
1876 } // end namespace std
1877 
1878 #endif // span_HAVE( STRUCT_BINDING )
1879 
1880 #if ! span_USES_STD_SPAN
1882 #endif // span_USES_STD_SPAN
1883 
1884 #endif // NONSTD_SPAN_HPP_INCLUDED
std11::remove_volatile< typename std11::remove_const< T >::type >::type type
Definition: span.hpp:594
span_constexpr_exp span< element_type, dynamic_extent > subspan(size_type offset, size_type count=static_cast< size_type >(dynamic_extent)) const
Definition: span.hpp:1152
span_constexpr_exp span(pointer first, pointer last)
Definition: span.hpp:969
const_pointer const_iterator
Definition: span.hpp:893
#define span_noexcept
Definition: span.hpp:427
span_constexpr span(span const &other) span_noexcept
Definition: span.hpp:1068
span_constexpr_exp reference operator[](size_type idx) const
Definition: span.hpp:1187
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
relop
Definition: sol.hpp:6020
span_constexpr iterator begin() const span_noexcept
Definition: span.hpp:1257
span_constexpr_exp span(span< OtherElementType, OtherExtent > const &other) span_noexcept
Definition: span.hpp:1091
constexpr bool operator>=(const optional< T > &lhs, const optional< U > &rhs)
relop
Definition: sol.hpp:6040
span_CONFIG_SIZE_TYPE size_t
Definition: span.hpp:561
#define span_constexpr_exp
Definition: span.hpp:502
span_constexpr std::ptrdiff_t ssize(span< T, Extent > const &spn)
Definition: span.hpp:1491
#define span_REQUIRES_T(VA)
Definition: span.hpp:549
std::ptrdiff_t difference_type
Definition: span.hpp:895
std::tuple_element_t< N, std::remove_reference_t< Tuple > > tuple_element_t
Definition: sol.hpp:1507
constexpr bool operator>(const optional< T > &lhs, const optional< U > &rhs)
relop
Definition: sol.hpp:6030
T const & const_reference
Definition: span.hpp:887
Count
span_constexpr reverse_iterator rbegin() const span_noexcept
Definition: span.hpp:1293
#define span_EXPECTS(cond)
Definition: span.hpp:503
#define span_sizeof(T)
Definition: span.hpp:864
#define span_CONFIG_EXTENT_TYPE
Definition: span.hpp:50
span_constexpr_exp span< element_type, dynamic_extent > last(size_type count) const
Definition: span.hpp:1144
span_constexpr size_type size_bytes() const span_noexcept
Definition: span.hpp:1175
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
Definition: printf.h:574
#define span_ADDRESSOF(x)
Definition: span.hpp:391
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_t >::value > is_signed
Definition: format.h:821
span_CONFIG_EXTENT_TYPE extent_t
Definition: span.hpp:560
span_constexpr_exp span< element_type, Count > last() const
Definition: span.hpp:1111
span_constexpr const_iterator cbegin() const span_noexcept
Definition: span.hpp:1275
span_constexpr_exp span< element_type, Count > first() const
Definition: span.hpp:1102
const span_constexpr with_container_t with_container
Definition: span.hpp:571
extent_t extent_type
Definition: span.hpp:890
span_constexpr span(element_type(&arr)[N]) span_noexcept
Definition: span.hpp:985
type
Definition: core.h:1059
T const * const_pointer
Definition: span.hpp:886
#define span_RESTORE_WARNINGS()
Definition: span.hpp:308
span_constexpr const_reverse_iterator crbegin() const span_noexcept
Definition: span.hpp:1303
Definition: core.h:760
integral_constant< bool, false > false_type
Definition: span.hpp:612
#define span_noreturn
Definition: span.hpp:451
span_constexpr size_t to_size(T size)
Definition: span.hpp:867
Definition: args.h:19
span_constexpr pointer data() const span_noexcept
Definition: span.hpp:1220
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:21884
span_noreturn void report_contract_violation(char const *) span_noexcept
Definition: span.hpp:853
constexpr auto count() -> size_t
Definition: core.h:1050
span_constexpr_exp span< element_type, Count > subspan() const
Definition: span.hpp:1124
void void_t
Definition: core.h:1512
integral_constant< bool, true > true_type
Definition: span.hpp:611
#define span_constexpr14
Definition: span.hpp:403
span_constexpr_exp reference back() const span_noexcept
Definition: span.hpp:1234
std11::remove_cv< T >::type value_type
Definition: span.hpp:882
j template void())
Definition: json.hpp:4061
#define span_nodiscard
Definition: span.hpp:445
T * ptr(T &val)
Definition: sol.hpp:2106
std::reverse_iterator< iterator > reverse_iterator
Definition: span.hpp:897
span_constexpr bool is_positive(T x)
Definition: span.hpp:710
const T & first(const T &value, const Tail &...)
Definition: compile.h:178
span_constexpr_exp span(pointer ptr, size_type count)
Definition: span.hpp:942
bool operator==(QwtEventPattern::MousePattern b1, QwtEventPattern::MousePattern b2)
Compare operator.
#define span_deprecated(msg)
Definition: span.hpp:439
remove_cvref_t< decltype(*detail::range_begin(std::declval< Range >()))> value_type
Definition: ranges.h:246
string template
span_constexpr with_container_t() span_noexcept
Definition: span.hpp:570
span_constexpr_exp reference front() const span_noexcept
Definition: span.hpp:1227
span_constexpr const extent_t dynamic_extent
Definition: span.hpp:563
span_REQUIRES_0((Extent==0)||(Extent==dynamic_extent)) span_constexpr span() span_noexcept
Definition: span.hpp:905
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: span.hpp:898
span_constexpr const_iterator cend() const span_noexcept
Definition: span.hpp:1284
span_constexpr std::ptrdiff_t ssize() const span_noexcept
Definition: span.hpp:1170
span_constexpr iterator end() const span_noexcept
Definition: span.hpp:1266
span_constexpr size_type size() const span_noexcept
Definition: span.hpp:1165
#define span_constexpr
Definition: span.hpp:397
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1485
span_nodiscard span_constexpr bool empty() const span_noexcept
Definition: span.hpp:1180
#define span_nullptr
Definition: span.hpp:433
Definition: core.h:1131
span_constexpr reverse_iterator rend() const span_noexcept
Definition: span.hpp:1298
~span() span_noexcept
Definition: span.hpp:1073
dictionary data
Definition: mqtt_test.py:22
span_constexpr const_reverse_iterator crend() const span_noexcept
Definition: span.hpp:1308
span_constexpr_exp span< element_type, dynamic_extent > first(size_type count) const
Definition: span.hpp:1136
std::tuple_element< N, std::remove_reference_t< Tuple > > tuple_element
Definition: sol.hpp:1504
#define span_CONFIG_SIZE_TYPE
Definition: span.hpp:54
span_constexpr14 span & operator=(span const &other) span_noexcept
Definition: span.hpp:1076


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:12:53