/
mdspan.hpp
5963 lines (5235 loc) · 222 KB
/
mdspan.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef _MDSPAN_SINGLE_HEADER_INCLUDE_GUARD_
#define _MDSPAN_SINGLE_HEADER_INCLUDE_GUARD_
//BEGIN_FILE_INCLUDE: /home/runner/work/mdspan/mdspan/include/experimental/mdarray
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
#ifndef MDSPAN_IMPL_STANDARD_NAMESPACE
#define MDSPAN_IMPL_STANDARD_NAMESPACE std
#endif
#ifndef MDSPAN_IMPL_PROPOSED_NAMESPACE
#define MDSPAN_IMPL_PROPOSED_NAMESPACE experimental
#endif
//BEGIN_FILE_INCLUDE: /home/runner/work/mdspan/mdspan/include/experimental/mdspan
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
#ifndef MDSPAN_IMPL_STANDARD_NAMESPACE
#define MDSPAN_IMPL_STANDARD_NAMESPACE std
#endif
#ifndef MDSPAN_IMPL_PROPOSED_NAMESPACE
#define MDSPAN_IMPL_PROPOSED_NAMESPACE experimental
#endif
//BEGIN_FILE_INCLUDE: /home/runner/work/mdspan/mdspan/include/mdspan/mdspan.hpp
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
#ifndef MDSPAN_HPP_
#define MDSPAN_HPP_
#ifndef MDSPAN_IMPL_STANDARD_NAMESPACE
#define MDSPAN_IMPL_STANDARD_NAMESPACE Kokkos
#endif
#ifndef MDSPAN_IMPL_PROPOSED_NAMESPACE
#define MDSPAN_IMPL_PROPOSED_NAMESPACE Experimental
#endif
//BEGIN_FILE_INCLUDE: /home/runner/work/mdspan/mdspan/include/experimental/__p0009_bits/default_accessor.hpp
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
//BEGIN_FILE_INCLUDE: /home/runner/work/mdspan/mdspan/include/experimental/__p0009_bits/macros.hpp
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
//BEGIN_FILE_INCLUDE: /home/runner/work/mdspan/mdspan/include/experimental/__p0009_bits/config.hpp
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
#ifndef __has_include
# define __has_include(x) 0
#endif
#if __has_include(<version>)
# include <version>
#else
# include <type_traits>
# include <utility>
#endif
#ifdef _MSVC_LANG
#define _MDSPAN_CPLUSPLUS _MSVC_LANG
#else
#define _MDSPAN_CPLUSPLUS __cplusplus
#endif
#define MDSPAN_CXX_STD_14 201402L
#define MDSPAN_CXX_STD_17 201703L
#define MDSPAN_CXX_STD_20 202002L
// Note GCC has not updated this in version 13
#ifdef __clang__
#define MDSPAN_CXX_STD_23 202302L
#else
#define MDSPAN_CXX_STD_23 202100L
#endif
#define MDSPAN_HAS_CXX_14 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14)
#define MDSPAN_HAS_CXX_17 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_17)
#define MDSPAN_HAS_CXX_20 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_20)
#define MDSPAN_HAS_CXX_23 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_23)
static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or later.");
#ifndef _MDSPAN_COMPILER_CLANG
# if defined(__clang__)
# define _MDSPAN_COMPILER_CLANG __clang__
# endif
#endif
#if !defined(_MDSPAN_COMPILER_MSVC) && !defined(_MDSPAN_COMPILER_MSVC_CLANG)
# if defined(_MSC_VER)
# if !defined(_MDSPAN_COMPILER_CLANG)
# define _MDSPAN_COMPILER_MSVC _MSC_VER
# else
# define _MDSPAN_COMPILER_MSVC_CLANG _MSC_VER
# endif
# endif
#endif
#ifndef _MDSPAN_COMPILER_INTEL
# ifdef __INTEL_COMPILER
# define _MDSPAN_COMPILER_INTEL __INTEL_COMPILER
# endif
#endif
#ifndef _MDSPAN_COMPILER_APPLECLANG
# ifdef __apple_build_version__
# define _MDSPAN_COMPILER_APPLECLANG __apple_build_version__
# endif
#endif
#ifndef _MDSPAN_HAS_CUDA
# if defined(__CUDACC__)
# define _MDSPAN_HAS_CUDA __CUDACC__
# endif
#endif
#ifndef _MDSPAN_HAS_HIP
# if defined(__HIPCC__)
# define _MDSPAN_HAS_HIP __HIPCC__
# endif
#endif
#ifndef _MDSPAN_HAS_SYCL
# if defined(SYCL_LANGUAGE_VERSION)
# define _MDSPAN_HAS_SYCL SYCL_LANGUAGE_VERSION
# endif
#endif
#ifndef __has_cpp_attribute
# define __has_cpp_attribute(x) 0
#endif
#ifndef _MDSPAN_PRESERVE_STANDARD_LAYOUT
// Preserve standard layout by default, but we're not removing the old version
// that turns this off until we're sure this doesn't have an unreasonable cost
// to the compiler or optimizer.
# define _MDSPAN_PRESERVE_STANDARD_LAYOUT 1
#endif
#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
# if ((__has_cpp_attribute(no_unique_address) >= 201803L) && \
(!defined(__NVCC__) || MDSPAN_HAS_CXX_20) && \
(!defined(_MDSPAN_COMPILER_MSVC) || MDSPAN_HAS_CXX_20))
# define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1
# define _MDSPAN_NO_UNIQUE_ADDRESS [[no_unique_address]]
# else
# define _MDSPAN_NO_UNIQUE_ADDRESS
# endif
#endif
// NVCC older than 11.6 chokes on the no-unique-address-emulation
// so just pretend to use it (to avoid the full blown EBO workaround
// which NVCC also doesn't like ...), and leave the macro empty
#ifndef _MDSPAN_NO_UNIQUE_ADDRESS
# if defined(__NVCC__)
# define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1
# define _MDSPAN_USE_FAKE_ATTRIBUTE_NO_UNIQUE_ADDRESS
# endif
# define _MDSPAN_NO_UNIQUE_ADDRESS
#endif
// AMDs HIP compiler seems to have issues with concepts
// it pretends concepts exist, but doesn't ship <concept>
#ifndef __HIPCC__
#ifndef _MDSPAN_USE_CONCEPTS
# if defined(__cpp_concepts) && __cpp_concepts >= 201507L
# define _MDSPAN_USE_CONCEPTS 1
# endif
#endif
#endif
#ifndef _MDSPAN_USE_FOLD_EXPRESSIONS
# if (defined(__cpp_fold_expressions) && __cpp_fold_expressions >= 201603L) \
|| (!defined(__cpp_fold_expressions) && MDSPAN_HAS_CXX_17)
# define _MDSPAN_USE_FOLD_EXPRESSIONS 1
# endif
#endif
#ifndef _MDSPAN_USE_INLINE_VARIABLES
# if defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L \
|| (!defined(__cpp_inline_variables) && MDSPAN_HAS_CXX_17)
# define _MDSPAN_USE_INLINE_VARIABLES 1
# endif
#endif
#ifndef _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS
# if (!(defined(__cpp_lib_type_trait_variable_templates) && __cpp_lib_type_trait_variable_templates >= 201510L) \
|| !MDSPAN_HAS_CXX_17)
# if !(defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_17)
# define _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS 1
# endif
# endif
#endif
#ifndef _MDSPAN_USE_VARIABLE_TEMPLATES
# if (defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 && MDSPAN_HAS_CXX_17) \
|| (!defined(__cpp_variable_templates) && MDSPAN_HAS_CXX_17)
# define _MDSPAN_USE_VARIABLE_TEMPLATES 1
# endif
#endif // _MDSPAN_USE_VARIABLE_TEMPLATES
#ifndef _MDSPAN_USE_CONSTEXPR_14
# if (defined(__cpp_constexpr) && __cpp_constexpr >= 201304) \
|| (!defined(__cpp_constexpr) && MDSPAN_HAS_CXX_14) \
&& (!(defined(__INTEL_COMPILER) && __INTEL_COMPILER <= 1700))
# define _MDSPAN_USE_CONSTEXPR_14 1
# endif
#endif
#ifndef _MDSPAN_USE_INTEGER_SEQUENCE
# if defined(_MDSPAN_COMPILER_MSVC)
# if (defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304)
# define _MDSPAN_USE_INTEGER_SEQUENCE 1
# endif
# endif
#endif
#ifndef _MDSPAN_USE_INTEGER_SEQUENCE
# if (defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304) \
|| (!defined(__cpp_lib_integer_sequence) && MDSPAN_HAS_CXX_14) \
/* as far as I can tell, libc++ seems to think this is a C++11 feature... */ \
|| (defined(__GLIBCXX__) && __GLIBCXX__ > 20150422 && __GNUC__ < 5 && !defined(__INTEL_CXX11_MODE__))
// several compilers lie about integer_sequence working properly unless the C++14 standard is used
# define _MDSPAN_USE_INTEGER_SEQUENCE 1
# elif defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_14
// appleclang seems to be missing the __cpp_lib_... macros, but doesn't seem to lie about C++14 making
// integer_sequence work
# define _MDSPAN_USE_INTEGER_SEQUENCE 1
# endif
#endif
#ifndef _MDSPAN_USE_RETURN_TYPE_DEDUCTION
# if (defined(__cpp_return_type_deduction) && __cpp_return_type_deduction >= 201304) \
|| (!defined(__cpp_return_type_deduction) && MDSPAN_HAS_CXX_14)
# define _MDSPAN_USE_RETURN_TYPE_DEDUCTION 1
# endif
#endif
#ifndef _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
# if (!defined(__NVCC__) || (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 7)) && \
((defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201703) || \
(!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_17))
# define _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1
# endif
#endif
#ifndef _MDSPAN_USE_STANDARD_TRAIT_ALIASES
# if (defined(__cpp_lib_transformation_trait_aliases) && __cpp_lib_transformation_trait_aliases >= 201304) \
|| (!defined(__cpp_lib_transformation_trait_aliases) && MDSPAN_HAS_CXX_14)
# define _MDSPAN_USE_STANDARD_TRAIT_ALIASES 1
# elif defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_14
// appleclang seems to be missing the __cpp_lib_... macros, but doesn't seem to lie about C++14
# define _MDSPAN_USE_STANDARD_TRAIT_ALIASES 1
# endif
#endif
#ifndef _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND
# ifdef __GNUC__
# if __GNUC__ < 9
# define _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND 1
# endif
# endif
#endif
#ifndef MDSPAN_CONDITIONAL_EXPLICIT
# if MDSPAN_HAS_CXX_20
# define MDSPAN_CONDITIONAL_EXPLICIT(COND) explicit(COND)
# else
# define MDSPAN_CONDITIONAL_EXPLICIT(COND)
# endif
#endif
#ifndef MDSPAN_USE_BRACKET_OPERATOR
# if defined(__cpp_multidimensional_subscript)
# define MDSPAN_USE_BRACKET_OPERATOR 1
# else
# define MDSPAN_USE_BRACKET_OPERATOR 0
# endif
#endif
#ifndef MDSPAN_USE_PAREN_OPERATOR
# if !MDSPAN_USE_BRACKET_OPERATOR
# define MDSPAN_USE_PAREN_OPERATOR 1
# else
# define MDSPAN_USE_PAREN_OPERATOR 0
# endif
#endif
#if MDSPAN_USE_BRACKET_OPERATOR
# define __MDSPAN_OP(mds,...) mds[__VA_ARGS__]
// Corentins demo compiler for subscript chokes on empty [] call,
// though I believe the proposal supports it?
#ifdef MDSPAN_NO_EMPTY_BRACKET_OPERATOR
# define __MDSPAN_OP0(mds) mds.accessor().access(mds.data_handle(),0)
#else
# define __MDSPAN_OP0(mds) mds[]
#endif
# define __MDSPAN_OP1(mds, a) mds[a]
# define __MDSPAN_OP2(mds, a, b) mds[a,b]
# define __MDSPAN_OP3(mds, a, b, c) mds[a,b,c]
# define __MDSPAN_OP4(mds, a, b, c, d) mds[a,b,c,d]
# define __MDSPAN_OP5(mds, a, b, c, d, e) mds[a,b,c,d,e]
# define __MDSPAN_OP6(mds, a, b, c, d, e, f) mds[a,b,c,d,e,f]
#else
# define __MDSPAN_OP(mds,...) mds(__VA_ARGS__)
# define __MDSPAN_OP0(mds) mds()
# define __MDSPAN_OP1(mds, a) mds(a)
# define __MDSPAN_OP2(mds, a, b) mds(a,b)
# define __MDSPAN_OP3(mds, a, b, c) mds(a,b,c)
# define __MDSPAN_OP4(mds, a, b, c, d) mds(a,b,c,d)
# define __MDSPAN_OP5(mds, a, b, c, d, e) mds(a,b,c,d,e)
# define __MDSPAN_OP6(mds, a, b, c, d, e, f) mds(a,b,c,d,e,f)
#endif
//END_FILE_INCLUDE: /home/runner/work/mdspan/mdspan/include/experimental/__p0009_bits/config.hpp
#include <type_traits> // std::is_void
#ifndef _MDSPAN_HOST_DEVICE
# if defined(_MDSPAN_HAS_CUDA) || defined(_MDSPAN_HAS_HIP)
# define _MDSPAN_HOST_DEVICE __host__ __device__
# else
# define _MDSPAN_HOST_DEVICE
# endif
#endif
#ifndef MDSPAN_FORCE_INLINE_FUNCTION
# ifdef _MDSPAN_COMPILER_MSVC // Microsoft compilers
# define MDSPAN_FORCE_INLINE_FUNCTION __forceinline _MDSPAN_HOST_DEVICE
# else
# define MDSPAN_FORCE_INLINE_FUNCTION __attribute__((always_inline)) _MDSPAN_HOST_DEVICE
# endif
#endif
#ifndef MDSPAN_INLINE_FUNCTION
# define MDSPAN_INLINE_FUNCTION inline _MDSPAN_HOST_DEVICE
#endif
#ifndef MDSPAN_FUNCTION
# define MDSPAN_FUNCTION _MDSPAN_HOST_DEVICE
#endif
#ifdef _MDSPAN_HAS_HIP
# define MDSPAN_DEDUCTION_GUIDE _MDSPAN_HOST_DEVICE
#else
# define MDSPAN_DEDUCTION_GUIDE
#endif
// In CUDA defaulted functions do not need host device markup
#ifndef MDSPAN_INLINE_FUNCTION_DEFAULTED
# define MDSPAN_INLINE_FUNCTION_DEFAULTED
#endif
//==============================================================================
// <editor-fold desc="Preprocessor helpers"> {{{1
#define MDSPAN_PP_COUNT(...) \
_MDSPAN_PP_INTERNAL_EXPAND_ARGS_PRIVATE( \
_MDSPAN_PP_INTERNAL_ARGS_AUGMENTER(__VA_ARGS__) \
)
#define _MDSPAN_PP_INTERNAL_ARGS_AUGMENTER(...) unused, __VA_ARGS__
#define _MDSPAN_PP_INTERNAL_EXPAND(x) x
#define _MDSPAN_PP_INTERNAL_EXPAND_ARGS_PRIVATE(...) \
_MDSPAN_PP_INTERNAL_EXPAND( \
_MDSPAN_PP_INTERNAL_COUNT_PRIVATE( \
__VA_ARGS__, 69, 68, 67, 66, 65, 64, 63, 62, 61, \
60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, \
48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, \
36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, \
24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 \
) \
)
# define _MDSPAN_PP_INTERNAL_COUNT_PRIVATE( \
_1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, \
_10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \
_20, _21, _22, _23, _24, _25, _26, _27, _28, _29, \
_30, _31, _32, _33, _34, _35, _36, _37, _38, _39, \
_40, _41, _42, _43, _44, _45, _46, _47, _48, _49, \
_50, _51, _52, _53, _54, _55, _56, _57, _58, _59, \
_60, _61, _62, _63, _64, _65, _66, _67, _68, _69, \
_70, count, ...) count \
/**/
#define MDSPAN_PP_STRINGIFY_IMPL(x) #x
#define MDSPAN_PP_STRINGIFY(x) MDSPAN_PP_STRINGIFY_IMPL(x)
#define MDSPAN_PP_CAT_IMPL(x, y) x ## y
#define MDSPAN_PP_CAT(x, y) MDSPAN_PP_CAT_IMPL(x, y)
#define MDSPAN_PP_EVAL(X, ...) X(__VA_ARGS__)
#define MDSPAN_PP_REMOVE_PARENS_IMPL(...) __VA_ARGS__
#define MDSPAN_PP_REMOVE_PARENS(...) MDSPAN_PP_REMOVE_PARENS_IMPL __VA_ARGS__
#define MDSPAN_IMPL_STANDARD_NAMESPACE_STRING MDSPAN_PP_STRINGIFY(MDSPAN_IMPL_STANDARD_NAMESPACE)
#define MDSPAN_IMPL_PROPOSED_NAMESPACE_STRING MDSPAN_PP_STRINGIFY(MDSPAN_IMPL_STANDARD_NAMESPACE) "::" MDSPAN_PP_STRINGIFY(MDSPAN_IMPL_PROPOSED_NAMESPACE)
// </editor-fold> end Preprocessor helpers }}}1
//==============================================================================
//==============================================================================
// <editor-fold desc="Concept emulation"> {{{1
// These compatibility macros don't help with partial ordering, but they should do the trick
// for what we need to do with concepts in mdspan
#ifdef _MDSPAN_USE_CONCEPTS
# define MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) > requires REQ
# define MDSPAN_FUNCTION_REQUIRES(PAREN_PREQUALS, FNAME, PAREN_PARAMS, QUALS, REQ) \
MDSPAN_PP_REMOVE_PARENS(PAREN_PREQUALS) FNAME PAREN_PARAMS QUALS requires REQ \
/**/
#else
# define MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) , typename ::std::enable_if<(REQ), int>::type = 0>
# define MDSPAN_FUNCTION_REQUIRES(PAREN_PREQUALS, FNAME, PAREN_PARAMS, QUALS, REQ) \
MDSPAN_TEMPLATE_REQUIRES( \
class __function_requires_ignored=void, \
(std::is_void<__function_requires_ignored>::value && REQ) \
) MDSPAN_PP_REMOVE_PARENS(PAREN_PREQUALS) FNAME PAREN_PARAMS QUALS \
/**/
#endif
#if defined(_MDSPAN_COMPILER_MSVC) && (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL)
# define MDSPAN_TEMPLATE_REQUIRES(...) \
MDSPAN_PP_CAT( \
MDSPAN_PP_CAT(MDSPAN_TEMPLATE_REQUIRES_, MDSPAN_PP_COUNT(__VA_ARGS__))\
(__VA_ARGS__), \
) \
/**/
#else
# define MDSPAN_TEMPLATE_REQUIRES(...) \
MDSPAN_PP_EVAL( \
MDSPAN_PP_CAT(MDSPAN_TEMPLATE_REQUIRES_, MDSPAN_PP_COUNT(__VA_ARGS__)), \
__VA_ARGS__ \
) \
/**/
#endif
#define MDSPAN_TEMPLATE_REQUIRES_2(TP1, REQ) \
template<TP1 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_3(TP1, TP2, REQ) \
template<TP1, TP2 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_4(TP1, TP2, TP3, REQ) \
template<TP1, TP2, TP3 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_5(TP1, TP2, TP3, TP4, REQ) \
template<TP1, TP2, TP3, TP4 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_6(TP1, TP2, TP3, TP4, TP5, REQ) \
template<TP1, TP2, TP3, TP4, TP5 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_7(TP1, TP2, TP3, TP4, TP5, TP6, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_8(TP1, TP2, TP3, TP4, TP5, TP6, TP7, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_9(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_10(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_11(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_12(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_13(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_14(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_15(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_16(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_17(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_18(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16, TP17, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16, TP17 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_19(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16, TP17, TP18, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16, TP17, TP18 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_TEMPLATE_REQUIRES_20(TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16, TP17, TP18, TP19, REQ) \
template<TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10, TP11, TP12, TP13, TP14, TP15, TP16, TP17, TP18, TP19 \
MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \
/**/
#define MDSPAN_INSTANTIATE_ONLY_IF_USED \
MDSPAN_TEMPLATE_REQUIRES( \
class __instantiate_only_if_used_tparam=void, \
( _MDSPAN_TRAIT(std::is_void, __instantiate_only_if_used_tparam) ) \
) \
/**/
// </editor-fold> end Concept emulation }}}1
//==============================================================================
//==============================================================================
// <editor-fold desc="inline variables"> {{{1
#ifdef _MDSPAN_USE_INLINE_VARIABLES
# define _MDSPAN_INLINE_VARIABLE inline
#else
# define _MDSPAN_INLINE_VARIABLE
#endif
// </editor-fold> end inline variables }}}1
//==============================================================================
//==============================================================================
// <editor-fold desc="Return type deduction"> {{{1
#if _MDSPAN_USE_RETURN_TYPE_DEDUCTION
# define _MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \
auto MDSPAN_PP_REMOVE_PARENS(SIGNATURE) { return MDSPAN_PP_REMOVE_PARENS(BODY); }
# define _MDSPAN_DEDUCE_DECLTYPE_AUTO_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \
decltype(auto) MDSPAN_PP_REMOVE_PARENS(SIGNATURE) { return MDSPAN_PP_REMOVE_PARENS(BODY); }
#else
# define _MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \
auto MDSPAN_PP_REMOVE_PARENS(SIGNATURE) \
-> std::remove_cv_t<std::remove_reference_t<decltype(BODY)>> \
{ return MDSPAN_PP_REMOVE_PARENS(BODY); }
# define _MDSPAN_DEDUCE_DECLTYPE_AUTO_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \
auto MDSPAN_PP_REMOVE_PARENS(SIGNATURE) \
-> decltype(BODY) \
{ return MDSPAN_PP_REMOVE_PARENS(BODY); }
#endif
// </editor-fold> end Return type deduction }}}1
//==============================================================================
//==============================================================================
// <editor-fold desc="fold expressions"> {{{1
struct __mdspan_enable_fold_comma { };
#ifdef _MDSPAN_USE_FOLD_EXPRESSIONS
# define _MDSPAN_FOLD_AND(...) ((__VA_ARGS__) && ...)
# define _MDSPAN_FOLD_AND_TEMPLATE(...) ((__VA_ARGS__) && ...)
# define _MDSPAN_FOLD_OR(...) ((__VA_ARGS__) || ...)
# define _MDSPAN_FOLD_ASSIGN_LEFT(INIT, ...) (INIT = ... = (__VA_ARGS__))
# define _MDSPAN_FOLD_ASSIGN_RIGHT(PACK, ...) (PACK = ... = (__VA_ARGS__))
# define _MDSPAN_FOLD_TIMES_RIGHT(PACK, ...) (PACK * ... * (__VA_ARGS__))
# define _MDSPAN_FOLD_PLUS_RIGHT(PACK, ...) (PACK + ... + (__VA_ARGS__))
# define _MDSPAN_FOLD_COMMA(...) ((__VA_ARGS__), ...)
#else
namespace MDSPAN_IMPL_STANDARD_NAMESPACE {
namespace __fold_compatibility_impl {
// We could probably be more clever here, but at the (small) risk of losing some compiler understanding. For the
// few operations we need, it's not worth generalizing over the operation
#if _MDSPAN_USE_RETURN_TYPE_DEDUCTION
MDSPAN_FORCE_INLINE_FUNCTION
constexpr decltype(auto) __fold_right_and_impl() {
return true;
}
template <class Arg, class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr decltype(auto) __fold_right_and_impl(Arg&& arg, Args&&... args) {
return ((Arg&&)arg) && __fold_compatibility_impl::__fold_right_and_impl((Args&&)args...);
}
MDSPAN_FORCE_INLINE_FUNCTION
constexpr decltype(auto) __fold_right_or_impl() {
return false;
}
template <class Arg, class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_right_or_impl(Arg&& arg, Args&&... args) {
return ((Arg&&)arg) || __fold_compatibility_impl::__fold_right_or_impl((Args&&)args...);
}
template <class Arg1>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_left_assign_impl(Arg1&& arg1) {
return (Arg1&&)arg1;
}
template <class Arg1, class Arg2, class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_left_assign_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) {
return __fold_compatibility_impl::__fold_left_assign_impl((((Arg1&&)arg1) = ((Arg2&&)arg2)), (Args&&)args...);
}
template <class Arg1>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_right_assign_impl(Arg1&& arg1) {
return (Arg1&&)arg1;
}
template <class Arg1, class Arg2, class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_right_assign_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) {
return ((Arg1&&)arg1) = __fold_compatibility_impl::__fold_right_assign_impl((Arg2&&)arg2, (Args&&)args...);
}
template <class Arg1>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_right_plus_impl(Arg1&& arg1) {
return (Arg1&&)arg1;
}
template <class Arg1, class Arg2, class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_right_plus_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) {
return ((Arg1&&)arg1) + __fold_compatibility_impl::__fold_right_plus_impl((Arg2&&)arg2, (Args&&)args...);
}
template <class Arg1>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_right_times_impl(Arg1&& arg1) {
return (Arg1&&)arg1;
}
template <class Arg1, class Arg2, class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr auto __fold_right_times_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) {
return ((Arg1&&)arg1) * __fold_compatibility_impl::__fold_right_times_impl((Arg2&&)arg2, (Args&&)args...);
}
#else
//------------------------------------------------------------------------------
// <editor-fold desc="right and"> {{{2
template <class... Args>
struct __fold_right_and_impl_;
template <>
struct __fold_right_and_impl_<> {
using __rv = bool;
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl() noexcept {
return true;
}
};
template <class Arg, class... Args>
struct __fold_right_and_impl_<Arg, Args...> {
using __next_t = __fold_right_and_impl_<Args...>;
using __rv = decltype(std::declval<Arg>() && std::declval<typename __next_t::__rv>());
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg&& arg, Args&&... args) noexcept {
return ((Arg&&)arg) && __next_t::__impl((Args&&)args...);
}
};
template <class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr typename __fold_right_and_impl_<Args...>::__rv
__fold_right_and_impl(Args&&... args) {
return __fold_right_and_impl_<Args...>::__impl((Args&&)args...);
}
// </editor-fold> end right and }}}2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <editor-fold desc="right or"> {{{2
template <class... Args>
struct __fold_right_or_impl_;
template <>
struct __fold_right_or_impl_<> {
using __rv = bool;
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl() noexcept {
return false;
}
};
template <class Arg, class... Args>
struct __fold_right_or_impl_<Arg, Args...> {
using __next_t = __fold_right_or_impl_<Args...>;
using __rv = decltype(std::declval<Arg>() || std::declval<typename __next_t::__rv>());
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg&& arg, Args&&... args) noexcept {
return ((Arg&&)arg) || __next_t::__impl((Args&&)args...);
}
};
template <class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr typename __fold_right_or_impl_<Args...>::__rv
__fold_right_or_impl(Args&&... args) {
return __fold_right_or_impl_<Args...>::__impl((Args&&)args...);
}
// </editor-fold> end right or }}}2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <editor-fold desc="right plus"> {{{2
template <class... Args>
struct __fold_right_plus_impl_;
template <class Arg>
struct __fold_right_plus_impl_<Arg> {
using __rv = Arg&&;
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg&& arg) noexcept {
return (Arg&&)arg;
}
};
template <class Arg1, class Arg2, class... Args>
struct __fold_right_plus_impl_<Arg1, Arg2, Args...> {
using __next_t = __fold_right_plus_impl_<Arg2, Args...>;
using __rv = decltype(std::declval<Arg1>() + std::declval<typename __next_t::__rv>());
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept {
return ((Arg1&&)arg) + __next_t::__impl((Arg2&&)arg2, (Args&&)args...);
}
};
template <class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr typename __fold_right_plus_impl_<Args...>::__rv
__fold_right_plus_impl(Args&&... args) {
return __fold_right_plus_impl_<Args...>::__impl((Args&&)args...);
}
// </editor-fold> end right plus }}}2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <editor-fold desc="right times"> {{{2
template <class... Args>
struct __fold_right_times_impl_;
template <class Arg>
struct __fold_right_times_impl_<Arg> {
using __rv = Arg&&;
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg&& arg) noexcept {
return (Arg&&)arg;
}
};
template <class Arg1, class Arg2, class... Args>
struct __fold_right_times_impl_<Arg1, Arg2, Args...> {
using __next_t = __fold_right_times_impl_<Arg2, Args...>;
using __rv = decltype(std::declval<Arg1>() * std::declval<typename __next_t::__rv>());
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept {
return ((Arg1&&)arg) * __next_t::__impl((Arg2&&)arg2, (Args&&)args...);
}
};
template <class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr typename __fold_right_times_impl_<Args...>::__rv
__fold_right_times_impl(Args&&... args) {
return __fold_right_times_impl_<Args...>::__impl((Args&&)args...);
}
// </editor-fold> end right times }}}2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <editor-fold desc="right assign"> {{{2
template <class... Args>
struct __fold_right_assign_impl_;
template <class Arg>
struct __fold_right_assign_impl_<Arg> {
using __rv = Arg&&;
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg&& arg) noexcept {
return (Arg&&)arg;
}
};
template <class Arg1, class Arg2, class... Args>
struct __fold_right_assign_impl_<Arg1, Arg2, Args...> {
using __next_t = __fold_right_assign_impl_<Arg2, Args...>;
using __rv = decltype(std::declval<Arg1>() = std::declval<typename __next_t::__rv>());
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept {
return ((Arg1&&)arg) = __next_t::__impl((Arg2&&)arg2, (Args&&)args...);
}
};
template <class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr typename __fold_right_assign_impl_<Args...>::__rv
__fold_right_assign_impl(Args&&... args) {
return __fold_right_assign_impl_<Args...>::__impl((Args&&)args...);
}
// </editor-fold> end right assign }}}2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <editor-fold desc="left assign"> {{{2
template <class... Args>
struct __fold_left_assign_impl_;
template <class Arg>
struct __fold_left_assign_impl_<Arg> {
using __rv = Arg&&;
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg&& arg) noexcept {
return (Arg&&)arg;
}
};
template <class Arg1, class Arg2, class... Args>
struct __fold_left_assign_impl_<Arg1, Arg2, Args...> {
using __assign_result_t = decltype(std::declval<Arg1>() = std::declval<Arg2>());
using __next_t = __fold_left_assign_impl_<__assign_result_t, Args...>;
using __rv = typename __next_t::__rv;
MDSPAN_FORCE_INLINE_FUNCTION
static constexpr __rv
__impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept {
return __next_t::__impl(((Arg1&&)arg) = (Arg2&&)arg2, (Args&&)args...);
}
};
template <class... Args>
MDSPAN_FORCE_INLINE_FUNCTION
constexpr typename __fold_left_assign_impl_<Args...>::__rv
__fold_left_assign_impl(Args&&... args) {
return __fold_left_assign_impl_<Args...>::__impl((Args&&)args...);
}
// </editor-fold> end left assign }}}2
//------------------------------------------------------------------------------
#endif
template <class... Args>
constexpr __mdspan_enable_fold_comma __fold_comma_impl(Args&&... args) noexcept { return { }; }
template <bool... Bs>
struct __bools;
} // __fold_compatibility_impl
} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE
# define _MDSPAN_FOLD_AND(...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_and_impl((__VA_ARGS__)...)
# define _MDSPAN_FOLD_OR(...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_or_impl((__VA_ARGS__)...)
# define _MDSPAN_FOLD_ASSIGN_LEFT(INIT, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_left_assign_impl(INIT, (__VA_ARGS__)...)
# define _MDSPAN_FOLD_ASSIGN_RIGHT(PACK, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_assign_impl((PACK)..., __VA_ARGS__)
# define _MDSPAN_FOLD_TIMES_RIGHT(PACK, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_times_impl((PACK)..., __VA_ARGS__)
# define _MDSPAN_FOLD_PLUS_RIGHT(PACK, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_plus_impl((PACK)..., __VA_ARGS__)
# define _MDSPAN_FOLD_COMMA(...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_comma_impl((__VA_ARGS__)...)
# define _MDSPAN_FOLD_AND_TEMPLATE(...) \
_MDSPAN_TRAIT(std::is_same, __fold_compatibility_impl::__bools<(__VA_ARGS__)..., true>, __fold_compatibility_impl::__bools<true, (__VA_ARGS__)...>)
#endif
// </editor-fold> end fold expressions }}}1
//==============================================================================
//==============================================================================
// <editor-fold desc="Variable template compatibility"> {{{1
#if _MDSPAN_USE_VARIABLE_TEMPLATES
# define _MDSPAN_TRAIT(TRAIT, ...) TRAIT##_v<__VA_ARGS__>
#else
# define _MDSPAN_TRAIT(TRAIT, ...) TRAIT<__VA_ARGS__>::value
#endif
// </editor-fold> end Variable template compatibility }}}1
//==============================================================================
//==============================================================================
// <editor-fold desc="Pre-C++14 constexpr"> {{{1
#if _MDSPAN_USE_CONSTEXPR_14
# define _MDSPAN_CONSTEXPR_14 constexpr
// Workaround for a bug (I think?) in EDG frontends