-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstatic_views.hpp
More file actions
5248 lines (4414 loc) · 172 KB
/
Copy pathstatic_views.hpp
File metadata and controls
5248 lines (4414 loc) · 172 KB
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
// Copyright Tom Westerhout 2017-2018.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Include _all_ the headers
#ifndef BOOST_STATIC_VIEWS_STATIC_VIEWS_HPP
#define BOOST_STATIC_VIEWS_STATIC_VIEWS_HPP
#line 1 "static_views/algorithm_base.hpp"
// Copyright Tom Westerhout 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_STATIC_VIEWS_ALGORITHM_BASE_HPP
#define BOOST_STATIC_VIEWS_ALGORITHM_BASE_HPP
#line 1 "detail/config.hpp"
// Copyright Tom Westerhout 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_STATIC_VIEWS_DETAIL_CONFIG_HPP
#define BOOST_STATIC_VIEWS_DETAIL_CONFIG_HPP
#include <cassert>
#include <cstddef>
// Define the following macro if you want to use StaticViews as part
// of Boost.
//#define BOOST_STATIC_VIEWS_USE_BOOST
// Define the following macro if when using Doxygen.
//#define DOXYGEN_IN_HOUSE
/// \brief Chooses whether to ignore the actual noexcept-ness of
/// std::tuple implementstion and make some reasonable assumptions
/// instead.
#define BOOST_STATIC_VIEWS_NEGLECT_STD_TUPLE
// #define BOOST_DISABLE_CHECKS
// #define BOOST_STATIC_VIEWS_THROW_ON_FAILURES
// #define BOOST_STATIC_VIEWS_TERMINATE_ON_FAILURES
#if !defined(BOOST_STATIC_VIEWS_DISABLE_CHECKS) \
&& !defined(BOOST_STATIC_VIEWS_TERMINATE_ON_FAILURES) \
&& !defined(BOOST_STATIC_VIEWS_THROW_ON_FAILURES)
#define BOOST_STATIC_VIEWS_THROW_ON_FAILURES
#endif
// Easily turn off constexpr-ness to add some debug output, for
// example.
#define BOOST_STATIC_VIEWS_CONSTEXPR constexpr
/// \brief Disables all checks to achieve better performance
// #define BOOST_STATIC_VIEWS_DISABLE_CHECKS
// Boost.StaticViews namespace
#define BOOST_STATIC_VIEWS_NAMESPACE boost::static_views
#define BOOST_STATIC_VIEWS_BEGIN_NAMESPACE \
namespace boost { \
namespace static_views {
#define BOOST_STATIC_VIEWS_END_NAMESPACE \
} /* static_views */ \
} /* boost */
#define BOOST_STATIC_VIEWS_BUG_MESSAGE \
"Congratulations, you've found a bug in the StaticViews " \
"library! Please, be so kind to submit here " \
"https://github.com/BoostGSoC17/static-views/issues."
#if defined(BOOST_STATIC_VIEWS_USE_BOOST)
//////////////////////////////////////////////////////////////////////////////
// We have Boost at our disposal
//////////////////////////////////////////////////////////////////////////////
#include <boost/config.hpp>
// Check for compilers
#if defined(BOOST_CLANG)
#define BOOST_STATIC_VIEWS_CLANG \
(__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#elif defined(BOOST_GCC)
#define BOOST_STATIC_VIEWS_GCC BOOST_GCC
#elif defined(BOOST_MSVC)
#define BOOST_STATIC_VIEWS_MSVC BOOST_MSVC
#endif
// Force inlining
#define BOOST_STATIC_VIEWS_FORCEINLINE BOOST_FORCEINLINE
// Ask compiler not to inline
#define BOOST_STATIC_VIEWS_NOINLINE BOOST_NOINLINE
// Unused variable
#define BOOST_STATIC_VIEWS_UNUSED BOOST_ATTRIBUTE_UNUSED
// Noreturn
#define BOOST_STATIC_VIEWS_NORETURN BOOST_NORETURN
#else
//////////////////////////////////////////////////////////////////////////////
// No Boost --> do everything manually
//////////////////////////////////////////////////////////////////////////////
#if defined(__clang__)
// ===========================================================================
// We're being compiled with Clang
#define BOOST_STATIC_VIEWS_CLANG \
(__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#define BOOST_STATIC_VIEWS_FORCEINLINE inline __attribute__((__always_inline__))
#define BOOST_STATIC_VIEWS_NOINLINE __attribute__((__noinline__))
#define BOOST_STATIC_VIEWS_UNUSED __attribute__((__unused__))
#define BOOST_STATIC_VIEWS_NORETURN __attribute__((__noreturn__))
#define BOOST_STATIC_VIEWS_LIKELY(cond) __builtin_expect(!!(cond), 1)
#define BOOST_STATIC_VIEWS_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
#define BOOST_STATIC_VIEWS_ASSUME(cond) __builtin_assume(!!(cond))
#define BOOST_STATIC_VIEWS_CURRENT_FUNCTION __PRETTY_FUNCTION__
#define BOOST_STATIC_VIEWS_UNREACHABLE __builtin_unreachable()
#define BOOST_STATIC_VIEWS_PURE __attribute__((__pure__))
#elif defined(__GNUC__)
// ===========================================================================
// We're being compiled with GCC
#define BOOST_STATIC_VIEWS_GCC \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#define BOOST_STATIC_VIEWS_FORCEINLINE inline __attribute__((__always_inline__))
#define BOOST_STATIC_VIEWS_NOINLINE __attribute__((__noinline__))
#define BOOST_STATIC_VIEWS_UNUSED __attribute__((__unused__))
#define BOOST_STATIC_VIEWS_NORETURN __attribute__((__noreturn__))
#define BOOST_STATIC_VIEWS_LIKELY(cond) __builtin_expect(!!(cond), 1)
#define BOOST_STATIC_VIEWS_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
#define BOOST_STATIC_VIEWS_ASSUME(cond) \
((!!(cond)) ? static_cast<void>(0) : __builtin_unreachable())
#define BOOST_STATIC_VIEWS_CURRENT_FUNCTION __PRETTY_FUNCTION__
#define BOOST_STATIC_VIEWS_UNREACHABLE __builtin_unreachable()
#define BOOST_STATIC_VIEWS_PURE __attribute__((__pure__))
#elif defined(_MSC_VER)
// ===========================================================================
// We're being compiled with Microsoft Visual C++
#define BOOST_STATIC_VIEWS_MSVC _MSC_VER
#define BOOST_STATIC_VIEWS_FORCEINLINE inline __forceinline
#define BOOST_STATIC_VIEWS_NOINLINE
#define BOOST_STATIC_VIEWS_UNUSED
#define BOOST_STATIC_VIEWS_NORETURN __declspec(noreturn)
#define BOOST_STATIC_VIEWS_LIKELY(cond) (cond)
#define BOOST_STATIC_VIEWS_UNLIKELY(cond) (cond)
#define BOOST_STATIC_VIEWS_ASSUME(cond) __assume(!!(cond))
#define BOOST_STATIC_VIEWS_CURRENT_FUNCTION __FUNCTION__
#define BOOST_STATIC_VIEWS_UNREACHABLE __assume(0)
#define BOOST_STATIC_VIEWS_PURE
#else
// clang-format off
# error "Unsupported compiler. Please, submit a request to https://github.com/boostgsoc17/static-views/issues."
// clang-format on
// ===========================================================================
#endif
#endif // use Boost.Config
#define BOOST_STATIC_VIEWS_ISSUES_LINK \
"https://github.com/BoostGSoC17/static-views/issues"
#define BOOST_STATIC_VIEWS_DO_JOIN2(X, Y) X##Y
#define BOOST_STATIC_VIEWS_DO_JOIN1(X, Y) BOOST_STATIC_VIEWS_DO_JOIN2(X, Y)
#define BOOST_STATIC_VIEWS_JOIN(X, Y) BOOST_STATIC_VIEWS_DO_JOIN1(X, Y)
#define BOOST_STATIC_VIEWS_DO_STRINGIFY(X) #X
#define BOOST_STATIC_VIEWS_STRINGIFY(X) BOOST_STATIC_VIEWS_DO_STRINGIFY(X)
#if defined(DOXYGEN_IN_HOUSE)
// It's a bad idea to let Doxygen try deduce noexcept-ness.
#define BOOST_STATIC_VIEWS_NOEXCEPT_IF(...) noexcept(whenever possible) /**/
#else
#if defined(BOOST_STATIC_VIEWS_DISABLE_CHECKS) \
|| !defined(BOOST_STATIC_VIEWS_THROW_ON_FAILURES)
#define BOOST_STATIC_VIEWS_NOEXCEPT_CHECKS_IF(...) \
BOOST_STATIC_VIEWS_NOEXCEPT_IF(__VA_ARGS__)
#else
#define BOOST_STATIC_VIEWS_NOEXCEPT_CHECKS_IF(...)
#endif
#define BOOST_STATIC_VIEWS_NOEXCEPT_IF(...) noexcept(__VA_ARGS__)
#endif
#if defined(DOXYGEN_IN_HOUSE)
// Breathe does not handle decltype(auto) correctly, see
// https://github.com/michaeljones/breathe/issues/330. Hence, trick it
// into thinking that the function returns a plain auto insted.
#define BOOST_STATIC_VIEWS_DECLTYPE_AUTO auto
#else
#define BOOST_STATIC_VIEWS_DECLTYPE_AUTO decltype(auto)
#endif
// Automatic noexcept deduction + trailing return type + body creation
#define BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN(...) \
BOOST_STATIC_VIEWS_NOEXCEPT_IF(noexcept(__VA_ARGS__)) \
->decltype(__VA_ARGS__) \
{ \
return (__VA_ARGS__); \
} /* This is needed to make clang-format think we've just */ \
/* declared a function. It then doesn't that annoying */ /* extra \
indent. */ \
static_assert(true, "")
#line 235 "detail/config.hpp"
// Automatic noexcept deduction + body creation
#define BOOST_STATIC_VIEWS_AUTO_NOEXCEPT_RETURN(...) \
BOOST_STATIC_VIEWS_NOEXCEPT_IF(noexcept(__VA_ARGS__)) \
{ \
return (__VA_ARGS__); \
} \
static_assert(true, "")
BOOST_STATIC_VIEWS_BEGIN_NAMESPACE
/// \cond
// See
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
template <class T>
constexpr T _static_const{};
/// \endcond
BOOST_STATIC_VIEWS_END_NAMESPACE
#if defined(BOOST_STATIC_VIEWS_DISABLE_CHECKS)
#define BOOST_STATIC_VIEWS_EXPECT(cond, msg) BOOST_STATIC_VIEWS_ASSUME(cond)
#elif defined(BOOST_STATIC_VIEWS_THROW_ON_FAILURES)
#include <exception>
#include <stdexcept>
BOOST_STATIC_VIEWS_BEGIN_NAMESPACE
/// \brief Exception that is thrown when an assert failure is
/// encountered.
class assertion_failure : public virtual std::runtime_error {
public:
assertion_failure(char const* file, int const line, char const* cond)
: std::runtime_error{std::string{"Assertion failure in '"} + file
+ "' on line " + std::to_string(line)
+ ": condition " + cond + " not satisfied."}
{
}
};
BOOST_STATIC_VIEWS_END_NAMESPACE
#define BOOST_STATIC_VIEWS_EXPECT(cond, msg) \
((BOOST_STATIC_VIEWS_LIKELY(!!(cond))) \
? static_cast<void>(0) \
: (throw assertion_failure{ \
__FILE__, __LINE__, BOOST_STATIC_VIEWS_STRINGIFY(cond)}))
#elif defined(BOOST_STATIC_VIEWS_TERMINATE_ON_FAILURES)
#define BOOST_STATIC_VIEWS_EXPECT(cond, msg) \
((BOOST_STATIC_VIEWS_LIKELY(!!(cond))) ? static_cast<void>(0) \
: std::terminate())
#else
#error "No error handling policy chosen."
#endif
#if defined(DOXYGEN_IN_HOUSE)
#define BOOST_STATIC_VIEWS_INLINE_VARIABLE(type, name) \
inline namespace { \
constexpr auto const& name = \
::BOOST_STATIC_VIEWS_NAMESPACE::_static_const<type>; \
} /**/
#else
#define BOOST_STATIC_VIEWS_INLINE_VARIABLE(type, name) \
constexpr auto name = type{}; /**/
#endif
BOOST_STATIC_VIEWS_BEGIN_NAMESPACE
/// \brief Special value of that indicates that the size of a sequence
/// is unknown at compile-time.
constexpr std::ptrdiff_t dynamic_extent = -1;
BOOST_STATIC_VIEWS_END_NAMESPACE
#endif // BOOST_STATIC_VIEWS_DETAIL_CONFIG_HPP
#line 1 "detail/wrapper.hpp"
// Copyright Tom Westerhout 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Implementation of boost::static_views::make_wrapper.
#ifndef BOOST_STATIC_VIEWS_DETAIL_WRAPPER_HPP
#define BOOST_STATIC_VIEWS_DETAIL_WRAPPER_HPP
#include <type_traits>
#line 1 "../concepts.hpp"
// Copyright Tom Westerhout 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_STATIC_VIEWS_CONCEPTS_HPP
#define BOOST_STATIC_VIEWS_CONCEPTS_HPP
#line 1 "detail/utils.hpp"
// Copyright Tom Westerhout 2017-2018.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_STATIC_VIEWS_DETAIL_UTILS_HPP
#define BOOST_STATIC_VIEWS_DETAIL_UTILS_HPP
BOOST_STATIC_VIEWS_BEGIN_NAMESPACE
namespace detail {
constexpr auto all() noexcept -> bool { return true; }
template <class... Bools>
constexpr auto all(bool const x, Bools... xs) noexcept -> bool
{
return x && all(xs...);
}
constexpr auto any() noexcept -> bool { return false; }
template <class... Bools>
constexpr auto any(bool const x, Bools... xs) noexcept -> bool
{
return x || any(xs...);
}
} // namespace detail
BOOST_STATIC_VIEWS_END_NAMESPACE
#endif // BOOST_STATIC_VIEWS_DETAIL_UTILS_HPP
#line 1 "detail/invoke.hpp"
// Copyright Tom Westerhout 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Implementation of boost::static_views::invoke. It is a
// BOOST_STATIC_VIEWS_CONSTEXPR
// equivalent of std::invoke.
#ifndef BOOST_STATIC_VIEWS_DETAIL_INVOKE_HPP
#define BOOST_STATIC_VIEWS_DETAIL_INVOKE_HPP
#include <functional>
#include <type_traits>
BOOST_STATIC_VIEWS_BEGIN_NAMESPACE
namespace detail {
/// \brief Trait that determines whether `T` is a reference_wrapper.
template <class T>
struct is_reference_wrapper : std::false_type {
};
/// \cond
template <class T>
struct is_reference_wrapper<std::reference_wrapper<T>> : std::true_type {
};
/// \endcond
#line 55 "detail/invoke.hpp"
// clang-format off
template <class Any, class Pointer, class Object, class... Args>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_func_impl
( std::true_type /*is_base_of*/
, Any /*is_reference_wrapper*/
, Pointer f
, Object&& obj
, Args&&... args )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
(std::forward<Object>(obj).*f)(std::forward<Args>(args)...)
);
template <class Pointer, class Object, class... Args>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_func_impl
( std::false_type /*is_base_of*/
, std::true_type /*is_reference_wrapper*/
, Pointer f
, Object&& obj
, Args&&... args )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
(std::forward<Object>(obj).get().*f)(std::forward<Args>(args)...)
);
template <class Pointer, class Object, class... Args>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_func_impl
( std::false_type /*is_base_of*/
, std::false_type /*is_reference_wrapper*/
, Pointer f
, Object&& obj
, Args&&... args )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
((*std::forward<Object>(obj)).*f)(std::forward<Args>(args)...)
);
template <class Function, class T, class Object, class... Args>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_func
( Function T::*f
, Object&& obj
, Args&&... args )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
invoke_member_func_impl
( std::is_base_of<T, std::decay_t<Object>>{}
, is_reference_wrapper<std::decay_t<Object>>{}
, f
, std::forward<Object>(obj)
, std::forward<Args>(args)... )
);
template <class Any, class Pointer, class Object>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_data_impl
( std::true_type /*is_base_of*/
, Any /*is_reference_wrapper*/
, Pointer f
, Object&& obj )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
std::forward<Object>(obj).*f
);
template <class Pointer, class Object>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_data_impl
( std::false_type /*is_base_of*/
, std::true_type /*is_reference_wrapper*/
, Pointer f
, Object&& obj )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
std::forward<Object>(obj).get().*f
);
template <class Pointer, class Object>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_data_impl
( std::false_type /*is_base_of*/
, std::false_type /*is_reference_wrapper*/
, Pointer f
, Object&& obj )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
(*std::forward<Object>(obj)).*f
);
template <class Function, class T, class Object>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_member_data
( Function T::*f
, Object&& obj )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
invoke_member_data_impl
( std::is_base_of<T, std::decay_t<Object>>{}
, is_reference_wrapper<std::decay_t<Object>>{}
, f
, std::forward<Object>(obj) )
);
template <class Function, class... Args>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto invoke_nonmember
( Function&& f
, Args&&... args )
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
std::forward<Function>(f)(std::forward<Args>(args)... )
);
struct invoke_impl {
private:
template <class Function, class T, class Object,
class = std::enable_if_t<
std::is_member_object_pointer<Function T::*>::value>>
BOOST_STATIC_VIEWS_FORCEINLINE
static constexpr
auto call_impl(Function T::*f, Object&& obj)
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
invoke_member_data(f, std::forward<Object>(obj))
);
template <class Function, class T, class Object, class... Args,
class = std::enable_if_t<
std::is_member_function_pointer<Function T::*>::value>>
BOOST_STATIC_VIEWS_FORCEINLINE
static constexpr
auto call_impl(Function T::*f, Object&& obj, Args&&... args)
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
invoke_member_func(f, std::forward<Object>(obj),
std::forward<Args>(args)...)
);
template <class Function, class... Args,
class = std::enable_if_t<
!std::is_member_pointer<std::decay_t<Function>>::value>>
BOOST_STATIC_VIEWS_FORCEINLINE
static constexpr
auto call_impl(Function&& f, Args&&... args)
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
invoke_nonmember(
std::forward<Function>(f), std::forward<Args>(args)...)
);
public:
template <class Function, class... Args>
BOOST_STATIC_VIEWS_FORCEINLINE
constexpr
auto operator()(Function&& f, Args&&... args) const
BOOST_STATIC_VIEWS_DECLTYPE_NOEXCEPT_RETURN
(
call_impl(std::forward<Function>(f), std::forward<Args>(args)...)
);
};
// clang-format on
} // end namespace detail
BOOST_STATIC_VIEWS_INLINE_VARIABLE(detail::invoke_impl, invoke)
BOOST_STATIC_VIEWS_END_NAMESPACE
#endif // BOOST_STATIC_VIEWS_DETAIL_INVOKE_HPP
#line 12 "../concepts.hpp"
#include <type_traits>
BOOST_STATIC_VIEWS_BEGIN_NAMESPACE
/// \typedef void_t
/// \verbatim embed:rst:leading-slashes
/// It is an alias to :cpp:`std::void_t` if available. Otherwise it is
/// defined as:
///
/// .. code-block:: cpp
///
/// template <class...>
/// using void_t = void;
/// \endverbatim
#if defined(__cpp_lib_void_t) && __cpp_lib_void_t >= 201411
using std::void_t;
#else
template <class...>
using void_t = void;
#endif
#if defined(__has_include) && __has_include(<experimental/type_traits>)
BOOST_STATIC_VIEWS_END_NAMESPACE
#include <experimental/type_traits>
BOOST_STATIC_VIEWS_BEGIN_NAMESPACE
using nonesuch = std::experimental::nonesuch;
template <template <class...> class Op, class... Args>
using is_detected = std::experimental::is_detected<Op, Args...>;
template <template <class...> class Op, class... Args>
using detected_t = std::experimental::detected_t<Op, Args...>;
#else
/// \verbatim embed:rst:leading-slashes
/// NOP type. It is an alias to :cpp:`std::experimental::nonesuch` if
/// available. Otherwise it is defined as:
///
/// .. code-block:: cpp
///
/// struct nonesuch {
/// nonesuch() = delete;
/// nonesuch(nonesuch const&) = delete;
/// nonesuch(nonesuch&&) = delete;
/// nonesuch& operator=(nonesuch const&) = delete;
/// nonesuch& operator=(nonesuch&&) = delete;
/// };
/// \endverbatim
struct nonesuch {
nonesuch() = delete;
nonesuch(nonesuch const&) = delete;
nonesuch(nonesuch&&) = delete;
nonesuch& operator=(nonesuch const&) = delete;
nonesuch& operator=(nonesuch&&) = delete;
};
namespace detail {
// clang-format off
template < class Default
, class
, template <class...> class Op
, class... Args
>
struct detector {
using value_t = std::false_type;
using type = Default;
};
template < class Default
, template <class...> class Op
, class... Args
>
struct detector<Default, void_t<Op<Args...>>, Op, Args...> {
using value_t = std::true_type;
using type = Op<Args...>;
};
// clang-format on
} // namespace detail
/// \verbatim embed:rst:leading-slashes
/// An alias to :cpp:`std::experimental::is_detected` if
/// available. Otherwise it is implemented from scratch.
/// \endverbatim
template <template <class...> class Op, class... Args>
using is_detected =
typename detail::detector<nonesuch, void, Op, Args...>::value_t;
/// \verbatim embed:rst:leading-slashes
/// An alias to :cpp:`std::experimental::is_detected` if
/// available. Otherwise it is implemented from scratch.
/// \endverbatim
template <template <class...> class Op, class... Args>
using detected_t = typename detail::detector<nonesuch, void, Op, Args...>::type;
#endif
#if defined(__cpp_lib_experimental_invocation_type) \
&& __cpp_lib_experimental_invocation_type >= 201411
// #if defined(__has_include) && __has_include(<experimental/type_traits>)
template <class Function, class... Args>
using is_invocable = std::is_invocable<Function, Args...>;
template <class Function, class... Args>
using is_nothrow_invocable = std::is_nothrow_invocable<Function, Args...>;
template <class Return, class Function, class... Args>
using is_invocable_r = std::is_invocable_r<Return, Function, Args...>;
template <class Return, class Function, class... Args>
using is_nothrow_invocable_r =
std::is_nothrow_invocable_r<Return, Function, Args...>;
#else
namespace detail {
template <class Function, class... Args>
using invoke_t =
decltype(invoke(std::declval<Function>(), std::declval<Args>()...));
} // namespace detail
template <class Fn, class... Xs>
using is_invocable = is_detected<detail::invoke_t, Fn, Xs...>;
template <class Fn, class... Xs>
using is_nothrow_invocable = std::conditional_t<
detail::all(is_detected<detail::invoke_t, Fn, Xs...>::value,
noexcept(invoke(std::declval<Fn>(), std::declval<Xs>()...))),
std::true_type, std::false_type>;
template <class R, class Fn, class... Xs>
using is_invocable_r = std::conditional_t<
detail::all(is_invocable<Fn, Xs...>::value,
std::is_convertible<detected_t<detail::invoke_t, Fn, Xs...>, R>::value),
std::true_type, std::false_type>;
template <class R, class Fn, class... Xs>
using is_nothrow_invocable_r = std::conditional_t<
detail::all(is_nothrow_invocable<Fn, Xs...>::value,
std::is_convertible<detected_t<detail::invoke_t, Fn, Xs...>, R>::value),
std::true_type, std::false_type>;
#endif
#if defined(__cpp_concepts) && __cpp_concepts >= 201507
#define BOOST_STATIC_VIEWS_CONCEPTS
#endif
#if defined(BOOST_STATIC_VIEWS_CONCEPTS)
#define BOOST_STATIC_VIEWS_REQUIRES(...) > requires __VA_ARGS__
#else
#define BOOST_STATIC_VIEWS_REQUIRES(...) \
, class = std::enable_if_t<__VA_ARGS__>>
#endif
#if defined(__cpp_lib_is_swappable) && __cpp_lib_is_swappable >= 201603
// We have std::is_swappable, let's use it
using std::is_nothrow_swappable;
using std::is_nothrow_swappable_with;
using std::is_swappable;
using std::is_swappable_with;
#else
namespace detail {
namespace swap_adl {
using std::swap;
template <class T, class U>
using swap_t = decltype(swap(std::declval<T>(), std::declval<U>()));
template <class T, class U>
using is_swappable_with =
std::conditional_t<is_detected<swap_t, T, U>::value
&& is_detected<swap_t, U, T>::value,
std::true_type, std::false_type>;
template <class T, class U, class = void>
struct is_nothrow_swappable_with : std::false_type {
};
template <class T, class U>
struct is_nothrow_swappable_with<T, U,
std::enable_if_t<is_swappable_with<T, U>::value>>
: std::conditional_t<
noexcept(swap(std::declval<T>(), std::declval<U>()))
&& noexcept(swap(std::declval<U>(), std::declval<T>())),
std::true_type, std::false_type> {
};
} // namespace swap_adl
} // namespace detail
using detail::swap_adl::is_nothrow_swappable_with;
using detail::swap_adl::is_swappable_with;
template <class T>
using is_swappable = is_swappable_with<T&, T&>;
template <class T>
using is_nothrow_swappable = is_nothrow_swappable_with<T&, T&>;
#endif
#if defined(BOOST_STATIC_VIEWS_CONCEPTS)
#if defined(__has_include) && __has_include(<concepts>)
#include <concepts>
#elif defined(__has_include) && __has_include(<experimental/concepts>)
#include <experimental/concepts>
#else
template <class T, class U>
concept bool Same = std::is_same<T, U>::value;
template <class From, class To>
concept bool ConvertibleTo = std::is_convertible<From, To>::value&& requires(
From (&f)())
{
static_cast<To>(f());
};
template <class T>
concept bool Destructible = std::is_nothrow_destructible<T>::value;
template <class T, class... Args>
concept bool Constructible =
Destructible<T>&& std::is_constructible<T, Args...>::value;
template <class T>
concept bool MoveConstructible = Constructible<T, T>&& ConvertibleTo<T, T>;
template <class T, class Dummy>
concept bool _MoveConstructible = MoveConstructible<T>;
template <class T>
concept bool Swappable = is_swappable<T>::value;
#endif
#else
namespace detail {
template <class From, class To>
using funny_extra_test_in_convertible_t =
decltype(static_cast<To>(std::declval<From (&)()>()()));
} // namespace detail
template <class T, class U>
constexpr bool Same = std::is_same<T, U>::value;
template <class From, class To>
constexpr bool ConvertibleTo = std::is_convertible<From, To>::value&&
is_detected<detail::funny_extra_test_in_convertible_t, From, To>::value;
template <class T>
constexpr bool Destructible = std::is_nothrow_destructible<T>::value;
template <class T, class... Args>
constexpr bool Constructible =
Destructible<T>&& std::is_constructible<T, Args...>::value;
template <class T>
constexpr bool MoveConstructible = Constructible<T, T>&& ConvertibleTo<T, T>;
template <class T, class Dummy>
constexpr bool _MoveConstructible = MoveConstructible<T>;
template <class T>
constexpr bool Swappable = is_swappable<T>::value;
#endif
namespace detail {
template <class T, int = (T::extent(), 0)>
static constexpr auto has_extent_impl(int) noexcept -> std::true_type
{
return {};
}
template <class T>
static constexpr auto has_extent_impl(...) noexcept -> std::false_type
{
return {};
}
template <class T, class = void>
struct HasExtent : std::false_type {
};
template <class T>
struct HasExtent<T, std::enable_if_t<has_extent_impl<T>(int{})>>
: std::conditional_t<noexcept(T::extent())
&& (T::extent() >= 0
|| T::extent() == dynamic_extent),
std::true_type, std::false_type> {
};
template <class T>
using has_size_t = decltype(std::declval<T const&>().size());
template <class T>
using has_size_type_t = typename T::size_type;
template <class T, class = void>
struct HasSize : std::false_type {
};
template <class T>
struct HasSize<T, std::enable_if_t<is_detected<has_size_t, T>::value>>
: std::conditional_t<noexcept(std::declval<T const&>().size()),
std::true_type, std::false_type> {
};
template <class T>
using HasSizeWithType =
std::conditional_t<HasSize<T>::value
&& std::is_same<detected_t<has_size_t, T>,
detected_t<has_size_type_t, T>>::value,
std::true_type, std::false_type>;
template <class T, class IndexType>
using has_index_operator_t =
decltype(std::declval<T>()[std::declval<IndexType>()]);
template <class T, class IndexType>
using HasIndexOperator = is_detected<has_index_operator_t, T, IndexType>;
template <class T, class = void, class = void, class = void>
struct HasIndexOperatorWithType : std::false_type {
};
template <class T>
struct HasIndexOperatorWithType<T, void_t<typename T::index_type>,
void_t<typename T::reference>
>
: std::conditional_t<std::is_same<detected_t<has_index_operator_t, T&,
typename T::index_type>,
typename T::reference>::value
,
std::true_type, std::false_type> {
};
template <class T, class IndexType>
using has_unsafe_at_t =
decltype(std::declval<T>().unsafe_at(std::declval<IndexType>()));
template <class T, class IndexType>
using HasUnsafeAt = is_detected<has_unsafe_at_t, T, IndexType>;
template <class T, class = void, class = void, class = void>
struct HasUnsafeAtWithType : std::false_type {
};
template <class T>
struct HasUnsafeAtWithType<T, void_t<typename T::index_type>,
void_t<typename T::reference>
>
: std::conditional_t<
std::is_same<detected_t<has_unsafe_at_t, T&, typename T::index_type>,
typename T::reference>::value
,
std::true_type, std::false_type> {
};
template <class T, class IndexType>
using has_map_t = decltype(std::declval<T>().map(std::declval<IndexType>()));
template <class T>
using HasMap = is_detected<has_map_t, T const&, typename T::index_type>;
} // namespace detail
#if defined(BOOST_STATIC_VIEWS_CONCEPTS)
// clang-format off
template <class T>
concept bool HasExtent = requires() {
{ T::extent() } noexcept -> std::ptrdiff_t;
T::extent() >= 0 || T::extent() == dynamic_extent;
};
template <class T>
concept bool HasSize = requires(T const& xs) {
{ xs.size() } noexcept;
};
template <class T>
concept bool HasSizeWithType = requires(T const& xs) {
{ xs.size() } noexcept -> typename T::size_type;
};
// TODO: Still not sure whether Views should preserve const'ness. Not preserving
// const'ness makes my life a whole lot easier, so I'll stick to that for now :)
template <class T, class IndexType>
concept bool HasIndexOperator = requires(T& ref, T const& cref,