From 10da2cde64499ba382446f4ee88e31300b822091 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sat, 17 Oct 2020 20:10:58 -0400 Subject: [PATCH] add range-v3 lib --- linux/include/concepts/compare.hpp | 65 + linux/include/concepts/concepts.hpp | 1136 +++++ linux/include/concepts/swap.hpp | 340 ++ linux/include/concepts/type_traits.hpp | 379 ++ linux/include/meta/meta.hpp | 3973 +++++++++++++++++ linux/include/meta/meta_fwd.hpp | 360 ++ linux/include/range/v3/action.hpp | 42 + linux/include/range/v3/action/action.hpp | 248 + .../range/v3/action/adjacent_remove_if.hpp | 70 + linux/include/range/v3/action/concepts.hpp | 169 + linux/include/range/v3/action/drop.hpp | 67 + linux/include/range/v3/action/drop_while.hpp | 66 + linux/include/range/v3/action/erase.hpp | 82 + linux/include/range/v3/action/insert.hpp | 320 ++ linux/include/range/v3/action/join.hpp | 69 + linux/include/range/v3/action/push_back.hpp | 150 + linux/include/range/v3/action/push_front.hpp | 150 + linux/include/range/v3/action/remove.hpp | 76 + linux/include/range/v3/action/remove_if.hpp | 72 + linux/include/range/v3/action/reverse.hpp | 56 + linux/include/range/v3/action/shuffle.hpp | 86 + linux/include/range/v3/action/slice.hpp | 164 + linux/include/range/v3/action/sort.hpp | 66 + linux/include/range/v3/action/split.hpp | 109 + linux/include/range/v3/action/split_when.hpp | 92 + linux/include/range/v3/action/stable_sort.hpp | 66 + linux/include/range/v3/action/stride.hpp | 81 + linux/include/range/v3/action/take.hpp | 66 + linux/include/range/v3/action/take_while.hpp | 66 + linux/include/range/v3/action/transform.hpp | 67 + linux/include/range/v3/action/unique.hpp | 70 + .../range/v3/action/unstable_remove_if.hpp | 75 + linux/include/range/v3/algorithm.hpp | 105 + .../range/v3/algorithm/adjacent_find.hpp | 77 + .../range/v3/algorithm/adjacent_remove_if.hpp | 94 + linux/include/range/v3/algorithm/all_of.hpp | 71 + linux/include/range/v3/algorithm/any_of.hpp | 72 + .../range/v3/algorithm/aux_/equal_range_n.hpp | 92 + .../range/v3/algorithm/aux_/lower_bound_n.hpp | 83 + .../range/v3/algorithm/aux_/merge_n.hpp | 116 + .../v3/algorithm/aux_/merge_n_with_buffer.hpp | 75 + .../v3/algorithm/aux_/partition_point_n.hpp | 66 + .../v3/algorithm/aux_/sort_n_with_buffer.hpp | 74 + .../range/v3/algorithm/aux_/upper_bound_n.hpp | 88 + .../range/v3/algorithm/binary_search.hpp | 83 + linux/include/range/v3/algorithm/contains.hpp | 62 + linux/include/range/v3/algorithm/copy.hpp | 91 + .../range/v3/algorithm/copy_backward.hpp | 76 + linux/include/range/v3/algorithm/copy_if.hpp | 90 + linux/include/range/v3/algorithm/copy_n.hpp | 70 + linux/include/range/v3/algorithm/count.hpp | 74 + linux/include/range/v3/algorithm/count_if.hpp | 73 + .../include/range/v3/algorithm/ends_with.hpp | 102 + linux/include/range/v3/algorithm/equal.hpp | 179 + .../range/v3/algorithm/equal_range.hpp | 132 + linux/include/range/v3/algorithm/fill.hpp | 64 + linux/include/range/v3/algorithm/fill_n.hpp | 60 + linux/include/range/v3/algorithm/find.hpp | 80 + linux/include/range/v3/algorithm/find_end.hpp | 242 + .../range/v3/algorithm/find_first_of.hpp | 105 + linux/include/range/v3/algorithm/find_if.hpp | 81 + .../range/v3/algorithm/find_if_not.hpp | 82 + linux/include/range/v3/algorithm/for_each.hpp | 80 + .../include/range/v3/algorithm/for_each_n.hpp | 79 + linux/include/range/v3/algorithm/generate.hpp | 75 + .../include/range/v3/algorithm/generate_n.hpp | 68 + .../range/v3/algorithm/heap_algorithm.hpp | 440 ++ .../range/v3/algorithm/inplace_merge.hpp | 307 ++ .../range/v3/algorithm/is_partitioned.hpp | 82 + .../include/range/v3/algorithm/is_sorted.hpp | 79 + .../range/v3/algorithm/is_sorted_until.hpp | 91 + .../v3/algorithm/lexicographical_compare.hpp | 101 + .../range/v3/algorithm/lower_bound.hpp | 80 + linux/include/range/v3/algorithm/max.hpp | 93 + .../range/v3/algorithm/max_element.hpp | 74 + linux/include/range/v3/algorithm/merge.hpp | 138 + linux/include/range/v3/algorithm/min.hpp | 93 + .../range/v3/algorithm/min_element.hpp | 74 + linux/include/range/v3/algorithm/minmax.hpp | 133 + .../range/v3/algorithm/minmax_element.hpp | 114 + linux/include/range/v3/algorithm/mismatch.hpp | 178 + linux/include/range/v3/algorithm/move.hpp | 90 + .../range/v3/algorithm/move_backward.hpp | 77 + linux/include/range/v3/algorithm/none_of.hpp | 72 + .../range/v3/algorithm/nth_element.hpp | 335 ++ .../range/v3/algorithm/partial_sort.hpp | 89 + .../range/v3/algorithm/partial_sort_copy.hpp | 125 + .../include/range/v3/algorithm/partition.hpp | 139 + .../range/v3/algorithm/partition_copy.hpp | 111 + .../range/v3/algorithm/partition_point.hpp | 110 + .../range/v3/algorithm/permutation.hpp | 369 ++ linux/include/range/v3/algorithm/remove.hpp | 84 + .../range/v3/algorithm/remove_copy.hpp | 88 + .../range/v3/algorithm/remove_copy_if.hpp | 88 + .../include/range/v3/algorithm/remove_if.hpp | 83 + linux/include/range/v3/algorithm/replace.hpp | 76 + .../range/v3/algorithm/replace_copy.hpp | 104 + .../range/v3/algorithm/replace_copy_if.hpp | 97 + .../include/range/v3/algorithm/replace_if.hpp | 77 + .../range/v3/algorithm/result_types.hpp | 169 + linux/include/range/v3/algorithm/reverse.hpp | 93 + .../range/v3/algorithm/reverse_copy.hpp | 77 + linux/include/range/v3/algorithm/rotate.hpp | 236 + .../range/v3/algorithm/rotate_copy.hpp | 78 + linux/include/range/v3/algorithm/sample.hpp | 254 ++ linux/include/range/v3/algorithm/search.hpp | 231 + linux/include/range/v3/algorithm/search_n.hpp | 199 + .../range/v3/algorithm/set_algorithm.hpp | 454 ++ linux/include/range/v3/algorithm/shuffle.hpp | 92 + linux/include/range/v3/algorithm/sort.hpp | 234 + .../range/v3/algorithm/stable_partition.hpp | 333 ++ .../range/v3/algorithm/stable_sort.hpp | 238 + .../range/v3/algorithm/starts_with.hpp | 102 + .../range/v3/algorithm/swap_ranges.hpp | 99 + linux/include/range/v3/algorithm/tagspec.hpp | 52 + .../include/range/v3/algorithm/transform.hpp | 226 + linux/include/range/v3/algorithm/unique.hpp | 88 + .../range/v3/algorithm/unique_copy.hpp | 180 + .../range/v3/algorithm/unstable_remove_if.hpp | 88 + .../range/v3/algorithm/upper_bound.hpp | 78 + linux/include/range/v3/all.hpp | 27 + linux/include/range/v3/at.hpp | 23 + linux/include/range/v3/back.hpp | 22 + linux/include/range/v3/begin_end.hpp | 22 + linux/include/range/v3/compare.hpp | 45 + linux/include/range/v3/core.hpp | 33 + linux/include/range/v3/data.hpp | 22 + linux/include/range/v3/detail/adl_get.hpp | 146 + linux/include/range/v3/detail/config.hpp | 760 ++++ linux/include/range/v3/detail/epilogue.hpp | 22 + linux/include/range/v3/detail/prologue.hpp | 47 + .../include/range/v3/detail/range_access.hpp | 375 ++ .../range/v3/detail/satisfy_boost_range.hpp | 87 + linux/include/range/v3/detail/variant.hpp | 907 ++++ .../range/v3/detail/with_braced_init_args.hpp | 83 + linux/include/range/v3/distance.hpp | 24 + linux/include/range/v3/empty.hpp | 22 + .../v3/experimental/utility/generator.hpp | 369 ++ .../range/v3/experimental/view/shared.hpp | 135 + linux/include/range/v3/front.hpp | 22 + linux/include/range/v3/functional.hpp | 32 + .../range/v3/functional/arithmetic.hpp | 112 + linux/include/range/v3/functional/bind.hpp | 127 + .../include/range/v3/functional/bind_back.hpp | 192 + .../range/v3/functional/comparisons.hpp | 133 + linux/include/range/v3/functional/compose.hpp | 104 + .../include/range/v3/functional/concepts.hpp | 90 + .../include/range/v3/functional/identity.hpp | 48 + .../include/range/v3/functional/indirect.hpp | 100 + linux/include/range/v3/functional/invoke.hpp | 245 + linux/include/range/v3/functional/not_fn.hpp | 103 + linux/include/range/v3/functional/on.hpp | 74 + .../include/range/v3/functional/overload.hpp | 181 + .../include/range/v3/functional/pipeable.hpp | 131 + .../range/v3/functional/reference_wrapper.hpp | 187 + linux/include/range/v3/getlines.hpp | 22 + linux/include/range/v3/index.hpp | 23 + linux/include/range/v3/istream_range.hpp | 22 + linux/include/range/v3/iterator.hpp | 32 + linux/include/range/v3/iterator/access.hpp | 304 ++ .../range/v3/iterator/basic_iterator.hpp | 1081 +++++ .../range/v3/iterator/common_iterator.hpp | 483 ++ linux/include/range/v3/iterator/concepts.hpp | 873 ++++ .../range/v3/iterator/counted_iterator.hpp | 498 +++ .../range/v3/iterator/default_sentinel.hpp | 41 + linux/include/range/v3/iterator/diffmax_t.hpp | 483 ++ .../range/v3/iterator/insert_iterators.hpp | 219 + .../range/v3/iterator/move_iterators.hpp | 489 ++ .../include/range/v3/iterator/operations.hpp | 674 +++ .../range/v3/iterator/reverse_iterator.hpp | 157 + .../range/v3/iterator/stream_iterators.hpp | 227 + linux/include/range/v3/iterator/traits.hpp | 178 + .../v3/iterator/unreachable_sentinel.hpp | 74 + linux/include/range/v3/iterator_range.hpp | 335 ++ linux/include/range/v3/numeric.hpp | 20 + linux/include/range/v3/numeric/accumulate.hpp | 69 + .../range/v3/numeric/adjacent_difference.hpp | 156 + .../range/v3/numeric/inner_product.hpp | 160 + linux/include/range/v3/numeric/iota.hpp | 57 + .../include/range/v3/numeric/partial_sum.hpp | 174 + linux/include/range/v3/range.h | 3 + linux/include/range/v3/range.hpp | 25 + linux/include/range/v3/range/access.hpp | 691 +++ linux/include/range/v3/range/concepts.hpp | 306 ++ linux/include/range/v3/range/conversion.hpp | 541 +++ linux/include/range/v3/range/dangling.hpp | 96 + linux/include/range/v3/range/operations.hpp | 128 + linux/include/range/v3/range/primitives.hpp | 396 ++ linux/include/range/v3/range/traits.hpp | 142 + linux/include/range/v3/range_access.hpp | 23 + linux/include/range/v3/range_concepts.hpp | 22 + linux/include/range/v3/range_for.hpp | 50 + linux/include/range/v3/range_fwd.hpp | 931 ++++ linux/include/range/v3/range_traits.hpp | 22 + linux/include/range/v3/size.hpp | 22 + linux/include/range/v3/span.hpp | 22 + linux/include/range/v3/to_container.hpp | 22 + linux/include/range/v3/utility.hpp | 37 + linux/include/range/v3/utility/addressof.hpp | 80 + linux/include/range/v3/utility/any.hpp | 236 + .../range/v3/utility/associated_types.hpp | 23 + .../range/v3/utility/basic_iterator.hpp | 23 + linux/include/range/v3/utility/box.hpp | 380 ++ .../range/v3/utility/common_iterator.hpp | 23 + .../include/range/v3/utility/common_tuple.hpp | 827 ++++ .../include/range/v3/utility/common_type.hpp | 175 + .../range/v3/utility/compressed_pair.hpp | 232 + linux/include/range/v3/utility/concepts.hpp | 27 + linux/include/range/v3/utility/copy.hpp | 62 + .../range/v3/utility/counted_iterator.hpp | 22 + linux/include/range/v3/utility/dangling.hpp | 22 + linux/include/range/v3/utility/functional.hpp | 42 + linux/include/range/v3/utility/get.hpp | 73 + linux/include/range/v3/utility/in_place.hpp | 33 + linux/include/range/v3/utility/infinity.hpp | 75 + linux/include/range/v3/utility/invoke.hpp | 23 + linux/include/range/v3/utility/iterator.hpp | 31 + .../range/v3/utility/iterator_concepts.hpp | 23 + .../range/v3/utility/iterator_traits.hpp | 22 + linux/include/range/v3/utility/memory.hpp | 262 ++ linux/include/range/v3/utility/move.hpp | 65 + linux/include/range/v3/utility/nullptr_v.hpp | 40 + linux/include/range/v3/utility/optional.hpp | 992 ++++ .../range/v3/utility/polymorphic_cast.hpp | 46 + linux/include/range/v3/utility/random.hpp | 498 +++ linux/include/range/v3/utility/scope_exit.hpp | 97 + .../include/range/v3/utility/semiregular.hpp | 24 + .../range/v3/utility/semiregular_box.hpp | 344 ++ .../include/range/v3/utility/static_const.hpp | 32 + linux/include/range/v3/utility/swap.hpp | 55 + .../include/range/v3/utility/tagged_pair.hpp | 236 + .../include/range/v3/utility/tagged_tuple.hpp | 45 + .../range/v3/utility/tuple_algorithm.hpp | 196 + .../include/range/v3/utility/unreachable.hpp | 22 + linux/include/range/v3/utility/variant.hpp | 142 + linux/include/range/v3/version.hpp | 24 + linux/include/range/v3/view.hpp | 89 + linux/include/range/v3/view/adaptor.hpp | 587 +++ linux/include/range/v3/view/addressof.hpp | 66 + .../include/range/v3/view/adjacent_filter.hpp | 191 + .../range/v3/view/adjacent_remove_if.hpp | 191 + linux/include/range/v3/view/all.hpp | 128 + linux/include/range/v3/view/any_view.hpp | 697 +++ linux/include/range/v3/view/bounded.hpp | 22 + linux/include/range/v3/view/c_str.hpp | 96 + linux/include/range/v3/view/cache1.hpp | 208 + .../range/v3/view/cartesian_product.hpp | 504 +++ linux/include/range/v3/view/chunk.hpp | 477 ++ linux/include/range/v3/view/common.hpp | 244 + linux/include/range/v3/view/concat.hpp | 473 ++ linux/include/range/v3/view/const.hpp | 148 + linux/include/range/v3/view/counted.hpp | 131 + linux/include/range/v3/view/cycle.hpp | 252 ++ linux/include/range/v3/view/delimit.hpp | 135 + linux/include/range/v3/view/drop.hpp | 211 + linux/include/range/v3/view/drop_exactly.hpp | 192 + linux/include/range/v3/view/drop_last.hpp | 383 ++ linux/include/range/v3/view/drop_while.hpp | 170 + linux/include/range/v3/view/empty.hpp | 86 + linux/include/range/v3/view/enumerate.hpp | 118 + .../include/range/v3/view/exclusive_scan.hpp | 200 + linux/include/range/v3/view/facade.hpp | 141 + linux/include/range/v3/view/filter.hpp | 144 + linux/include/range/v3/view/for_each.hpp | 143 + linux/include/range/v3/view/generate.hpp | 121 + linux/include/range/v3/view/generate_n.hpp | 128 + linux/include/range/v3/view/getlines.hpp | 112 + linux/include/range/v3/view/group_by.hpp | 206 + linux/include/range/v3/view/indices.hpp | 84 + linux/include/range/v3/view/indirect.hpp | 163 + linux/include/range/v3/view/interface.hpp | 551 +++ linux/include/range/v3/view/intersperse.hpp | 268 ++ linux/include/range/v3/view/iota.hpp | 580 +++ linux/include/range/v3/view/istream.hpp | 124 + linux/include/range/v3/view/join.hpp | 658 +++ .../range/v3/view/linear_distribute.hpp | 119 + linux/include/range/v3/view/map.hpp | 151 + linux/include/range/v3/view/move.hpp | 141 + linux/include/range/v3/view/partial_sum.hpp | 235 + linux/include/range/v3/view/ref.hpp | 129 + linux/include/range/v3/view/remove.hpp | 113 + linux/include/range/v3/view/remove_if.hpp | 216 + linux/include/range/v3/view/repeat.hpp | 124 + linux/include/range/v3/view/repeat_n.hpp | 132 + linux/include/range/v3/view/replace.hpp | 144 + linux/include/range/v3/view/replace_if.hpp | 162 + linux/include/range/v3/view/reverse.hpp | 191 + linux/include/range/v3/view/sample.hpp | 271 ++ linux/include/range/v3/view/set_algorithm.hpp | 907 ++++ linux/include/range/v3/view/single.hpp | 144 + linux/include/range/v3/view/slice.hpp | 354 ++ linux/include/range/v3/view/sliding.hpp | 415 ++ linux/include/range/v3/view/span.hpp | 430 ++ linux/include/range/v3/view/split.hpp | 716 +++ linux/include/range/v3/view/split_when.hpp | 236 + linux/include/range/v3/view/stride.hpp | 350 ++ linux/include/range/v3/view/subrange.hpp | 487 ++ linux/include/range/v3/view/tail.hpp | 151 + linux/include/range/v3/view/take.hpp | 334 ++ linux/include/range/v3/view/take_exactly.hpp | 207 + linux/include/range/v3/view/take_last.hpp | 68 + linux/include/range/v3/view/take_while.hpp | 218 + linux/include/range/v3/view/tokenize.hpp | 213 + linux/include/range/v3/view/transform.hpp | 623 +++ linux/include/range/v3/view/trim.hpp | 165 + linux/include/range/v3/view/unbounded.hpp | 75 + linux/include/range/v3/view/unique.hpp | 74 + linux/include/range/v3/view/view.hpp | 285 ++ linux/include/range/v3/view/zip.hpp | 199 + linux/include/range/v3/view/zip_with.hpp | 460 ++ linux/include/range/v3/view_adaptor.hpp | 21 + linux/include/range/v3/view_facade.hpp | 21 + linux/include/range/v3/view_interface.hpp | 21 + linux/include/std/detail/associated_types.hpp | 304 ++ linux/include/std/iterator | 278 ++ 315 files changed, 60113 insertions(+) create mode 100644 linux/include/concepts/compare.hpp create mode 100644 linux/include/concepts/concepts.hpp create mode 100644 linux/include/concepts/swap.hpp create mode 100644 linux/include/concepts/type_traits.hpp create mode 100644 linux/include/meta/meta.hpp create mode 100644 linux/include/meta/meta_fwd.hpp create mode 100644 linux/include/range/v3/action.hpp create mode 100644 linux/include/range/v3/action/action.hpp create mode 100644 linux/include/range/v3/action/adjacent_remove_if.hpp create mode 100644 linux/include/range/v3/action/concepts.hpp create mode 100644 linux/include/range/v3/action/drop.hpp create mode 100644 linux/include/range/v3/action/drop_while.hpp create mode 100644 linux/include/range/v3/action/erase.hpp create mode 100644 linux/include/range/v3/action/insert.hpp create mode 100644 linux/include/range/v3/action/join.hpp create mode 100644 linux/include/range/v3/action/push_back.hpp create mode 100644 linux/include/range/v3/action/push_front.hpp create mode 100644 linux/include/range/v3/action/remove.hpp create mode 100644 linux/include/range/v3/action/remove_if.hpp create mode 100644 linux/include/range/v3/action/reverse.hpp create mode 100644 linux/include/range/v3/action/shuffle.hpp create mode 100644 linux/include/range/v3/action/slice.hpp create mode 100644 linux/include/range/v3/action/sort.hpp create mode 100644 linux/include/range/v3/action/split.hpp create mode 100644 linux/include/range/v3/action/split_when.hpp create mode 100644 linux/include/range/v3/action/stable_sort.hpp create mode 100644 linux/include/range/v3/action/stride.hpp create mode 100644 linux/include/range/v3/action/take.hpp create mode 100644 linux/include/range/v3/action/take_while.hpp create mode 100644 linux/include/range/v3/action/transform.hpp create mode 100644 linux/include/range/v3/action/unique.hpp create mode 100644 linux/include/range/v3/action/unstable_remove_if.hpp create mode 100644 linux/include/range/v3/algorithm.hpp create mode 100644 linux/include/range/v3/algorithm/adjacent_find.hpp create mode 100644 linux/include/range/v3/algorithm/adjacent_remove_if.hpp create mode 100644 linux/include/range/v3/algorithm/all_of.hpp create mode 100644 linux/include/range/v3/algorithm/any_of.hpp create mode 100644 linux/include/range/v3/algorithm/aux_/equal_range_n.hpp create mode 100644 linux/include/range/v3/algorithm/aux_/lower_bound_n.hpp create mode 100644 linux/include/range/v3/algorithm/aux_/merge_n.hpp create mode 100644 linux/include/range/v3/algorithm/aux_/merge_n_with_buffer.hpp create mode 100644 linux/include/range/v3/algorithm/aux_/partition_point_n.hpp create mode 100644 linux/include/range/v3/algorithm/aux_/sort_n_with_buffer.hpp create mode 100644 linux/include/range/v3/algorithm/aux_/upper_bound_n.hpp create mode 100644 linux/include/range/v3/algorithm/binary_search.hpp create mode 100644 linux/include/range/v3/algorithm/contains.hpp create mode 100644 linux/include/range/v3/algorithm/copy.hpp create mode 100644 linux/include/range/v3/algorithm/copy_backward.hpp create mode 100644 linux/include/range/v3/algorithm/copy_if.hpp create mode 100644 linux/include/range/v3/algorithm/copy_n.hpp create mode 100644 linux/include/range/v3/algorithm/count.hpp create mode 100644 linux/include/range/v3/algorithm/count_if.hpp create mode 100644 linux/include/range/v3/algorithm/ends_with.hpp create mode 100644 linux/include/range/v3/algorithm/equal.hpp create mode 100644 linux/include/range/v3/algorithm/equal_range.hpp create mode 100644 linux/include/range/v3/algorithm/fill.hpp create mode 100644 linux/include/range/v3/algorithm/fill_n.hpp create mode 100644 linux/include/range/v3/algorithm/find.hpp create mode 100644 linux/include/range/v3/algorithm/find_end.hpp create mode 100644 linux/include/range/v3/algorithm/find_first_of.hpp create mode 100644 linux/include/range/v3/algorithm/find_if.hpp create mode 100644 linux/include/range/v3/algorithm/find_if_not.hpp create mode 100644 linux/include/range/v3/algorithm/for_each.hpp create mode 100644 linux/include/range/v3/algorithm/for_each_n.hpp create mode 100644 linux/include/range/v3/algorithm/generate.hpp create mode 100644 linux/include/range/v3/algorithm/generate_n.hpp create mode 100644 linux/include/range/v3/algorithm/heap_algorithm.hpp create mode 100644 linux/include/range/v3/algorithm/inplace_merge.hpp create mode 100644 linux/include/range/v3/algorithm/is_partitioned.hpp create mode 100644 linux/include/range/v3/algorithm/is_sorted.hpp create mode 100644 linux/include/range/v3/algorithm/is_sorted_until.hpp create mode 100644 linux/include/range/v3/algorithm/lexicographical_compare.hpp create mode 100644 linux/include/range/v3/algorithm/lower_bound.hpp create mode 100644 linux/include/range/v3/algorithm/max.hpp create mode 100644 linux/include/range/v3/algorithm/max_element.hpp create mode 100644 linux/include/range/v3/algorithm/merge.hpp create mode 100644 linux/include/range/v3/algorithm/min.hpp create mode 100644 linux/include/range/v3/algorithm/min_element.hpp create mode 100644 linux/include/range/v3/algorithm/minmax.hpp create mode 100644 linux/include/range/v3/algorithm/minmax_element.hpp create mode 100644 linux/include/range/v3/algorithm/mismatch.hpp create mode 100644 linux/include/range/v3/algorithm/move.hpp create mode 100644 linux/include/range/v3/algorithm/move_backward.hpp create mode 100644 linux/include/range/v3/algorithm/none_of.hpp create mode 100644 linux/include/range/v3/algorithm/nth_element.hpp create mode 100644 linux/include/range/v3/algorithm/partial_sort.hpp create mode 100644 linux/include/range/v3/algorithm/partial_sort_copy.hpp create mode 100644 linux/include/range/v3/algorithm/partition.hpp create mode 100644 linux/include/range/v3/algorithm/partition_copy.hpp create mode 100644 linux/include/range/v3/algorithm/partition_point.hpp create mode 100644 linux/include/range/v3/algorithm/permutation.hpp create mode 100644 linux/include/range/v3/algorithm/remove.hpp create mode 100644 linux/include/range/v3/algorithm/remove_copy.hpp create mode 100644 linux/include/range/v3/algorithm/remove_copy_if.hpp create mode 100644 linux/include/range/v3/algorithm/remove_if.hpp create mode 100644 linux/include/range/v3/algorithm/replace.hpp create mode 100644 linux/include/range/v3/algorithm/replace_copy.hpp create mode 100644 linux/include/range/v3/algorithm/replace_copy_if.hpp create mode 100644 linux/include/range/v3/algorithm/replace_if.hpp create mode 100644 linux/include/range/v3/algorithm/result_types.hpp create mode 100644 linux/include/range/v3/algorithm/reverse.hpp create mode 100644 linux/include/range/v3/algorithm/reverse_copy.hpp create mode 100644 linux/include/range/v3/algorithm/rotate.hpp create mode 100644 linux/include/range/v3/algorithm/rotate_copy.hpp create mode 100644 linux/include/range/v3/algorithm/sample.hpp create mode 100644 linux/include/range/v3/algorithm/search.hpp create mode 100644 linux/include/range/v3/algorithm/search_n.hpp create mode 100644 linux/include/range/v3/algorithm/set_algorithm.hpp create mode 100644 linux/include/range/v3/algorithm/shuffle.hpp create mode 100644 linux/include/range/v3/algorithm/sort.hpp create mode 100644 linux/include/range/v3/algorithm/stable_partition.hpp create mode 100644 linux/include/range/v3/algorithm/stable_sort.hpp create mode 100644 linux/include/range/v3/algorithm/starts_with.hpp create mode 100644 linux/include/range/v3/algorithm/swap_ranges.hpp create mode 100644 linux/include/range/v3/algorithm/tagspec.hpp create mode 100644 linux/include/range/v3/algorithm/transform.hpp create mode 100644 linux/include/range/v3/algorithm/unique.hpp create mode 100644 linux/include/range/v3/algorithm/unique_copy.hpp create mode 100644 linux/include/range/v3/algorithm/unstable_remove_if.hpp create mode 100644 linux/include/range/v3/algorithm/upper_bound.hpp create mode 100644 linux/include/range/v3/all.hpp create mode 100644 linux/include/range/v3/at.hpp create mode 100644 linux/include/range/v3/back.hpp create mode 100644 linux/include/range/v3/begin_end.hpp create mode 100644 linux/include/range/v3/compare.hpp create mode 100644 linux/include/range/v3/core.hpp create mode 100644 linux/include/range/v3/data.hpp create mode 100644 linux/include/range/v3/detail/adl_get.hpp create mode 100644 linux/include/range/v3/detail/config.hpp create mode 100644 linux/include/range/v3/detail/epilogue.hpp create mode 100644 linux/include/range/v3/detail/prologue.hpp create mode 100644 linux/include/range/v3/detail/range_access.hpp create mode 100644 linux/include/range/v3/detail/satisfy_boost_range.hpp create mode 100644 linux/include/range/v3/detail/variant.hpp create mode 100644 linux/include/range/v3/detail/with_braced_init_args.hpp create mode 100644 linux/include/range/v3/distance.hpp create mode 100644 linux/include/range/v3/empty.hpp create mode 100644 linux/include/range/v3/experimental/utility/generator.hpp create mode 100644 linux/include/range/v3/experimental/view/shared.hpp create mode 100644 linux/include/range/v3/front.hpp create mode 100644 linux/include/range/v3/functional.hpp create mode 100644 linux/include/range/v3/functional/arithmetic.hpp create mode 100644 linux/include/range/v3/functional/bind.hpp create mode 100644 linux/include/range/v3/functional/bind_back.hpp create mode 100644 linux/include/range/v3/functional/comparisons.hpp create mode 100644 linux/include/range/v3/functional/compose.hpp create mode 100644 linux/include/range/v3/functional/concepts.hpp create mode 100644 linux/include/range/v3/functional/identity.hpp create mode 100644 linux/include/range/v3/functional/indirect.hpp create mode 100644 linux/include/range/v3/functional/invoke.hpp create mode 100644 linux/include/range/v3/functional/not_fn.hpp create mode 100644 linux/include/range/v3/functional/on.hpp create mode 100644 linux/include/range/v3/functional/overload.hpp create mode 100644 linux/include/range/v3/functional/pipeable.hpp create mode 100644 linux/include/range/v3/functional/reference_wrapper.hpp create mode 100644 linux/include/range/v3/getlines.hpp create mode 100644 linux/include/range/v3/index.hpp create mode 100644 linux/include/range/v3/istream_range.hpp create mode 100644 linux/include/range/v3/iterator.hpp create mode 100644 linux/include/range/v3/iterator/access.hpp create mode 100644 linux/include/range/v3/iterator/basic_iterator.hpp create mode 100644 linux/include/range/v3/iterator/common_iterator.hpp create mode 100644 linux/include/range/v3/iterator/concepts.hpp create mode 100644 linux/include/range/v3/iterator/counted_iterator.hpp create mode 100644 linux/include/range/v3/iterator/default_sentinel.hpp create mode 100644 linux/include/range/v3/iterator/diffmax_t.hpp create mode 100644 linux/include/range/v3/iterator/insert_iterators.hpp create mode 100644 linux/include/range/v3/iterator/move_iterators.hpp create mode 100644 linux/include/range/v3/iterator/operations.hpp create mode 100644 linux/include/range/v3/iterator/reverse_iterator.hpp create mode 100644 linux/include/range/v3/iterator/stream_iterators.hpp create mode 100644 linux/include/range/v3/iterator/traits.hpp create mode 100644 linux/include/range/v3/iterator/unreachable_sentinel.hpp create mode 100644 linux/include/range/v3/iterator_range.hpp create mode 100644 linux/include/range/v3/numeric.hpp create mode 100644 linux/include/range/v3/numeric/accumulate.hpp create mode 100644 linux/include/range/v3/numeric/adjacent_difference.hpp create mode 100644 linux/include/range/v3/numeric/inner_product.hpp create mode 100644 linux/include/range/v3/numeric/iota.hpp create mode 100644 linux/include/range/v3/numeric/partial_sum.hpp create mode 100644 linux/include/range/v3/range.h create mode 100644 linux/include/range/v3/range.hpp create mode 100644 linux/include/range/v3/range/access.hpp create mode 100644 linux/include/range/v3/range/concepts.hpp create mode 100644 linux/include/range/v3/range/conversion.hpp create mode 100644 linux/include/range/v3/range/dangling.hpp create mode 100644 linux/include/range/v3/range/operations.hpp create mode 100644 linux/include/range/v3/range/primitives.hpp create mode 100644 linux/include/range/v3/range/traits.hpp create mode 100644 linux/include/range/v3/range_access.hpp create mode 100644 linux/include/range/v3/range_concepts.hpp create mode 100644 linux/include/range/v3/range_for.hpp create mode 100644 linux/include/range/v3/range_fwd.hpp create mode 100644 linux/include/range/v3/range_traits.hpp create mode 100644 linux/include/range/v3/size.hpp create mode 100644 linux/include/range/v3/span.hpp create mode 100644 linux/include/range/v3/to_container.hpp create mode 100644 linux/include/range/v3/utility.hpp create mode 100644 linux/include/range/v3/utility/addressof.hpp create mode 100644 linux/include/range/v3/utility/any.hpp create mode 100644 linux/include/range/v3/utility/associated_types.hpp create mode 100644 linux/include/range/v3/utility/basic_iterator.hpp create mode 100644 linux/include/range/v3/utility/box.hpp create mode 100644 linux/include/range/v3/utility/common_iterator.hpp create mode 100644 linux/include/range/v3/utility/common_tuple.hpp create mode 100644 linux/include/range/v3/utility/common_type.hpp create mode 100644 linux/include/range/v3/utility/compressed_pair.hpp create mode 100644 linux/include/range/v3/utility/concepts.hpp create mode 100644 linux/include/range/v3/utility/copy.hpp create mode 100644 linux/include/range/v3/utility/counted_iterator.hpp create mode 100644 linux/include/range/v3/utility/dangling.hpp create mode 100644 linux/include/range/v3/utility/functional.hpp create mode 100644 linux/include/range/v3/utility/get.hpp create mode 100644 linux/include/range/v3/utility/in_place.hpp create mode 100644 linux/include/range/v3/utility/infinity.hpp create mode 100644 linux/include/range/v3/utility/invoke.hpp create mode 100644 linux/include/range/v3/utility/iterator.hpp create mode 100644 linux/include/range/v3/utility/iterator_concepts.hpp create mode 100644 linux/include/range/v3/utility/iterator_traits.hpp create mode 100644 linux/include/range/v3/utility/memory.hpp create mode 100644 linux/include/range/v3/utility/move.hpp create mode 100644 linux/include/range/v3/utility/nullptr_v.hpp create mode 100644 linux/include/range/v3/utility/optional.hpp create mode 100644 linux/include/range/v3/utility/polymorphic_cast.hpp create mode 100644 linux/include/range/v3/utility/random.hpp create mode 100644 linux/include/range/v3/utility/scope_exit.hpp create mode 100644 linux/include/range/v3/utility/semiregular.hpp create mode 100644 linux/include/range/v3/utility/semiregular_box.hpp create mode 100644 linux/include/range/v3/utility/static_const.hpp create mode 100644 linux/include/range/v3/utility/swap.hpp create mode 100644 linux/include/range/v3/utility/tagged_pair.hpp create mode 100644 linux/include/range/v3/utility/tagged_tuple.hpp create mode 100644 linux/include/range/v3/utility/tuple_algorithm.hpp create mode 100644 linux/include/range/v3/utility/unreachable.hpp create mode 100644 linux/include/range/v3/utility/variant.hpp create mode 100644 linux/include/range/v3/version.hpp create mode 100644 linux/include/range/v3/view.hpp create mode 100644 linux/include/range/v3/view/adaptor.hpp create mode 100644 linux/include/range/v3/view/addressof.hpp create mode 100644 linux/include/range/v3/view/adjacent_filter.hpp create mode 100644 linux/include/range/v3/view/adjacent_remove_if.hpp create mode 100644 linux/include/range/v3/view/all.hpp create mode 100644 linux/include/range/v3/view/any_view.hpp create mode 100644 linux/include/range/v3/view/bounded.hpp create mode 100644 linux/include/range/v3/view/c_str.hpp create mode 100644 linux/include/range/v3/view/cache1.hpp create mode 100644 linux/include/range/v3/view/cartesian_product.hpp create mode 100644 linux/include/range/v3/view/chunk.hpp create mode 100644 linux/include/range/v3/view/common.hpp create mode 100644 linux/include/range/v3/view/concat.hpp create mode 100644 linux/include/range/v3/view/const.hpp create mode 100644 linux/include/range/v3/view/counted.hpp create mode 100644 linux/include/range/v3/view/cycle.hpp create mode 100644 linux/include/range/v3/view/delimit.hpp create mode 100644 linux/include/range/v3/view/drop.hpp create mode 100644 linux/include/range/v3/view/drop_exactly.hpp create mode 100644 linux/include/range/v3/view/drop_last.hpp create mode 100644 linux/include/range/v3/view/drop_while.hpp create mode 100644 linux/include/range/v3/view/empty.hpp create mode 100644 linux/include/range/v3/view/enumerate.hpp create mode 100644 linux/include/range/v3/view/exclusive_scan.hpp create mode 100644 linux/include/range/v3/view/facade.hpp create mode 100644 linux/include/range/v3/view/filter.hpp create mode 100644 linux/include/range/v3/view/for_each.hpp create mode 100644 linux/include/range/v3/view/generate.hpp create mode 100644 linux/include/range/v3/view/generate_n.hpp create mode 100644 linux/include/range/v3/view/getlines.hpp create mode 100644 linux/include/range/v3/view/group_by.hpp create mode 100644 linux/include/range/v3/view/indices.hpp create mode 100644 linux/include/range/v3/view/indirect.hpp create mode 100644 linux/include/range/v3/view/interface.hpp create mode 100644 linux/include/range/v3/view/intersperse.hpp create mode 100644 linux/include/range/v3/view/iota.hpp create mode 100644 linux/include/range/v3/view/istream.hpp create mode 100644 linux/include/range/v3/view/join.hpp create mode 100644 linux/include/range/v3/view/linear_distribute.hpp create mode 100644 linux/include/range/v3/view/map.hpp create mode 100644 linux/include/range/v3/view/move.hpp create mode 100644 linux/include/range/v3/view/partial_sum.hpp create mode 100644 linux/include/range/v3/view/ref.hpp create mode 100644 linux/include/range/v3/view/remove.hpp create mode 100644 linux/include/range/v3/view/remove_if.hpp create mode 100644 linux/include/range/v3/view/repeat.hpp create mode 100644 linux/include/range/v3/view/repeat_n.hpp create mode 100644 linux/include/range/v3/view/replace.hpp create mode 100644 linux/include/range/v3/view/replace_if.hpp create mode 100644 linux/include/range/v3/view/reverse.hpp create mode 100644 linux/include/range/v3/view/sample.hpp create mode 100644 linux/include/range/v3/view/set_algorithm.hpp create mode 100644 linux/include/range/v3/view/single.hpp create mode 100644 linux/include/range/v3/view/slice.hpp create mode 100644 linux/include/range/v3/view/sliding.hpp create mode 100644 linux/include/range/v3/view/span.hpp create mode 100644 linux/include/range/v3/view/split.hpp create mode 100644 linux/include/range/v3/view/split_when.hpp create mode 100644 linux/include/range/v3/view/stride.hpp create mode 100644 linux/include/range/v3/view/subrange.hpp create mode 100644 linux/include/range/v3/view/tail.hpp create mode 100644 linux/include/range/v3/view/take.hpp create mode 100644 linux/include/range/v3/view/take_exactly.hpp create mode 100644 linux/include/range/v3/view/take_last.hpp create mode 100644 linux/include/range/v3/view/take_while.hpp create mode 100644 linux/include/range/v3/view/tokenize.hpp create mode 100644 linux/include/range/v3/view/transform.hpp create mode 100644 linux/include/range/v3/view/trim.hpp create mode 100644 linux/include/range/v3/view/unbounded.hpp create mode 100644 linux/include/range/v3/view/unique.hpp create mode 100644 linux/include/range/v3/view/view.hpp create mode 100644 linux/include/range/v3/view/zip.hpp create mode 100644 linux/include/range/v3/view/zip_with.hpp create mode 100644 linux/include/range/v3/view_adaptor.hpp create mode 100644 linux/include/range/v3/view_facade.hpp create mode 100644 linux/include/range/v3/view_interface.hpp create mode 100644 linux/include/std/detail/associated_types.hpp create mode 100644 linux/include/std/iterator diff --git a/linux/include/concepts/compare.hpp b/linux/include/concepts/compare.hpp new file mode 100644 index 000000000..4b0beb8d5 --- /dev/null +++ b/linux/include/concepts/compare.hpp @@ -0,0 +1,65 @@ +/// \file +// CPP, the Concepts PreProcessor library +// +// Copyright Eric Niebler 2018-present +// Copyright (c) 2020-present, Google LLC. +// +// Use, modification and distribution is subject to 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) +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// +// Project home: https://github.com/ericniebler/range-v3 +// +#ifndef CPP_COMPARE_HPP +#define CPP_COMPARE_HPP + +#if __cplusplus > 201703L && defined(__cpp_impl_three_way_comparison) && __has_include() + +#include +#include +#include + +// clang-format off + +namespace concepts +{ + // Note: concepts in this file can use C++20 concepts, since operator<=> isn't available in + // compilers that don't support core concepts. + namespace detail + { + template + concept compares_as = same_as, Cat>; + } // namespace detail + + inline namespace defs + { + template + concept three_way_comparable = + detail::weakly_equality_comparable_with_ && + detail::partially_ordered_with_ && + requires(detail::as_cref_t& a, detail::as_cref_t& b) { + { a <=> b } -> detail::compares_as; + }; + + template + concept three_way_comparable_with = + three_way_comparable && + three_way_comparable && + common_reference_with&, detail::as_cref_t&> && + three_way_comparable&, detail::as_cref_t&>> && + detail::partially_ordered_with_ && + requires(detail::as_cref_t& t, detail::as_cref_t& u) { + { t <=> u } -> detail::compares_as; + { u <=> t } -> detail::compares_as; + }; + } // inline namespace defs +} // namespace concepts + +// clang-format on + +#endif // __cplusplus +#endif // CPP_COMPARE_HPP diff --git a/linux/include/concepts/concepts.hpp b/linux/include/concepts/concepts.hpp new file mode 100644 index 000000000..a1c3182c1 --- /dev/null +++ b/linux/include/concepts/concepts.hpp @@ -0,0 +1,1136 @@ +/// \file +// CPP, the Concepts PreProcessor library +// +// Copyright Eric Niebler 2018-present +// Copyright (c) 2018-present, Facebook, Inc. +// Copyright (c) 2020-present, Google LLC. +// +// Use, modification and distribution is subject to 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) +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// +// Project home: https://github.com/ericniebler/range-v3 +// + +#ifndef CPP_CONCEPTS_HPP +#define CPP_CONCEPTS_HPP + +// clang-format off + +#include +#include +#include +#include +#include + +// Disable buggy clang compatibility warning about "requires" and "concept" being +// C++20 keywords. +// https://bugs.llvm.org/show_bug.cgi?id=43708 +#if defined(__clang__) && __cplusplus <= 201703L +#define CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ + CPP_DIAGNOSTIC_PUSH \ + CPP_DIAGNOSTIC_IGNORE_CPP2A_COMPAT + +#define CPP_PP_IGNORE_CXX2A_COMPAT_END \ + CPP_DIAGNOSTIC_POP + +#else +#define CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN +#define CPP_PP_IGNORE_CXX2A_COMPAT_END +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +#define CPP_WORKAROUND_MSVC_779763 // FATAL_UNREACHABLE calling constexpr function via template parameter +#define CPP_WORKAROUND_MSVC_784772 // Failure to invoke *explicit* bool conversion in a constant expression +#endif + +#if !defined(CPP_CXX_CONCEPTS) +#ifdef CPP_DOXYGEN_INVOKED +#define CPP_CXX_CONCEPTS 201800L +#elif defined(__cpp_concepts) && __cpp_concepts > 0 +// gcc-6 concepts are too buggy to use +#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 7 +#define CPP_CXX_CONCEPTS __cpp_concepts +#else +#define CPP_CXX_CONCEPTS 0L +#endif +#else +#define CPP_CXX_CONCEPTS 0L +#endif +#endif + +#define CPP_PP_CAT_(X, ...) X ## __VA_ARGS__ +#define CPP_PP_CAT(X, ...) CPP_PP_CAT_(X, __VA_ARGS__) + +#define CPP_PP_EVAL_(X, ARGS) X ARGS +#define CPP_PP_EVAL(X, ...) CPP_PP_EVAL_(X, (__VA_ARGS__)) + +#define CPP_PP_EVAL2_(X, ARGS) X ARGS +#define CPP_PP_EVAL2(X, ...) CPP_PP_EVAL2_(X, (__VA_ARGS__)) + +#define CPP_PP_EXPAND(...) __VA_ARGS__ +#define CPP_PP_EAT(...) + +#define CPP_PP_FIRST(LIST) CPP_PP_FIRST_ LIST +#define CPP_PP_FIRST_(...) __VA_ARGS__ CPP_PP_EAT + +#define CPP_PP_SECOND(LIST) CPP_PP_SECOND_ LIST +#define CPP_PP_SECOND_(...) CPP_PP_EXPAND + +#define CPP_PP_CHECK(...) CPP_PP_EXPAND(CPP_PP_CHECK_N(__VA_ARGS__, 0,)) +#define CPP_PP_CHECK_N(x, n, ...) n +#define CPP_PP_PROBE(x) x, 1, +#define CPP_PP_PROBE_N(x, n) x, n, + +#define CPP_PP_IS_PAREN(x) CPP_PP_CHECK(CPP_PP_IS_PAREN_PROBE x) +#define CPP_PP_IS_PAREN_PROBE(...) CPP_PP_PROBE(~) + +// CPP_CXX_VA_OPT +#ifndef CPP_CXX_VA_OPT +#if __cplusplus > 201703L +#define CPP_CXX_VA_OPT_(...) CPP_PP_CHECK(__VA_OPT__(,) 1) +#define CPP_CXX_VA_OPT CPP_CXX_VA_OPT_(~) +#else +#define CPP_CXX_VA_OPT 0 +#endif +#endif // CPP_CXX_VA_OPT + +// The final CPP_PP_EXPAND here is to avoid +// https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly +#define CPP_PP_COUNT(...) \ + CPP_PP_EXPAND(CPP_PP_COUNT_(__VA_ARGS__, \ + 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,)) + +#define CPP_PP_COUNT_( \ + _01, _02, _03, _04, _05, _06, _07, _08, _09, _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, N, ...) \ + N + +#define CPP_PP_IIF(BIT) CPP_PP_CAT_(CPP_PP_IIF_, BIT) +#define CPP_PP_IIF_0(TRUE, ...) __VA_ARGS__ +#define CPP_PP_IIF_1(TRUE, ...) TRUE + +#define CPP_PP_LPAREN ( +#define CPP_PP_RPAREN ) + +#define CPP_PP_NOT(BIT) CPP_PP_CAT_(CPP_PP_NOT_, BIT) +#define CPP_PP_NOT_0 1 +#define CPP_PP_NOT_1 0 + +#define CPP_PP_EMPTY() +#define CPP_PP_COMMA() , +#define CPP_PP_LBRACE() { +#define CPP_PP_RBRACE() } +#define CPP_PP_COMMA_IIF(X) \ + CPP_PP_IIF(X)(CPP_PP_EMPTY, CPP_PP_COMMA)() + +#define CPP_PP_FOR_EACH(M, ...) \ + CPP_PP_FOR_EACH_N(CPP_PP_COUNT(__VA_ARGS__), M, __VA_ARGS__) +#define CPP_PP_FOR_EACH_N(N, M, ...) \ + CPP_PP_CAT(CPP_PP_FOR_EACH_, N)(M, __VA_ARGS__) +#define CPP_PP_FOR_EACH_1(M, _1) \ + M(_1) +#define CPP_PP_FOR_EACH_2(M, _1, _2) \ + M(_1), M(_2) +#define CPP_PP_FOR_EACH_3(M, _1, _2, _3) \ + M(_1), M(_2), M(_3) +#define CPP_PP_FOR_EACH_4(M, _1, _2, _3, _4) \ + M(_1), M(_2), M(_3), M(_4) +#define CPP_PP_FOR_EACH_5(M, _1, _2, _3, _4, _5) \ + M(_1), M(_2), M(_3), M(_4), M(_5) +#define CPP_PP_FOR_EACH_6(M, _1, _2, _3, _4, _5, _6) \ + M(_1), M(_2), M(_3), M(_4), M(_5), M(_6) +#define CPP_PP_FOR_EACH_7(M, _1, _2, _3, _4, _5, _6, _7) \ + M(_1), M(_2), M(_3), M(_4), M(_5), M(_6), M(_7) +#define CPP_PP_FOR_EACH_8(M, _1, _2, _3, _4, _5, _6, _7, _8) \ + M(_1), M(_2), M(_3), M(_4), M(_5), M(_6), M(_7), M(_8) + +#define CPP_PP_PROBE_EMPTY_PROBE_CPP_PP_PROBE_EMPTY \ + CPP_PP_PROBE(~) + +#define CPP_PP_PROBE_EMPTY() +#define CPP_PP_IS_NOT_EMPTY(...) \ + CPP_PP_EVAL( \ + CPP_PP_CHECK, \ + CPP_PP_CAT( \ + CPP_PP_PROBE_EMPTY_PROBE_, \ + CPP_PP_PROBE_EMPTY __VA_ARGS__ ())) + +#if defined(_MSC_VER) && !defined(__clang__) && (__cplusplus <= 201703L) +#define CPP_BOOL(...) ::meta::bool_<__VA_ARGS__>::value +#define CPP_TRUE_FN \ + !::concepts::detail::instance_< \ + decltype(CPP_true_fn(::concepts::detail::xNil{}))> + +#define CPP_NOT(...) (!CPP_BOOL(__VA_ARGS__)) +#else +#define CPP_BOOL(...) __VA_ARGS__ +#define CPP_TRUE_FN CPP_true_fn(::concepts::detail::xNil{}) +#define CPP_NOT(...) (!(__VA_ARGS__)) +#endif + +#define CPP_assert(...) \ + static_assert(static_cast(__VA_ARGS__), \ + "Concept assertion failed : " #__VA_ARGS__) + +#define CPP_assert_msg static_assert + +#if CPP_CXX_CONCEPTS || defined(CPP_DOXYGEN_INVOKED) +#define CPP_concept META_CONCEPT +#define CPP_and && + +#else +#define CPP_concept CPP_INLINE_VAR constexpr bool +#define CPP_and CPP_and_sfinae + +#endif + +//////////////////////////////////////////////////////////////////////////////// +// CPP_template +// Usage: +// CPP_template(typename A, typename B) +// (requires Concept1 CPP_and Concept2) +// void foo(A a, B b) +// {} +#if CPP_CXX_CONCEPTS +#define CPP_template(...) template<__VA_ARGS__ CPP_TEMPLATE_AUX_ +#define CPP_template_def CPP_template +#define CPP_member +#define CPP_ctor(TYPE) TYPE CPP_CTOR_IMPL_1_ +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 10 +#define CPP_auto_member template +#else +#define CPP_auto_member +#endif + +#if defined(CPP_DOXYGEN_INVOKED) && CPP_DOXYGEN_INVOKED +/// INTERNAL ONLY +#define CPP_CTOR_IMPL_1_(...) (__VA_ARGS__) CPP_CTOR_IMPL_2_ +#define CPP_CTOR_IMPL_2_(...) __VA_ARGS__ ` +#else +/// INTERNAL ONLY +#define CPP_CTOR_IMPL_1_(...) (__VA_ARGS__) CPP_PP_EXPAND +#endif + +/// INTERNAL ONLY +#define CPP_TEMPLATE_AUX_(...) \ + > CPP_PP_CAT( \ + CPP_TEMPLATE_AUX_, \ + CPP_TEMPLATE_AUX_WHICH_(__VA_ARGS__,))(__VA_ARGS__) + +/// INTERNAL ONLY +#define CPP_TEMPLATE_AUX_WHICH_(FIRST, ...) \ + CPP_PP_EVAL( \ + CPP_PP_CHECK, \ + CPP_PP_CAT(CPP_TEMPLATE_PROBE_CONCEPT_, FIRST)) + +/// INTERNAL ONLY +#define CPP_TEMPLATE_PROBE_CONCEPT_concept \ + CPP_PP_PROBE(~) + +#if defined(CPP_DOXYGEN_INVOKED) && CPP_DOXYGEN_INVOKED +// A template with a requires clause. Turn the requires clause into +// a Doxygen precondition block. +/// INTERNAL ONLY +#define CPP_TEMPLATE_AUX_0(...) __VA_ARGS__` +#define requires requires ` + +#else +// A template with a requires clause +/// INTERNAL ONLY +#define CPP_TEMPLATE_AUX_0(...) __VA_ARGS__ +#endif + +// A concept definition +/// INTERNAL ONLY +#define CPP_TEMPLATE_AUX_1(DECL, ...) \ + CPP_concept CPP_CONCEPT_NAME_(DECL) = __VA_ARGS__ + +#define CPP_concept_ref(NAME, ...) \ + CPP_PP_CAT(NAME, _concept_)<__VA_ARGS__> + +#else // ^^^^ with concepts / without concepts vvvv + +#define CPP_template CPP_template_sfinae +#define CPP_template_def CPP_template_def_sfinae +#define CPP_member CPP_member_sfinae +#define CPP_auto_member CPP_member_sfinae +#define CPP_ctor CPP_ctor_sfinae +#define CPP_concept_ref(NAME, ...) \ + (1u == sizeof(CPP_PP_CAT(NAME, _concept_)( \ + (::concepts::detail::tag<__VA_ARGS__>*)nullptr))) + +/// INTERNAL ONLY +#define CPP_TEMPLATE_AUX_ CPP_TEMPLATE_SFINAE_AUX_ + +#endif + +#define CPP_template_sfinae(...) \ + CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ + template<__VA_ARGS__ CPP_TEMPLATE_SFINAE_AUX_ + +/// INTERNAL ONLY +#define CPP_TEMPLATE_SFINAE_PROBE_CONCEPT_concept \ + CPP_PP_PROBE(~) + +/// INTERNAL ONLY +#define CPP_TEMPLATE_SFINAE_AUX_WHICH_(FIRST, ...) \ + CPP_PP_EVAL( \ + CPP_PP_CHECK, \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_PROBE_CONCEPT_, FIRST)) + +/// INTERNAL ONLY +#define CPP_TEMPLATE_SFINAE_AUX_(...) \ + CPP_PP_CAT( \ + CPP_TEMPLATE_SFINAE_AUX_, \ + CPP_TEMPLATE_SFINAE_AUX_WHICH_(__VA_ARGS__,))(__VA_ARGS__) + +// A template with a requires clause +/// INTERNAL ONLY +#define CPP_TEMPLATE_SFINAE_AUX_0(...) , \ + bool CPP_true = true, \ + std::enable_if_t< \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && \ + CPP_BOOL(CPP_true), \ + int> = 0> \ + CPP_PP_IGNORE_CXX2A_COMPAT_END + +// A concept definition +/// INTERNAL ONLY +#define CPP_TEMPLATE_SFINAE_AUX_1(DECL, ...) , \ + bool CPP_true = true, \ + std::enable_if_t<__VA_ARGS__ && CPP_BOOL(CPP_true), int> = 0> \ + auto CPP_CONCEPT_NAME_(DECL)( \ + ::concepts::detail::tag*) \ + -> char(&)[1]; \ + auto CPP_CONCEPT_NAME_(DECL)(...) -> char(&)[2] \ + CPP_PP_IGNORE_CXX2A_COMPAT_END + +/// INTERNAL ONLY +#define CPP_CONCEPT_NAME_(DECL) \ + CPP_PP_EVAL( \ + CPP_PP_CAT, \ + CPP_PP_EVAL(CPP_PP_FIRST, CPP_EAT_CONCEPT_(DECL)), _concept_) + +/// INTERNAL ONLY +#define CPP_CONCEPT_PARAMS_(DECL) \ + CPP_PP_EVAL(CPP_PP_SECOND, CPP_EAT_CONCEPT_(DECL)) + +/// INTERNAL ONLY +#define CPP_EAT_CONCEPT_(DECL) \ + CPP_PP_CAT(CPP_EAT_CONCEPT_, DECL) + +/// INTERNAL ONLY +#define CPP_EAT_CONCEPT_concept + +#define CPP_and_sfinae \ + && CPP_BOOL(CPP_true), int> = 0, std::enable_if_t< + +#define CPP_template_def_sfinae(...) \ + template<__VA_ARGS__ CPP_TEMPLATE_DEF_SFINAE_AUX_ + +/// INTERNAL ONLY +#define CPP_TEMPLATE_DEF_SFINAE_AUX_(...) , \ + bool CPP_true, \ + std::enable_if_t< \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && \ + CPP_BOOL(CPP_true), \ + int>> + +#define CPP_and_sfinae_def \ + && CPP_BOOL(CPP_true), int>, std::enable_if_t< + +/// INTERNAL ONLY +#define CPP_TEMPLATE_SFINAE_AUX_3_requires + +#define CPP_member_sfinae \ + CPP_broken_friend_member + +#define CPP_ctor_sfinae(TYPE) \ + CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ + TYPE CPP_CTOR_SFINAE_IMPL_1_ + +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_IMPL_1_(...) \ + (__VA_ARGS__ \ + CPP_PP_COMMA_IIF( \ + CPP_PP_NOT(CPP_PP_IS_NOT_EMPTY(__VA_ARGS__))) \ + CPP_CTOR_SFINAE_REQUIRES + +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_PROBE_NOEXCEPT_noexcept \ + CPP_PP_PROBE(~) + +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_MAKE_PROBE(FIRST,...) \ + CPP_PP_CAT(CPP_CTOR_SFINAE_PROBE_NOEXCEPT_, FIRST) + +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_REQUIRES(...) \ + CPP_PP_CAT( \ + CPP_CTOR_SFINAE_REQUIRES_, \ + CPP_PP_EVAL( \ + CPP_PP_CHECK, \ + CPP_CTOR_SFINAE_MAKE_PROBE(__VA_ARGS__,)))(__VA_ARGS__) + +// No noexcept-clause: +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_REQUIRES_0(...) \ + std::enable_if_t< \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && CPP_TRUE_FN, \ + ::concepts::detail::Nil \ + > = {}) \ + CPP_PP_IGNORE_CXX2A_COMPAT_END + +// Yes noexcept-clause: +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_REQUIRES_1(...) \ + std::enable_if_t< \ + CPP_PP_EVAL(CPP_PP_CAT, \ + CPP_TEMPLATE_SFINAE_AUX_3_, \ + CPP_PP_CAT(CPP_CTOR_SFINAE_EAT_NOEXCEPT_, __VA_ARGS__)) && CPP_TRUE_FN,\ + ::concepts::detail::Nil \ + > = {}) \ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_CTOR_SFINAE_SHOW_NOEXCEPT_, __VA_ARGS__))) + +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_EAT_NOEXCEPT_noexcept(...) + +/// INTERNAL ONLY +#define CPP_CTOR_SFINAE_SHOW_NOEXCEPT_noexcept(...) \ + noexcept(__VA_ARGS__) \ + CPP_PP_IGNORE_CXX2A_COMPAT_END \ + CPP_PP_EAT CPP_PP_LPAREN + +#ifdef CPP_DOXYGEN_INVOKED +#define CPP_broken_friend_ret(...) \ + __VA_ARGS__ CPP_PP_EXPAND + +#else // ^^^ CPP_DOXYGEN_INVOKED / not CPP_DOXYGEN_INVOKED vvv +#define CPP_broken_friend_ret(...) \ + ::concepts::return_t< \ + __VA_ARGS__, \ + std::enable_if_t> + +#ifdef CPP_WORKAROUND_MSVC_779763 +#define CPP_broken_friend_member \ + template<::concepts::detail::CPP_true_t const &CPP_true_fn = \ + ::concepts::detail::CPP_true_fn_> + +#else // ^^^ workaround / no workaround vvv +#define CPP_broken_friend_member \ + template + +#endif // CPP_WORKAROUND_MSVC_779763 +#endif + +#if CPP_CXX_CONCEPTS +#define CPP_requires(NAME, REQS) \ +CPP_concept CPP_PP_CAT(NAME, _requires_) = \ + CPP_PP_CAT(CPP_REQUIRES_, REQS) + +#define CPP_requires_ref(NAME, ...) \ + CPP_PP_CAT(NAME, _requires_)<__VA_ARGS__> + +/// INTERNAL ONLY +#define CPP_REQUIRES_requires(...) \ + requires(__VA_ARGS__) CPP_REQUIRES_AUX_ + +/// INTERNAL ONLY +#define CPP_REQUIRES_AUX_(...) \ + { __VA_ARGS__; } + +#else +#define CPP_requires(NAME, REQS) \ + auto CPP_PP_CAT(NAME, _requires_test_) \ + CPP_REQUIRES_AUX_(NAME, CPP_REQUIRES_ ## REQS) + +#define CPP_requires_ref(NAME, ...) \ + (1u == sizeof(CPP_PP_CAT(NAME, _requires_)( \ + (::concepts::detail::tag<__VA_ARGS__>*)nullptr))) + +/// INTERNAL ONLY +#define CPP_REQUIRES_requires(...) \ + (__VA_ARGS__) -> decltype CPP_REQUIRES_RETURN_ + +/// INTERNAL ONLY +#define CPP_REQUIRES_RETURN_(...) (__VA_ARGS__, void()) {} + +/// INTERNAL ONLY +#define CPP_REQUIRES_AUX_(NAME, ...) \ + __VA_ARGS__ \ + template \ + auto CPP_PP_CAT(NAME, _requires_)( \ + ::concepts::detail::tag *, \ + decltype(&CPP_PP_CAT(NAME, _requires_test_)) = nullptr) \ + -> char(&)[1]; \ + auto CPP_PP_CAT(NAME, _requires_)(...) -> char(&)[2] + +#endif + +#if CPP_CXX_CONCEPTS + +#if defined(CPP_DOXYGEN_INVOKED) && CPP_DOXYGEN_INVOKED +#define CPP_ret(...) \ + __VA_ARGS__ CPP_RET_AUX_ +#define CPP_RET_AUX_(...) __VA_ARGS__ ` +#else +#define CPP_ret(...) \ + __VA_ARGS__ CPP_PP_EXPAND +#endif + +#else +#define CPP_ret \ + CPP_broken_friend_ret + +#endif + +//////////////////////////////////////////////////////////////////////////////// +// CPP_fun +#if CPP_CXX_CONCEPTS + +#if defined(CPP_DOXYGEN_INVOKED) && CPP_DOXYGEN_INVOKED +/// INTERNAL ONLY +#define CPP_FUN_IMPL_1_(...) \ + (__VA_ARGS__) \ + CPP_FUN_IMPL_2_ +#define CPP_FUN_IMPL_2_(...) \ + __VA_ARGS__ ` +#else +/// INTERNAL ONLY +#define CPP_FUN_IMPL_1_(...) \ + (__VA_ARGS__) \ + CPP_PP_EXPAND +#endif + +#define CPP_fun(X) X CPP_FUN_IMPL_1_ +#else +/// INTERNAL ONLY +#define CPP_FUN_IMPL_1_(...) \ + (__VA_ARGS__ \ + CPP_PP_COMMA_IIF( \ + CPP_PP_NOT(CPP_PP_IS_NOT_EMPTY(__VA_ARGS__))) \ + CPP_FUN_IMPL_REQUIRES + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_REQUIRES(...) \ + CPP_PP_EVAL2_( \ + CPP_FUN_IMPL_SELECT_CONST_, \ + (__VA_ARGS__,) \ + )(__VA_ARGS__) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_CONST_(MAYBE_CONST, ...) \ + CPP_PP_CAT(CPP_FUN_IMPL_SELECT_CONST_, \ + CPP_PP_EVAL(CPP_PP_CHECK, CPP_PP_CAT( \ + CPP_PP_PROBE_CONST_PROBE_, MAYBE_CONST))) + +/// INTERNAL ONLY +#define CPP_PP_PROBE_CONST_PROBE_const CPP_PP_PROBE(~) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_CONST_1(...) \ + CPP_PP_EVAL( \ + CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_, \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_CONST_, __VA_ARGS__),)( \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_CONST_, __VA_ARGS__)) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_(MAYBE_NOEXCEPT, ...) \ + CPP_PP_CAT(CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_, \ + CPP_PP_EVAL2(CPP_PP_CHECK, CPP_PP_CAT( \ + CPP_PP_PROBE_NOEXCEPT_PROBE_, MAYBE_NOEXCEPT))) + +/// INTERNAL ONLY +#define CPP_PP_PROBE_NOEXCEPT_PROBE_noexcept CPP_PP_PROBE(~) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_0(...) \ + std::enable_if_t< \ + CPP_PP_EVAL( \ + CPP_PP_CAT, \ + CPP_FUN_IMPL_EAT_REQUIRES_, \ + __VA_ARGS__) && CPP_TRUE_FN, \ + ::concepts::detail::Nil \ + > = {}) const \ + CPP_PP_IGNORE_CXX2A_COMPAT_END + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_1(...) \ + std::enable_if_t< \ + CPP_PP_EVAL( \ + CPP_PP_CAT, \ + CPP_FUN_IMPL_EAT_REQUIRES_, \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_NOEXCEPT_, __VA_ARGS__)) && CPP_TRUE_FN, \ + ::concepts::detail::Nil \ + > = {}) const \ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_FUN_IMPL_SHOW_NOEXCEPT_, __VA_ARGS__))) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_EAT_NOEXCEPT_noexcept(...) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SHOW_NOEXCEPT_noexcept(...) \ + noexcept(__VA_ARGS__) CPP_PP_IGNORE_CXX2A_COMPAT_END \ + CPP_PP_EAT CPP_PP_LPAREN + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_CONST_0(...) \ + CPP_PP_EVAL_( \ + CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_, \ + (__VA_ARGS__,) \ + )(__VA_ARGS__) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_(MAYBE_NOEXCEPT, ...) \ + CPP_PP_CAT(CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_, \ + CPP_PP_EVAL2(CPP_PP_CHECK, CPP_PP_CAT( \ + CPP_PP_PROBE_NOEXCEPT_PROBE_, MAYBE_NOEXCEPT))) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_0(...) \ + std::enable_if_t< \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_REQUIRES_, __VA_ARGS__) && CPP_TRUE_FN, \ + ::concepts::detail::Nil \ + > = {}) \ + CPP_PP_IGNORE_CXX2A_COMPAT_END + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_1(...) \ + std::enable_if_t< \ + CPP_PP_EVAL( \ + CPP_PP_CAT, \ + CPP_FUN_IMPL_EAT_REQUIRES_, \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_NOEXCEPT_, __VA_ARGS__) \ + ) && CPP_TRUE_FN, \ + ::concepts::detail::Nil \ + > = {}) \ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_FUN_IMPL_SHOW_NOEXCEPT_, __VA_ARGS__))) + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_EAT_CONST_const + +/// INTERNAL ONLY +#define CPP_FUN_IMPL_EAT_REQUIRES_requires + +//////////////////////////////////////////////////////////////////////////////// +// CPP_fun +// Usage: +// template +// void CPP_fun(foo)(A a, B b)([const]opt [noexcept(true)]opt +// requires Concept1 && Concept2) +// {} +// +// Note: This macro cannot be used when the last function argument is a +// parameter pack. +#define CPP_fun(X) CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN X CPP_FUN_IMPL_1_ +#endif + +//////////////////////////////////////////////////////////////////////////////// +// CPP_auto_fun +// Usage: +// template +// auto CPP_auto_fun(foo)(A a, B b)([const]opt [noexcept(cond)]opt)opt +// ( +// return a + b +// ) +#define CPP_auto_fun(X) X CPP_AUTO_FUN_IMPL_ + +/// INTERNAL ONLY +#define CPP_AUTO_FUN_IMPL_(...) (__VA_ARGS__) CPP_AUTO_FUN_RETURNS_ + +/// INTERNAL ONLY +#define CPP_AUTO_FUN_RETURNS_(...) \ + CPP_PP_EVAL2_( \ + CPP_AUTO_FUN_SELECT_RETURNS_, \ + (__VA_ARGS__,) \ + )(__VA_ARGS__) + +/// INTERNAL ONLY +#define CPP_AUTO_FUN_SELECT_RETURNS_(MAYBE_CONST, ...) \ + CPP_PP_CAT(CPP_AUTO_FUN_RETURNS_CONST_, \ + CPP_PP_EVAL(CPP_PP_CHECK, CPP_PP_CAT( \ + CPP_PP_PROBE_CONST_MUTABLE_PROBE_, MAYBE_CONST))) + +/// INTERNAL ONLY +#define CPP_PP_PROBE_CONST_MUTABLE_PROBE_const CPP_PP_PROBE_N(~, 1) + +/// INTERNAL ONLY +#define CPP_PP_PROBE_CONST_MUTABLE_PROBE_mutable CPP_PP_PROBE_N(~, 2) + +/// INTERNAL ONLY +#define CPP_PP_EAT_MUTABLE_mutable + +/// INTERNAL ONLY +#define CPP_AUTO_FUN_RETURNS_CONST_2(...) \ + CPP_PP_CAT(CPP_PP_EAT_MUTABLE_, __VA_ARGS__) CPP_AUTO_FUN_RETURNS_CONST_0 + +/// INTERNAL ONLY +#define CPP_AUTO_FUN_RETURNS_CONST_1(...) \ + __VA_ARGS__ CPP_AUTO_FUN_RETURNS_CONST_0 + +/// INTERNAL ONLY +#define CPP_AUTO_FUN_RETURNS_CONST_0(...) \ + CPP_PP_EVAL(CPP_AUTO_FUN_DECLTYPE_NOEXCEPT_, \ + CPP_PP_CAT(CPP_AUTO_FUN_RETURNS_, __VA_ARGS__)) + +/// INTERNAL ONLY +#define CPP_AUTO_FUN_RETURNS_return + +#ifdef __cpp_guaranteed_copy_elision +/// INTERNAL ONLY +#define CPP_AUTO_FUN_DECLTYPE_NOEXCEPT_(...) \ + noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ + { return (__VA_ARGS__); } + +#else +/// INTERNAL ONLY +#define CPP_AUTO_FUN_DECLTYPE_NOEXCEPT_(...) \ + noexcept(noexcept(decltype(__VA_ARGS__)(__VA_ARGS__))) -> \ + decltype(__VA_ARGS__) \ + { return (__VA_ARGS__); } + +#endif + +namespace concepts +{ + template + using bool_ = std::integral_constant; + +#if defined(__cpp_fold_expressions) && __cpp_fold_expressions >= 201603 + template + CPP_INLINE_VAR constexpr bool and_v = (Bs &&...); + + template + CPP_INLINE_VAR constexpr bool or_v = (Bs ||...); +#else + namespace detail + { + template + struct bools; + } // namespace detail + + template + CPP_INLINE_VAR constexpr bool and_v = + META_IS_SAME(detail::bools, detail::bools); + + template + CPP_INLINE_VAR constexpr bool or_v = + !META_IS_SAME(detail::bools, detail::bools); +#endif + + template + struct return_t_ + { + template + using invoke = T; + }; + + template + using return_t = meta::invoke, T>; + + namespace detail + { + struct ignore + { + template + constexpr ignore(Args&&...) noexcept {} + }; + + template + constexpr bool true_() + { + return true; + } + + template + struct tag; + + template + CPP_INLINE_VAR constexpr T instance_ = T{}; + + template + constexpr bool requires_() + { + return true; + } + + struct Nil + {}; + +#ifdef CPP_WORKAROUND_MSVC_779763 + enum class xNil {}; + + struct CPP_true_t + { + constexpr bool operator()(Nil) const noexcept + { + return true; + } + constexpr bool operator()(xNil) const noexcept + { + return true; + } + }; + + CPP_INLINE_VAR constexpr CPP_true_t CPP_true_fn_ {}; + + constexpr bool CPP_true_fn(xNil) + { + return true; + } +#else + using xNil = Nil; +#endif + + constexpr bool CPP_true_fn(Nil) + { + return true; + } + } // namespace detail + +#if defined(__clang__) || defined(_MSC_VER) + template + std::enable_if_t requires_() + {} +#else + template + CPP_INLINE_VAR constexpr std::enable_if_t requires_ = 0; +#endif + + inline namespace defs + { + //////////////////////////////////////////////////////////////////////// + // Utility concepts + //////////////////////////////////////////////////////////////////////// + + template + CPP_concept is_true = B; + + template + CPP_concept type = true; + + template class Trait, typename... Args> + CPP_concept satisfies = + static_cast(Trait::type::value); + + //////////////////////////////////////////////////////////////////////// + // Core language concepts + //////////////////////////////////////////////////////////////////////// + + template + CPP_concept same_as = + META_IS_SAME(A, B) && META_IS_SAME(B, A); + + /// \cond + template + CPP_concept not_same_as_ = + (!same_as, remove_cvref_t>); + + // Workaround bug in the Standard Library: + // From cannot be an incomplete class type despite that + // is_convertible should be equivalent to is_convertible + // in such a case. + template + CPP_concept implicitly_convertible_to = + std::is_convertible, To>::value; + + template + CPP_requires(explicitly_convertible_to_, + requires(From(*from)()) // + ( + static_cast(from()) + )); + template + CPP_concept explicitly_convertible_to = + CPP_requires_ref(concepts::explicitly_convertible_to_, From, To); + /// \endcond + + template + CPP_concept convertible_to = + implicitly_convertible_to && + explicitly_convertible_to; + + CPP_template(typename T, typename U)( + concept (derived_from_)(T, U), + convertible_to + ); + template + CPP_concept derived_from = + META_IS_BASE_OF(U, T) && + CPP_concept_ref(concepts::derived_from_, T, U); + + CPP_template(typename T, typename U)( + concept (common_reference_with_)(T, U), + same_as, common_reference_t> CPP_and + convertible_to> CPP_and + convertible_to> + ); + template + CPP_concept common_reference_with = + CPP_concept_ref(concepts::common_reference_with_, T, U); + + CPP_template(typename T, typename U)( + concept (common_with_)(T, U), + same_as, common_type_t> CPP_and + convertible_to> CPP_and + convertible_to> CPP_and + common_reference_with< + std::add_lvalue_reference_t, + std::add_lvalue_reference_t> CPP_and + common_reference_with< + std::add_lvalue_reference_t>, + common_reference_t< + std::add_lvalue_reference_t, + std::add_lvalue_reference_t>> + ); + template + CPP_concept common_with = + CPP_concept_ref(concepts::common_with_, T, U); + + template + CPP_concept integral = + std::is_integral::value; + + template + CPP_concept signed_integral = + integral && + std::is_signed::value; + + template + CPP_concept unsigned_integral = + integral && + !signed_integral; + + template + CPP_requires(assignable_from_, + requires(T t, U && u) // + ( + t = (U &&) u, + requires_> + )); + template + CPP_concept assignable_from = + std::is_lvalue_reference::value && + common_reference_with, detail::as_cref_t> && + CPP_requires_ref(defs::assignable_from_, T, U); + + template + CPP_requires(swappable_, + requires(T & t, T & u) // + ( + concepts::swap(t, u) + )); + template + CPP_concept swappable = + CPP_requires_ref(defs::swappable_, T); + + template + CPP_requires(swappable_with_, + requires(T && t, U && u) // + ( + concepts::swap((T &&) t, (T &&) t), + concepts::swap((U &&) u, (U &&) u), + concepts::swap((U &&) u, (T &&) t), + concepts::swap((T &&) t, (U &&) u) + )); + template + CPP_concept swappable_with = + common_reference_with, detail::as_cref_t> && + CPP_requires_ref(defs::swappable_with_, T, U); + + } // inline namespace defs + + namespace detail + { + template + CPP_concept boolean_testable_impl_ = convertible_to; + + template + CPP_requires(boolean_testable_frag_, + requires(T && t) // + ( + !(T&&) t, + concepts::requires_> + )); + + template + CPP_concept boolean_testable_ = + CPP_requires_ref(boolean_testable_frag_, T) && + boolean_testable_impl_; + + CPP_DIAGNOSTIC_PUSH + CPP_DIAGNOSTIC_IGNORE_FLOAT_EQUAL + + template + CPP_requires(weakly_equality_comparable_with_frag_, + requires(detail::as_cref_t t, detail::as_cref_t u) // + ( + concepts::requires_>, + concepts::requires_>, + concepts::requires_>, + concepts::requires_> + )); + template + CPP_concept weakly_equality_comparable_with_ = + CPP_requires_ref(weakly_equality_comparable_with_frag_, T, U); + + template + CPP_requires(partially_ordered_with_frag_, + requires(detail::as_cref_t& t, detail::as_cref_t& u) // + ( + concepts::requires_>, + concepts::requires_ u)>>, + concepts::requires_>, + concepts::requires_= u)>>, + concepts::requires_>, + concepts::requires_ t)>>, + concepts::requires_>, + concepts::requires_= t)>> + )); + template + CPP_concept partially_ordered_with_ = + CPP_requires_ref(partially_ordered_with_frag_, T, U); + + CPP_DIAGNOSTIC_POP + } // namespace detail + + inline namespace defs + { + //////////////////////////////////////////////////////////////////////// + // Comparison concepts + //////////////////////////////////////////////////////////////////////// + + template + CPP_concept equality_comparable = + detail::weakly_equality_comparable_with_; + + CPP_template(typename T, typename U)( + concept (equality_comparable_with_)(T, U), + equality_comparable< + common_reference_t, detail::as_cref_t>> + ); + template + CPP_concept equality_comparable_with = + equality_comparable && + equality_comparable && + detail::weakly_equality_comparable_with_ && + common_reference_with, detail::as_cref_t> && + CPP_concept_ref(concepts::equality_comparable_with_, T, U); + + template + CPP_concept totally_ordered = + equality_comparable && + detail::partially_ordered_with_; + + CPP_template(typename T, typename U)( + concept (totally_ordered_with_)(T, U), + totally_ordered< + common_reference_t< + detail::as_cref_t, + detail::as_cref_t>> CPP_and + detail::partially_ordered_with_); + + template + CPP_concept totally_ordered_with = + totally_ordered && + totally_ordered && + equality_comparable_with && + CPP_concept_ref(concepts::totally_ordered_with_, T, U); + + //////////////////////////////////////////////////////////////////////// + // Object concepts + //////////////////////////////////////////////////////////////////////// + + template + CPP_concept destructible = + std::is_nothrow_destructible::value; + + template + CPP_concept constructible_from = + destructible && + META_IS_CONSTRUCTIBLE(T, Args...); + + template + CPP_concept default_constructible = + constructible_from; + + template + CPP_concept move_constructible = + constructible_from && + convertible_to; + + CPP_template(typename T)( + concept (copy_constructible_)(T), + constructible_from && + constructible_from && + constructible_from && + convertible_to && + convertible_to && + convertible_to); + template + CPP_concept copy_constructible = + move_constructible && + CPP_concept_ref(concepts::copy_constructible_, T); + + CPP_template(typename T)( + concept (move_assignable_)(T), + assignable_from + ); + template + CPP_concept movable = + std::is_object::value && + move_constructible && + CPP_concept_ref(concepts::move_assignable_, T) && + swappable; + + CPP_template(typename T)( + concept (copy_assignable_)(T), + assignable_from + ); + template + CPP_concept copyable = + copy_constructible && + movable && + CPP_concept_ref(concepts::copy_assignable_, T); + + template + CPP_concept semiregular = + copyable && + default_constructible; + // Axiom: copies are independent. See Fundamentals of Generic + // Programming http://www.stepanovpapers.com/DeSt98.pdf + + template + CPP_concept regular = + semiregular && + equality_comparable; + + } // inline namespace defs +} // namespace concepts + +#endif // RANGES_V3_UTILITY_CONCEPTS_HPP diff --git a/linux/include/concepts/swap.hpp b/linux/include/concepts/swap.hpp new file mode 100644 index 000000000..dd7086411 --- /dev/null +++ b/linux/include/concepts/swap.hpp @@ -0,0 +1,340 @@ +/// \file +// Concepts library +// +// Copyright Eric Niebler 2013-present +// +// Use, modification and distribution is subject to 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) +// +// Project home: https://github.com/ericniebler/range-v3 + +#ifndef CPP_SWAP_HPP +#define CPP_SWAP_HPP + +#include +#include +#include +#include + +// Note: constexpr implies inline, to retain the same visibility +// C++14 constexpr functions are inline in C++11 +#if (defined(__cpp_constexpr) && __cpp_constexpr >= 201304L) ||\ + (!defined(__cpp_constexpr) && __cplusplus >= 201402L) +#define CPP_CXX14_CONSTEXPR constexpr +#else +#define CPP_CXX14_CONSTEXPR inline +#endif + +#ifndef CPP_CXX_INLINE_VARIABLES +#ifdef __cpp_inline_variables // TODO: fix this if SD-6 picks another name +#define CPP_CXX_INLINE_VARIABLES __cpp_inline_variables +// TODO: remove once clang defines __cpp_inline_variables (or equivalent) +#elif defined(__clang__) && \ + (__clang_major__ > 3 || __clang_major__ == 3 && __clang_minor__ == 9) && \ + __cplusplus > 201402L +#define CPP_CXX_INLINE_VARIABLES 201606L +#else +#define CPP_CXX_INLINE_VARIABLES __cplusplus +#endif // __cpp_inline_variables +#endif // CPP_CXX_INLINE_VARIABLES + +#if defined(_MSC_VER) && !defined(__clang__) +#if _MSC_VER < 1926 +#define CPP_WORKAROUND_MSVC_895622 // Error when phase 1 name binding finds only deleted function +#endif // _MSC_VER < 1926 +#endif // MSVC + +#if CPP_CXX_INLINE_VARIABLES < 201606L +#define CPP_INLINE_VAR +#define CPP_INLINE_VARIABLE(type, name) \ + inline namespace \ + { \ + constexpr auto &name = ::concepts::detail::static_const::value; \ + } \ + /**/ +#else // CPP_CXX_INLINE_VARIABLES >= 201606L +#define CPP_INLINE_VAR inline +#define CPP_INLINE_VARIABLE(type, name) \ + inline constexpr type name{}; \ + /**/ +#endif // CPP_CXX_INLINE_VARIABLES + +#if CPP_CXX_INLINE_VARIABLES < 201606L +#define CPP_DEFINE_CPO(type, name) \ + inline namespace \ + { \ + constexpr auto &name = ::concepts::detail::static_const::value; \ + } \ + /**/ +#else // CPP_CXX_INLINE_VARIABLES >= 201606L +#define CPP_DEFINE_CPO(type, name) \ + inline namespace _ \ + { \ + inline constexpr type name{}; \ + } \ + /**/ +#endif // CPP_CXX_INLINE_VARIABLES + +#if defined(_MSC_VER) && !defined(__clang__) +#define CPP_DIAGNOSTIC_PUSH __pragma(warning(push)) +#define CPP_DIAGNOSTIC_POP __pragma(warning(pop)) +#define CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME +#define CPP_DIAGNOSTIC_IGNORE_FLOAT_EQUAL +#define CPP_DIAGNOSTIC_IGNORE_CPP2A_COMPAT +#else // ^^^ defined(_MSC_VER) ^^^ / vvv !defined(_MSC_VER) vvv +#if defined(__GNUC__) || defined(__clang__) +#define CPP_PRAGMA(X) _Pragma(#X) +#define CPP_DIAGNOSTIC_PUSH CPP_PRAGMA(GCC diagnostic push) +#define CPP_DIAGNOSTIC_POP CPP_PRAGMA(GCC diagnostic pop) +#define CPP_DIAGNOSTIC_IGNORE_PRAGMAS \ + CPP_PRAGMA(GCC diagnostic ignored "-Wpragmas") +#define CPP_DIAGNOSTIC_IGNORE(X) \ + CPP_DIAGNOSTIC_IGNORE_PRAGMAS \ + CPP_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas") \ + CPP_PRAGMA(GCC diagnostic ignored X) +#define CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME \ + CPP_DIAGNOSTIC_IGNORE("-Wunknown-warning-option") \ + CPP_DIAGNOSTIC_IGNORE("-Winit-list-lifetime") +#define CPP_DIAGNOSTIC_IGNORE_FLOAT_EQUAL CPP_DIAGNOSTIC_IGNORE("-Wfloat-equal") +#define CPP_DIAGNOSTIC_IGNORE_CPP2A_COMPAT CPP_DIAGNOSTIC_IGNORE("-Wc++2a-compat") +#else +#define CPP_DIAGNOSTIC_PUSH +#define CPP_DIAGNOSTIC_POP +#define CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME +#define CPP_DIAGNOSTIC_IGNORE_FLOAT_EQUAL +#define CPP_DIAGNOSTIC_IGNORE_CPP2A_COMPAT +#endif +#endif // MSVC/Generic configuration switch + +namespace concepts +{ + /// \cond + namespace detail + { + template + CPP_INLINE_VAR constexpr bool is_movable_v = + std::is_object::value && + std::is_move_constructible::value && + std::is_move_assignable::value; + + template + struct static_const + { + static constexpr T const value {}; + }; + template + constexpr T const static_const::value; + } + /// \endcond + + template + struct is_swappable; + + template + struct is_nothrow_swappable; + + template + struct is_swappable_with; + + template + struct is_nothrow_swappable_with; + + template + CPP_CXX14_CONSTEXPR + meta::if_c< + std::is_move_constructible::value && + std::is_assignable::value, T> + exchange(T &t, U &&u) + noexcept( + std::is_nothrow_move_constructible::value && + std::is_nothrow_assignable::value) + { + T tmp((T &&) t); + t = (U &&) u; + CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME + return tmp; + } + + /// \cond + namespace adl_swap_detail + { + struct nope + {}; + + // Intentionally create an ambiguity with std::swap, which is + // (possibly) unconstrained. + template + nope swap(T &, T &) = delete; + + template + nope swap(T (&)[N], T (&)[N]) = delete; + +#ifdef CPP_WORKAROUND_MSVC_895622 + nope swap(); +#endif + + template + decltype(swap(std::declval(), std::declval())) try_adl_swap_(int); + + template + nope try_adl_swap_(long); + + template + CPP_INLINE_VAR constexpr bool is_adl_swappable_v = + !META_IS_SAME(decltype(adl_swap_detail::try_adl_swap_(42)), nope); + + struct swap_fn + { + // Dispatch to user-defined swap found via ADL: + template + CPP_CXX14_CONSTEXPR + meta::if_c> + operator()(T &&t, U &&u) const + noexcept(noexcept(swap((T &&) t, (U &&) u))) + { + swap((T &&) t, (U &&) u); + } + + // For intrinsically swappable (i.e., movable) types for which + // a swap overload cannot be found via ADL, swap by moving. + template + CPP_CXX14_CONSTEXPR + meta::if_c< + !is_adl_swappable_v && + detail::is_movable_v> + operator()(T &a, T &b) const + noexcept(noexcept(b = concepts::exchange(a, (T &&) b))) + { + b = concepts::exchange(a, (T &&) b); + } + + // For arrays of intrinsically swappable (i.e., movable) types + // for which a swap overload cannot be found via ADL, swap array + // elements by moving. + template + CPP_CXX14_CONSTEXPR + meta::if_c< + !is_adl_swappable_v && + is_swappable_with::value> + operator()(T (&t)[N], U (&u)[N]) const + noexcept(is_nothrow_swappable_with::value) + { + for(std::size_t i = 0; i < N; ++i) + (*this)(t[i], u[i]); + } + + // For rvalue pairs and tuples of swappable types, swap the + // members. This permits code like: + // ranges::swap(std::tie(a,b,c), std::tie(d,e,f)); + template + CPP_CXX14_CONSTEXPR + meta::if_c::value && is_swappable_with::value> + operator()(std::pair &&left, std::pair &&right) const + noexcept( + is_nothrow_swappable_with::value && + is_nothrow_swappable_with::value) + { + swap_fn()(static_cast &&>(left).first, + static_cast &&>(right).first); + swap_fn()(static_cast &&>(left).second, + static_cast &&>(right).second); + } + + template + CPP_CXX14_CONSTEXPR + meta::if_c::value...>::value> + operator()(std::tuple &&left, std::tuple &&right) const + noexcept(meta::and_c::value...>::value) + { + swap_fn::impl( + static_cast &&>(left), + static_cast &&>(right), + meta::make_index_sequence{}); + } + + private: + template + static constexpr int ignore_unused(Ts &&...) + { + return 0; + } + template + CPP_CXX14_CONSTEXPR + static void impl(T &&left, U &&right, meta::index_sequence) + { + (void) swap_fn::ignore_unused( + (swap_fn()(std::get(static_cast(left)), + std::get(static_cast(right))), 42)...); + } + }; + + template + struct is_swappable_with_ + : std::false_type + {}; + + template + struct is_swappable_with_(), std::declval())), + decltype(swap_fn()(std::declval(), std::declval()))>> + : std::true_type + {}; + + template + struct is_nothrow_swappable_with_ + : meta::bool_(), std::declval())) && + noexcept(swap_fn()(std::declval(), std::declval()))> + {}; + + // Q: Should std::reference_wrapper be considered a proxy wrt swapping rvalues? + // A: No. Its operator= is currently defined to reseat the references, so + // std::swap(ra, rb) already means something when ra and rb are (lvalue) + // reference_wrappers. That reseats the reference wrappers but leaves the + // referents unmodified. Treating rvalue reference_wrappers differently would + // be confusing. + + // Q: Then why is it OK to "re"-define swap for pairs and tuples of references? + // A: Because as defined above, swapping an rvalue tuple of references has the same + // semantics as swapping an lvalue tuple of references. Rather than reseat the + // references, assignment happens *through* the references. + + // Q: But I have an iterator whose operator* returns an rvalue + // std::reference_wrapper. How do I make it model indirectly_swappable? + // A: With an overload of iter_swap. + } + /// \endcond + + /// \ingroup group-utility + template + struct is_swappable_with + : adl_swap_detail::is_swappable_with_ + {}; + + /// \ingroup group-utility + template + struct is_nothrow_swappable_with + : meta::and_< + is_swappable_with, + adl_swap_detail::is_nothrow_swappable_with_> + {}; + + /// \ingroup group-utility + template + struct is_swappable + : is_swappable_with + {}; + + /// \ingroup group-utility + template + struct is_nothrow_swappable + : is_nothrow_swappable_with + {}; + + /// \ingroup group-utility + /// \relates adl_swap_detail::swap_fn + CPP_DEFINE_CPO(adl_swap_detail::swap_fn, swap) +} + +#endif diff --git a/linux/include/concepts/type_traits.hpp b/linux/include/concepts/type_traits.hpp new file mode 100644 index 000000000..f8ee95c9c --- /dev/null +++ b/linux/include/concepts/type_traits.hpp @@ -0,0 +1,379 @@ +/// \file +// Concepts library +// +// Copyright Eric Niebler 2013-present +// +// Use, modification and distribution is subject to 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) +// +// Project home: https://github.com/ericniebler/range-v3 + +#ifndef CPP_TYPE_TRAITS_HPP +#define CPP_TYPE_TRAITS_HPP + +#include +#include +#include +#include + +namespace concepts +{ + template + using remove_cvref_t = + typename std::remove_cv< + typename std::remove_reference::type>::type; + + /// \cond + namespace detail + { + template + using is_convertible = std::is_convertible>, To>; + + template + struct if_else_ + { + template + using invoke = U; + }; + template<> + struct if_else_ + { + template + using invoke = T; + }; + template + using if_else_t = meta::invoke, T, U>; + + template + struct if_ + {}; + template<> + struct if_ + { + template + using invoke = T; + }; + template + using if_t = meta::invoke, T>; + + template + struct _copy_cv_ + { + using type = To; + }; + template + struct _copy_cv_ + { + using type = To const; + }; + template + struct _copy_cv_ + { + using type = To volatile; + }; + template + struct _copy_cv_ + { + using type = To const volatile; + }; + template + using _copy_cv = meta::_t<_copy_cv_>; + + //////////////////////////////////////////////////////////////////////////////////////// + template + struct _builtin_common; + + template + using _builtin_common_t = meta::_t<_builtin_common>; + + template + using _cond_res = decltype(true ? std::declval() : std::declval()); + + template> + using _rref_res = + if_else_t::value, meta::_t> &&, R>; + + template + using _lref_res = _cond_res<_copy_cv &, _copy_cv &>; + + template + struct as_cref_ + { + using type = T const &; + }; + template + struct as_cref_ + { + using type = T const &; + }; + template + struct as_cref_ + { + using type = T const &; + }; + template<> + struct as_cref_ + { + using type = void; + }; + template<> + struct as_cref_ + { + using type = void const; + }; + + template + using as_cref_t = typename as_cref_::type; + + template + using decay_t = typename std::decay::type; + + #if !defined(__GNUC__) || defined(__clang__) + template + struct _builtin_common_3 + {}; + template + struct _builtin_common_3, as_cref_t>>> + : std::decay<_cond_res, as_cref_t>> + {}; + template + struct _builtin_common_2 + : _builtin_common_3 + {}; + template + struct _builtin_common_2>> + : std::decay<_cond_res> + {}; + template + struct _builtin_common + : _builtin_common_2 + {}; + template + struct _builtin_common>::value && + is_convertible>::value>> + { + using type = _rref_res; + }; + template + struct _builtin_common + : meta::defer<_lref_res, T, U> + {}; + template + struct _builtin_common>::value>> + : _builtin_common + {}; + template + struct _builtin_common + : _builtin_common + {}; + #else + template + struct _builtin_common_3 + {}; + template + struct _builtin_common_3, as_cref_t>>> + : std::decay<_cond_res, as_cref_t>> + {}; + template + struct _builtin_common_2 + : _builtin_common_3 + {}; + template + struct _builtin_common_2>> + : std::decay<_cond_res> + {}; + template + struct _builtin_common + : _builtin_common_2 + {}; + template + struct _builtin_common_rr + : _builtin_common_2 + {}; + template + struct _builtin_common_rr>::value && + is_convertible>::value>> + { + using type = _rref_res; + }; + template + struct _builtin_common + : _builtin_common_rr + {}; + template + struct _builtin_common + : meta::defer<_lref_res, T, U> + {}; + template + struct _builtin_common_lr + : _builtin_common_2 + {}; + template + struct _builtin_common_lr>::value>> + : _builtin_common + {}; + template + struct _builtin_common + : _builtin_common_lr + {}; + template + struct _builtin_common + : _builtin_common + {}; + #endif + } + /// \endcond + + /// \addtogroup group-utility Utility + /// @{ + /// + + /// Users should specialize this to hook the \c common_with concept + /// until \c std gets a SFINAE-friendly \c std::common_type and there's + /// some sane way to deal with cv and ref qualifiers. + template + struct common_type + {}; + + template + struct common_type + : std::decay + {}; + + template + struct common_type + : detail::if_else_t< + (META_IS_SAME(detail::decay_t, T) && + META_IS_SAME(detail::decay_t, U) ), + meta::defer, + common_type, detail::decay_t>> + {}; + + template + using common_type_t = typename common_type::type; + + template + struct common_type + : meta::lazy::fold, T, meta::quote> + {}; + + /// @} + + /// \addtogroup group-utility Utility + /// @{ + /// + + /// Users can specialize this to hook the \c common_reference_with concept. + /// \sa `common_reference` + template< + typename T, + typename U, + template class TQual, + template class UQual> + struct basic_common_reference + {}; + + /// \cond + namespace detail + { + using _rref = + meta::quote_trait; + using _lref = + meta::quote_trait; + + template + struct _xref + { + template + using invoke = T; + }; + template + struct _xref + { + template + using invoke = + meta::_t, U>>>; + }; + template + struct _xref + { + template + using invoke = + meta::_t, U>>>; + }; + template + struct _xref + { + template + using invoke = U const; + }; + template + struct _xref + { + template + using invoke = U volatile; + }; + template + struct _xref + { + template + using invoke = U const volatile; + }; + + template + using _basic_common_reference = + basic_common_reference< + remove_cvref_t, + remove_cvref_t, + _xref::template invoke, + _xref::template invoke>; + + template + struct _common_reference2 + : if_else_t< + meta::is_trait<_basic_common_reference>::value, + _basic_common_reference, + common_type> + {}; + + template + struct _common_reference2>::value>> + : _builtin_common + {}; + } + /// \endcond + + /// Users can specialize this to hook the \c common_reference_with concept. + /// \sa `basic_common_reference` + template + struct common_reference + {}; + + template + struct common_reference + { + using type = T; + }; + + template + struct common_reference + : detail::_common_reference2 + {}; + + template + using common_reference_t = typename common_reference::type; + + template + struct common_reference + : meta::lazy::fold, T, meta::quote> + {}; + /// @} +} // namespace concepts + +#endif diff --git a/linux/include/meta/meta.hpp b/linux/include/meta/meta.hpp new file mode 100644 index 000000000..c87e103f8 --- /dev/null +++ b/linux/include/meta/meta.hpp @@ -0,0 +1,3973 @@ +/// \file meta.hpp Tiny meta-programming library. +// +// Meta library +// +// Copyright Eric Niebler 2014-present +// +// Use, modification and distribution is subject to 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) +// +// Project home: https://github.com/ericniebler/meta +// + +#ifndef META_HPP +#define META_HPP + +#include +#include +#include +#include +#include + +#ifdef __clang__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wdocumentation-deprecated-sync" +#pragma GCC diagnostic ignored "-Wmissing-variable-declarations" +#endif + +/// \defgroup meta Meta +/// +/// A tiny metaprogramming library + +/// \defgroup trait Trait +/// Trait invocation/composition. +/// \ingroup meta + +/// \defgroup invocation Invocation +/// Trait invocation +/// \ingroup trait + +/// \defgroup composition Composition +/// Trait composition +/// \ingroup trait + +/// \defgroup logical Logical +/// Logical operations +/// \ingroup meta + +/// \defgroup algorithm Algorithms +/// Algorithms. +/// \ingroup meta + +/// \defgroup query Query/Search +/// Query and search algorithms +/// \ingroup algorithm + +/// \defgroup transformation Transformation +/// Transformation algorithms +/// \ingroup algorithm + +/// \defgroup runtime Runtime +/// Runtime algorithms +/// \ingroup algorithm + +/// \defgroup datatype Datatype +/// Datatypes. +/// \ingroup meta + +/// \defgroup list list_like +/// \ingroup datatype + +/// \defgroup integral Integer sequence +/// Equivalent to C++14's `std::integer_sequence` +/// \ingroup datatype + +/// \defgroup extension Extension +/// Extend meta with your own datatypes. +/// \ingroup datatype + +/// \defgroup math Math +/// Integral constant arithmetic. +/// \ingroup meta + +/// \defgroup lazy_trait lazy +/// \ingroup trait + +/// \defgroup lazy_invocation lazy +/// \ingroup invocation + +/// \defgroup lazy_composition lazy +/// \ingroup composition + +/// \defgroup lazy_logical lazy +/// \ingroup logical + +/// \defgroup lazy_query lazy +/// \ingroup query + +/// \defgroup lazy_transformation lazy +/// \ingroup transformation + +/// \defgroup lazy_list lazy +/// \ingroup list + +/// \defgroup lazy_datatype lazy +/// \ingroup datatype + +/// \defgroup lazy_math lazy +/// \ingroup math + +/// Tiny metaprogramming library +namespace meta +{ + namespace detail + { + /// Returns a \p T nullptr + template + constexpr T *_nullptr_v() + { + return nullptr; + } + +#if META_CXX_VARIABLE_TEMPLATES + template + META_INLINE_VAR constexpr T *nullptr_v = nullptr; +#endif + } // namespace detail + + /// An empty type. + /// \ingroup datatype + struct nil_ + { + }; + + /// Type alias for \p T::type. + /// \ingroup invocation + template + using _t = typename T::type; + +#if META_CXX_VARIABLE_TEMPLATES || defined(META_DOXYGEN_INVOKED) + /// Variable alias for \c T::type::value + /// \note Requires C++14 or greater. + /// \ingroup invocation + template + constexpr typename T::type::value_type _v = T::type::value; +#endif + + /// Lazy versions of meta actions + namespace lazy + { + /// \sa `meta::_t` + /// \ingroup lazy_invocation + template + using _t = defer<_t, T>; + } // namespace lazy + + /// An integral constant wrapper for \c std::size_t. + /// \ingroup integral + template + using size_t = std::integral_constant; + + /// An integral constant wrapper for \c bool. + /// \ingroup integral + template + using bool_ = std::integral_constant; + + /// An integral constant wrapper for \c int. + /// \ingroup integral + template + using int_ = std::integral_constant; + + /// An integral constant wrapper for \c char. + /// \ingroup integral + template + using char_ = std::integral_constant; + + /////////////////////////////////////////////////////////////////////////////////////////// + // Math operations + /// An integral constant wrapper around the result of incrementing the wrapped integer \c + /// T::type::value. + template + using inc = std::integral_constant; + + /// An integral constant wrapper around the result of decrementing the wrapped integer \c + /// T::type::value. + template + using dec = std::integral_constant; + + /// An integral constant wrapper around the result of adding the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using plus = std::integral_constant; + + /// An integral constant wrapper around the result of subtracting the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using minus = std::integral_constant; + + /// An integral constant wrapper around the result of multiplying the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using multiplies = std::integral_constant; + + /// An integral constant wrapper around the result of dividing the two wrapped integers \c + /// T::type::value and \c U::type::value. + /// \ingroup math + template + using divides = std::integral_constant; + + /// An integral constant wrapper around the result of negating the wrapped integer + /// \c T::type::value. + /// \ingroup math + template + using negate = std::integral_constant; + + /// An integral constant wrapper around the remainder of dividing the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using modulus = std::integral_constant; + + /// A Boolean integral constant wrapper around the result of comparing \c T::type::value and + /// \c U::type::value for equality. + /// \ingroup math + template + using equal_to = bool_; + + /// A Boolean integral constant wrapper around the result of comparing \c T::type::value and + /// \c U::type::value for inequality. + /// \ingroup math + template + using not_equal_to = bool_; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is greater than + /// \c U::type::value; \c false, otherwise. + /// \ingroup math + template + using greater = bool_<(T::type::value > U::type::value)>; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is less than \c + /// U::type::value; \c false, otherwise. + /// \ingroup math + template + using less = bool_<(T::type::value < U::type::value)>; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is greater than + /// or equal to \c U::type::value; \c false, otherwise. + /// \ingroup math + template + using greater_equal = bool_<(T::type::value >= U::type::value)>; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is less than or + /// equal to \c U::type::value; \c false, otherwise. + /// \ingroup math + template + using less_equal = bool_<(T::type::value <= U::type::value)>; + + /// An integral constant wrapper around the result of bitwise-and'ing the two wrapped + /// integers \c T::type::value and \c U::type::value. + /// \ingroup math + template + using bit_and = std::integral_constant; + + /// An integral constant wrapper around the result of bitwise-or'ing the two wrapped + /// integers \c T::type::value and \c U::type::value. + /// \ingroup math + template + using bit_or = std::integral_constant; + + /// An integral constant wrapper around the result of bitwise-exclusive-or'ing the two + /// wrapped integers \c T::type::value and \c U::type::value. + /// \ingroup math + template + using bit_xor = std::integral_constant; + + /// An integral constant wrapper around the result of bitwise-complementing the wrapped + /// integer \c T::type::value. + /// \ingroup math + template + using bit_not = std::integral_constant; + + namespace lazy + { + /// \sa 'meta::int' + /// \ingroup lazy_math + template + using inc = defer; + + /// \sa 'meta::dec' + /// \ingroup lazy_math + template + using dec = defer; + + /// \sa 'meta::plus' + /// \ingroup lazy_math + template + using plus = defer; + + /// \sa 'meta::minus' + /// \ingroup lazy_math + template + using minus = defer; + + /// \sa 'meta::multiplies' + /// \ingroup lazy_math + template + using multiplies = defer; + + /// \sa 'meta::divides' + /// \ingroup lazy_math + template + using divides = defer; + + /// \sa 'meta::negate' + /// \ingroup lazy_math + template + using negate = defer; + + /// \sa 'meta::modulus' + /// \ingroup lazy_math + template + using modulus = defer; + + /// \sa 'meta::equal_to' + /// \ingroup lazy_math + template + using equal_to = defer; + + /// \sa 'meta::not_equal_t' + /// \ingroup lazy_math + template + using not_equal_to = defer; + + /// \sa 'meta::greater' + /// \ingroup lazy_math + template + using greater = defer; + + /// \sa 'meta::less' + /// \ingroup lazy_math + template + using less = defer; + + /// \sa 'meta::greater_equal' + /// \ingroup lazy_math + template + using greater_equal = defer; + + /// \sa 'meta::less_equal' + /// \ingroup lazy_math + template + using less_equal = defer; + + /// \sa 'meta::bit_and' + /// \ingroup lazy_math + template + using bit_and = defer; + + /// \sa 'meta::bit_or' + /// \ingroup lazy_math + template + using bit_or = defer; + + /// \sa 'meta::bit_xor' + /// \ingroup lazy_math + template + using bit_xor = defer; + + /// \sa 'meta::bit_not' + /// \ingroup lazy_math + template + using bit_not = defer; + } // namespace lazy + + /// \cond + namespace detail + { + enum class indices_strategy_ + { + done, + repeat, + recurse + }; + + constexpr indices_strategy_ strategy_(std::size_t cur, std::size_t end) + { + return cur >= end ? indices_strategy_::done + : cur * 2 <= end ? indices_strategy_::repeat + : indices_strategy_::recurse; + } + + template + constexpr std::size_t range_distance_(T begin, T end) + { + return begin <= end ? static_cast(end - begin) + : throw "The start of the integer_sequence must not be " + "greater than the end"; + } + + template + struct make_indices_ + { + using type = State; + }; + + template + struct coerce_indices_ + { + }; + } // namespace detail + /// \endcond + + /////////////////////////////////////////////////////////////////////////////////////////// + // integer_sequence +#if !META_CXX_INTEGER_SEQUENCE + /// A container for a sequence of compile-time integer constants. + /// \ingroup integral + template + struct integer_sequence + { + using value_type = T; + /// \return `sizeof...(Is)` + static constexpr std::size_t size() noexcept { return sizeof...(Is); } + }; +#endif + + /////////////////////////////////////////////////////////////////////////////////////////// + // index_sequence + /// A container for a sequence of compile-time integer constants of type + /// \c std::size_t + /// \ingroup integral + template + using index_sequence = integer_sequence; + +#if META_HAS_MAKE_INTEGER_SEQ && !defined(META_DOXYGEN_INVOKED) + // Implement make_integer_sequence and make_index_sequence with the + // __make_integer_seq builtin on compilers that provide it. (Redirect + // through decltype to workaround suspected clang bug.) + /// \cond + namespace detail + { + template + __make_integer_seq make_integer_sequence_(); + } + /// \endcond + + template + using make_integer_sequence = decltype(detail::make_integer_sequence_()); + + template + using make_index_sequence = make_integer_sequence; +#else + /// Generate \c index_sequence containing integer constants [0,1,2,...,N-1]. + /// \par Complexity + /// \f$ O(log(N)) \f$. + /// \ingroup integral + template + using make_index_sequence = + _t, detail::strategy_(1, N)>>; + + /// Generate \c integer_sequence containing integer constants [0,1,2,...,N-1]. + /// \par Complexity + /// \f$ O(log(N)) \f$. + /// \ingroup integral + template + using make_integer_sequence = + _t(N)>>>; +#endif + + /////////////////////////////////////////////////////////////////////////////////////////// + // integer_range + /// Makes the integer sequence [From, To). + /// \par Complexity + /// \f$ O(log(To - From)) \f$. + /// \ingroup integral + template + using integer_range = + _t>>; + + /// \cond + namespace detail + { + template + struct concat_indices_ + { + }; + + template + struct concat_indices_, index_sequence> + { + using type = index_sequence; + }; + + template <> + struct make_indices_<0u, index_sequence<0>, indices_strategy_::done> + { + using type = index_sequence<>; + }; + + template + struct make_indices_, indices_strategy_::repeat> + : make_indices_, + detail::strategy_(sizeof...(Values) * 2, End)> + { + }; + + template + struct make_indices_, indices_strategy_::recurse> + : concat_indices_, + make_index_sequence> + { + }; + + template + struct coerce_indices_> + { + using type = + integer_sequence(static_cast(Values) + Offset)...>; + }; + } // namespace detail + /// \endcond + + /// Evaluate the invocable \p Fn with the arguments \p Args. + /// \ingroup invocation + template + using invoke = typename Fn::template invoke; + + /// Lazy versions of meta actions + namespace lazy + { + /// \sa `meta::invoke` + /// \ingroup lazy_invocation + template + using invoke = defer; + } // namespace lazy + + /// A trait that always returns its argument \p T. It is also an invocable + /// that always returns \p T. + /// \ingroup trait + /// \ingroup invocation + template + struct id + { +#if defined(META_WORKAROUND_CWG_1558) && !defined(META_DOXYGEN_INVOKED) + // Redirect through decltype for compilers that have not + // yet implemented CWG 1558: + static id impl(void *); + + template + using invoke = _t *>(nullptr)))>; +#else + template + using invoke = T; +#endif + + using type = T; + }; + + /// An alias for type \p T. Useful in non-deduced contexts. + /// \ingroup trait + template + using id_t = _t>; + + namespace lazy + { + /// \sa `meta::id` + /// \ingroup lazy_trait + /// \ingroup lazy_invocation + template + using id = defer; + } // namespace lazy + + /// An alias for `void`. + /// \ingroup trait +#if defined(META_WORKAROUND_CWG_1558) && !defined(META_DOXYGEN_INVOKED) + // Redirect through decltype for compilers that have not + // yet implemented CWG 1558: + template + using void_ = invoke, Ts...>; +#else + template + using void_ = void; +#endif + +#if META_CXX_VARIABLE_TEMPLATES +#ifdef META_CONCEPT + /// `true` if `T::type` exists and names a type; `false` otherwise. + /// \ingroup trait + template + META_INLINE_VAR constexpr bool is_trait_v = trait; + + /// `true` if `T::invoke` exists and names a class template; `false` otherwise. + /// \ingroup trait + template + META_INLINE_VAR constexpr bool is_callable_v = invocable; +#else // ^^^ Concepts / No concepts vvv + /// \cond + namespace detail + { + template + META_INLINE_VAR constexpr bool is_trait_ = false; + + template + META_INLINE_VAR constexpr bool is_trait_> = true; + + template + META_INLINE_VAR constexpr bool is_callable_ = false; + + template + META_INLINE_VAR constexpr bool is_callable_>> = true; + } // namespace detail + /// \endcond + + /// `true` if `T::type` exists and names a type; `false` otherwise. + /// \ingroup trait + template + META_INLINE_VAR constexpr bool is_trait_v = detail::is_trait_; + + /// `true` if `T::invoke` exists and names a class template; `false` otherwise. + /// \ingroup trait + template + META_INLINE_VAR constexpr bool is_callable_v = detail::is_callable_; +#endif // Concepts vs. variable templates + + /// An alias for `std::true_type` if `T::type` exists and names a type; otherwise, it's an + /// alias for `std::false_type`. + /// \ingroup trait + template + using is_trait = bool_>; + + /// An alias for `std::true_type` if `T::invoke` exists and names a class template; + /// otherwise, it's an alias for `std::false_type`. + /// \ingroup trait + template + using is_callable = bool_>; +#else // ^^^ META_CXX_VARIABLE_TEMPLATES / !META_CXX_VARIABLE_TEMPLATES vvv + /// \cond + namespace detail + { + template + struct is_trait_ + { + using type = std::false_type; + }; + + template + struct is_trait_> + { + using type = std::true_type; + }; + + template + struct is_callable_ + { + using type = std::false_type; + }; + + template + struct is_callable_>> + { + using type = std::true_type; + }; + } // namespace detail + /// \endcond + + template + using is_trait = _t>; + + /// An alias for `std::true_type` if `T::invoke` exists and names a class + /// template or alias template; otherwise, it's an alias for + /// `std::false_type`. + /// \ingroup trait + template + using is_callable = _t>; +#endif + + /// \cond + namespace detail + { +#ifdef META_CONCEPT + template