From 385a813585d10de4612a3bffa080a951e94022a0 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 6 Aug 2020 13:21:45 -0600 Subject: [PATCH] use clang as a doxygen preprocessor and turn requires clauses into \pre blocks --- .clang-format | 2 +- doc/CMakeLists.txt | 1 + doc/Doxyfile.in | 2 +- doc/ignore_errors.sh | 3 + doc/preprocess.sh.in | 3 + doc/unpreprocess.pl | 19 ++ include/concepts/concepts.hpp | 268 ++++++++---------- include/range/v3/action/action.hpp | 17 +- .../range/v3/action/adjacent_remove_if.hpp | 8 +- include/range/v3/action/concepts.hpp | 20 +- include/range/v3/action/drop.hpp | 10 +- include/range/v3/action/drop_while.hpp | 8 +- include/range/v3/action/erase.hpp | 12 +- include/range/v3/action/insert.hpp | 101 ++++--- include/range/v3/action/join.hpp | 5 +- include/range/v3/action/push_back.hpp | 27 +- include/range/v3/action/push_front.hpp | 25 +- include/range/v3/action/remove.hpp | 8 +- include/range/v3/action/remove_if.hpp | 8 +- include/range/v3/action/reverse.hpp | 5 +- include/range/v3/action/shuffle.hpp | 9 +- include/range/v3/action/slice.hpp | 40 ++- include/range/v3/action/sort.hpp | 8 +- include/range/v3/action/split.hpp | 13 +- include/range/v3/action/split_when.hpp | 18 +- include/range/v3/action/stable_sort.hpp | 8 +- include/range/v3/action/stride.hpp | 12 +- include/range/v3/action/take.hpp | 10 +- include/range/v3/action/take_while.hpp | 8 +- include/range/v3/action/transform.hpp | 8 +- include/range/v3/action/unique.hpp | 12 +- .../range/v3/action/unstable_remove_if.hpp | 8 +- include/range/v3/algorithm/adjacent_find.hpp | 14 +- .../range/v3/algorithm/adjacent_remove_if.hpp | 14 +- include/range/v3/algorithm/all_of.hpp | 14 +- include/range/v3/algorithm/any_of.hpp | 14 +- .../range/v3/algorithm/aux_/equal_range_n.hpp | 5 +- .../range/v3/algorithm/aux_/lower_bound_n.hpp | 5 +- include/range/v3/algorithm/aux_/merge_n.hpp | 5 +- .../v3/algorithm/aux_/merge_n_with_buffer.hpp | 5 +- .../v3/algorithm/aux_/partition_point_n.hpp | 5 +- .../v3/algorithm/aux_/sort_n_with_buffer.hpp | 5 +- .../range/v3/algorithm/aux_/upper_bound_n.hpp | 5 +- include/range/v3/algorithm/binary_search.hpp | 8 +- include/range/v3/algorithm/contains.hpp | 14 +- include/range/v3/algorithm/copy.hpp | 14 +- include/range/v3/algorithm/copy_backward.hpp | 14 +- include/range/v3/algorithm/copy_if.hpp | 18 +- include/range/v3/algorithm/copy_n.hpp | 7 +- include/range/v3/algorithm/count.hpp | 14 +- include/range/v3/algorithm/count_if.hpp | 14 +- include/range/v3/algorithm/ends_with.hpp | 10 +- include/range/v3/algorithm/equal.hpp | 16 +- include/range/v3/algorithm/equal_range.hpp | 8 +- include/range/v3/algorithm/fill.hpp | 10 +- include/range/v3/algorithm/fill_n.hpp | 5 +- include/range/v3/algorithm/find.hpp | 14 +- include/range/v3/algorithm/find_end.hpp | 25 +- include/range/v3/algorithm/find_first_of.hpp | 10 +- include/range/v3/algorithm/find_if.hpp | 14 +- include/range/v3/algorithm/find_if_not.hpp | 14 +- include/range/v3/algorithm/for_each.hpp | 14 +- include/range/v3/algorithm/for_each_n.hpp | 10 +- include/range/v3/algorithm/generate.hpp | 12 +- include/range/v3/algorithm/generate_n.hpp | 5 +- include/range/v3/algorithm/heap_algorithm.hpp | 91 +++--- include/range/v3/algorithm/inplace_merge.hpp | 20 +- include/range/v3/algorithm/is_partitioned.hpp | 14 +- include/range/v3/algorithm/is_sorted.hpp | 14 +- .../range/v3/algorithm/is_sorted_until.hpp | 14 +- .../v3/algorithm/lexicographical_compare.hpp | 10 +- include/range/v3/algorithm/lower_bound.hpp | 8 +- include/range/v3/algorithm/max.hpp | 19 +- include/range/v3/algorithm/max_element.hpp | 14 +- include/range/v3/algorithm/merge.hpp | 10 +- include/range/v3/algorithm/min.hpp | 19 +- include/range/v3/algorithm/min_element.hpp | 14 +- include/range/v3/algorithm/minmax.hpp | 19 +- include/range/v3/algorithm/minmax_element.hpp | 14 +- include/range/v3/algorithm/mismatch.hpp | 17 +- include/range/v3/algorithm/move.hpp | 14 +- include/range/v3/algorithm/move_backward.hpp | 14 +- include/range/v3/algorithm/none_of.hpp | 14 +- include/range/v3/algorithm/nth_element.hpp | 18 +- include/range/v3/algorithm/partial_sort.hpp | 10 +- .../range/v3/algorithm/partial_sort_copy.hpp | 10 +- include/range/v3/algorithm/partition.hpp | 14 +- include/range/v3/algorithm/partition_copy.hpp | 10 +- .../range/v3/algorithm/partition_point.hpp | 14 +- include/range/v3/algorithm/permutation.hpp | 40 +-- include/range/v3/algorithm/remove.hpp | 14 +- include/range/v3/algorithm/remove_copy.hpp | 12 +- include/range/v3/algorithm/remove_copy_if.hpp | 14 +- include/range/v3/algorithm/remove_if.hpp | 14 +- include/range/v3/algorithm/replace.hpp | 8 +- include/range/v3/algorithm/replace_copy.hpp | 10 +- .../range/v3/algorithm/replace_copy_if.hpp | 8 +- include/range/v3/algorithm/replace_if.hpp | 8 +- include/range/v3/algorithm/reverse.hpp | 8 +- include/range/v3/algorithm/reverse_copy.hpp | 14 +- include/range/v3/algorithm/rotate.hpp | 10 +- include/range/v3/algorithm/rotate_copy.hpp | 14 +- include/range/v3/algorithm/sample.hpp | 10 +- include/range/v3/algorithm/search.hpp | 10 +- include/range/v3/algorithm/search_n.hpp | 8 +- include/range/v3/algorithm/set_algorithm.hpp | 50 ++-- include/range/v3/algorithm/shuffle.hpp | 8 +- include/range/v3/algorithm/sort.hpp | 12 +- .../range/v3/algorithm/stable_partition.hpp | 16 +- include/range/v3/algorithm/stable_sort.hpp | 12 +- include/range/v3/algorithm/starts_with.hpp | 8 +- include/range/v3/algorithm/swap_ranges.hpp | 24 +- include/range/v3/algorithm/transform.hpp | 32 ++- include/range/v3/algorithm/unique.hpp | 10 +- include/range/v3/algorithm/unique_copy.hpp | 4 +- .../range/v3/algorithm/unstable_remove_if.hpp | 16 +- include/range/v3/algorithm/upper_bound.hpp | 8 +- include/range/v3/detail/adl_get.hpp | 10 +- include/range/v3/detail/prologue.hpp | 1 - include/range/v3/detail/range_access.hpp | 3 +- include/range/v3/detail/variant.hpp | 62 ++-- .../v3/experimental/utility/generator.hpp | 3 +- include/range/v3/experimental/view/shared.hpp | 19 +- include/range/v3/functional/bind.hpp | 6 +- include/range/v3/functional/comparisons.hpp | 33 ++- include/range/v3/functional/invoke.hpp | 15 +- include/range/v3/functional/not_fn.hpp | 29 +- include/range/v3/functional/overload.hpp | 6 + include/range/v3/functional/pipeable.hpp | 9 +- .../range/v3/functional/reference_wrapper.hpp | 13 +- include/range/v3/iterator/basic_iterator.hpp | 225 +++++++++------ include/range/v3/iterator/common_iterator.hpp | 81 ++++-- include/range/v3/iterator/concepts.hpp | 61 ++-- .../range/v3/iterator/counted_iterator.hpp | 109 ++++--- include/range/v3/iterator/diffmax_t.hpp | 43 ++- include/range/v3/iterator/move_iterators.hpp | 126 +++++--- include/range/v3/iterator/operations.hpp | 113 +++++--- .../range/v3/iterator/reverse_iterator.hpp | 23 +- .../range/v3/iterator/stream_iterators.hpp | 10 +- .../v3/iterator/unreachable_sentinel.hpp | 12 +- include/range/v3/iterator_range.hpp | 67 +++-- include/range/v3/numeric/accumulate.hpp | 10 +- .../range/v3/numeric/adjacent_difference.hpp | 16 +- include/range/v3/numeric/inner_product.hpp | 16 +- include/range/v3/numeric/iota.hpp | 10 +- include/range/v3/numeric/partial_sum.hpp | 16 +- include/range/v3/range/access.hpp | 33 ++- include/range/v3/range/conversion.hpp | 82 ++++-- include/range/v3/range/dangling.hpp | 10 +- include/range/v3/range/operations.hpp | 22 +- include/range/v3/range/primitives.hpp | 33 ++- include/range/v3/utility/addressof.hpp | 6 +- include/range/v3/utility/any.hpp | 6 +- include/range/v3/utility/box.hpp | 30 +- include/range/v3/utility/common_tuple.hpp | 153 ++++++---- include/range/v3/utility/compressed_pair.hpp | 10 +- include/range/v3/utility/copy.hpp | 8 +- include/range/v3/utility/infinity.hpp | 12 +- include/range/v3/utility/memory.hpp | 20 +- include/range/v3/utility/optional.hpp | 113 +++++--- include/range/v3/utility/random.hpp | 37 ++- include/range/v3/utility/semiregular_box.hpp | 55 ++-- include/range/v3/utility/tagged_pair.hpp | 26 +- include/range/v3/utility/variant.hpp | 30 +- include/range/v3/view/adaptor.hpp | 60 ++-- include/range/v3/view/addressof.hpp | 5 +- include/range/v3/view/adjacent_filter.hpp | 20 +- include/range/v3/view/adjacent_remove_if.hpp | 17 +- include/range/v3/view/all.hpp | 10 +- include/range/v3/view/any_view.hpp | 47 +-- include/range/v3/view/c_str.hpp | 6 +- include/range/v3/view/cache1.hpp | 23 +- include/range/v3/view/cartesian_product.hpp | 65 +++-- include/range/v3/view/chunk.hpp | 48 +++- include/range/v3/view/common.hpp | 47 +-- include/range/v3/view/concat.hpp | 89 +++--- include/range/v3/view/const.hpp | 22 +- include/range/v3/view/counted.hpp | 18 +- include/range/v3/view/cycle.hpp | 23 +- include/range/v3/view/delimit.hpp | 15 +- include/range/v3/view/drop.hpp | 36 ++- include/range/v3/view/drop_exactly.hpp | 34 ++- include/range/v3/view/drop_last.hpp | 41 +-- include/range/v3/view/drop_while.hpp | 25 +- include/range/v3/view/empty.hpp | 3 +- include/range/v3/view/enumerate.hpp | 3 +- include/range/v3/view/exclusive_scan.hpp | 25 +- include/range/v3/view/facade.hpp | 20 +- include/range/v3/view/filter.hpp | 23 +- include/range/v3/view/for_each.hpp | 23 +- include/range/v3/view/generate.hpp | 5 +- include/range/v3/view/generate_n.hpp | 5 +- include/range/v3/view/group_by.hpp | 12 +- include/range/v3/view/indices.hpp | 20 +- include/range/v3/view/indirect.hpp | 21 +- include/range/v3/view/interface.hpp | 183 +++++++----- include/range/v3/view/intersperse.hpp | 50 ++-- include/range/v3/view/iota.hpp | 87 ++++-- include/range/v3/view/istream.hpp | 5 +- include/range/v3/view/join.hpp | 63 ++-- include/range/v3/view/linear_distribute.hpp | 3 +- include/range/v3/view/map.hpp | 15 +- include/range/v3/view/move.hpp | 17 +- include/range/v3/view/partial_sum.hpp | 24 +- include/range/v3/view/ref.hpp | 14 +- include/range/v3/view/remove.hpp | 16 +- include/range/v3/view/remove_if.hpp | 29 +- include/range/v3/view/repeat.hpp | 5 +- include/range/v3/view/repeat_n.hpp | 5 +- include/range/v3/view/replace.hpp | 10 +- include/range/v3/view/replace_if.hpp | 17 +- include/range/v3/view/reverse.hpp | 25 +- include/range/v3/view/sample.hpp | 14 +- include/range/v3/view/set_algorithm.hpp | 59 ++-- include/range/v3/view/single.hpp | 13 +- include/range/v3/view/slice.hpp | 45 +-- include/range/v3/view/sliding.hpp | 28 +- include/range/v3/view/span.hpp | 64 +++-- include/range/v3/view/split.hpp | 54 ++-- include/range/v3/view/split_when.hpp | 28 +- include/range/v3/view/stride.hpp | 33 ++- include/range/v3/view/subrange.hpp | 116 +++++--- include/range/v3/view/tail.hpp | 23 +- include/range/v3/view/take.hpp | 29 +- include/range/v3/view/take_exactly.hpp | 16 +- include/range/v3/view/take_last.hpp | 6 +- include/range/v3/view/take_while.hpp | 40 +-- include/range/v3/view/tokenize.hpp | 34 ++- include/range/v3/view/transform.hpp | 93 +++--- include/range/v3/view/trim.hpp | 21 +- include/range/v3/view/unbounded.hpp | 5 +- include/range/v3/view/unique.hpp | 10 +- include/range/v3/view/view.hpp | 14 +- include/range/v3/view/zip.hpp | 52 ++-- include/range/v3/view/zip_with.hpp | 54 ++-- test/debug_view.hpp | 12 +- test/iterator/basic_iterator.cpp | 27 +- test/test_utils.hpp | 13 +- 238 files changed, 3647 insertions(+), 2352 deletions(-) create mode 100755 doc/ignore_errors.sh create mode 100755 doc/preprocess.sh.in create mode 100755 doc/unpreprocess.pl diff --git a/.clang-format b/.clang-format index 32efaf864a..e2bc471e7e 100644 --- a/.clang-format +++ b/.clang-format @@ -46,7 +46,7 @@ ForEachMacros: ['RANGES_FOR',], IncludeBlocks: Regroup, IncludeCategories: [ - { Regex: '^/dev/null +exit 0 diff --git a/doc/preprocess.sh.in b/doc/preprocess.sh.in new file mode 100755 index 0000000000..a365b511db --- /dev/null +++ b/doc/preprocess.sh.in @@ -0,0 +1,3 @@ +#!/bin/bash +@Range-v3_SOURCE_DIR@/doc/ignore_errors.sh @CMAKE_CXX_COMPILER@ -x c++ -std=c++2a -DRANGES_DOXYGEN_INVOKED=1 -DMETA_DOXYGEN_INVOKED=1 -DCPP_DOXYGEN_INVOKED=1 -I @Range-v3_SOURCE_DIR@/include -E -CC $1 | @Range-v3_SOURCE_DIR@/doc/unpreprocess.pl +exit 0 diff --git a/doc/unpreprocess.pl b/doc/unpreprocess.pl new file mode 100755 index 0000000000..befe3d4b77 --- /dev/null +++ b/doc/unpreprocess.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; + +my $file = ""; +my $first = 1; +my $emit = 0; + +while(<>) { + if ($first) { + $_ =~ m/^#\s*\d+\s+"(.*)"/; + $file = $1; + $first = 0; + } elsif ($_ =~ m/^#\s*\d+\s+"(.*)"/) { + $emit = ($1 eq $file); + } elsif ($emit) { + print $_; + } +} diff --git a/include/concepts/concepts.hpp b/include/concepts/concepts.hpp index f542804bff..43c1a6d88c 100644 --- a/include/concepts/concepts.hpp +++ b/include/concepts/concepts.hpp @@ -33,11 +33,11 @@ #if defined(__clang__) && __cplusplus <= 201703L #define CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ CPP_DIAGNOSTIC_PUSH \ - CPP_DIAGNOSTIC_IGNORE_CPP2A_COMPAT \ - /**/ + CPP_DIAGNOSTIC_IGNORE_CPP2A_COMPAT + #define CPP_PP_IGNORE_CXX2A_COMPAT_END \ - CPP_DIAGNOSTIC_POP \ - /**/ + CPP_DIAGNOSTIC_POP + #else #define CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN #define CPP_PP_IGNORE_CXX2A_COMPAT_END @@ -107,16 +107,15 @@ 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,)) \ - /**/ + 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 \ - /**/ + N #define CPP_PP_IIF(BIT) CPP_PP_CAT_(CPP_PP_IIF_, BIT) #define CPP_PP_IIF_0(TRUE, ...) __VA_ARGS__ @@ -134,8 +133,7 @@ #define CPP_PP_LBRACE() { #define CPP_PP_RBRACE() } #define CPP_PP_COMMA_IIF(X) \ - CPP_PP_IIF(X)(CPP_PP_EMPTY, CPP_PP_COMMA)() \ - /**/ + 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__) @@ -159,7 +157,7 @@ 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(~) \ + CPP_PP_PROBE(~) #define CPP_PP_PROBE_EMPTY() #define CPP_PP_IS_NOT_EMPTY(...) \ @@ -167,15 +165,14 @@ CPP_PP_CHECK, \ CPP_PP_CAT( \ CPP_PP_PROBE_EMPTY_PROBE_, \ - CPP_PP_PROBE_EMPTY __VA_ARGS__ ())) \ - /**/ + 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{}))> \ - /**/ + decltype(CPP_true_fn(::concepts::detail::xNil{}))> + #define CPP_NOT(...) (!CPP_BOOL(__VA_ARGS__)) #else #define CPP_BOOL(...) __VA_ARGS__ @@ -185,18 +182,18 @@ #define CPP_assert(...) \ static_assert(static_cast(__VA_ARGS__), \ - "Concept assertion failed : " #__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 //////////////////////////////////////////////////////////////////////////////// @@ -212,41 +209,51 @@ #define CPP_member #define CPP_ctor(TYPE) TYPE CPP_CTOR_IMPL_1_ +#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__) \ - /**/ + 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)) \ - /**/ + CPP_PP_CAT(CPP_TEMPLATE_PROBE_CONCEPT_, FIRST)) /// INTERNAL ONLY #define CPP_TEMPLATE_PROBE_CONCEPT_concept \ - CPP_PP_PROBE(~) \ - /**/ + 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__ \ - /**/ + CPP_concept CPP_CONCEPT_NAME_(DECL) = __VA_ARGS__ #define CPP_concept_ref(NAME, ...) \ - CPP_PP_CAT(NAME, _concept_)<__VA_ARGS__> \ - /**/ + CPP_PP_CAT(NAME, _concept_)<__VA_ARGS__> #else // ^^^^ with concepts / without concepts vvvv @@ -256,8 +263,7 @@ #define CPP_ctor CPP_ctor_sfinae #define CPP_concept_ref(NAME, ...) \ (1u == sizeof(CPP_PP_CAT(NAME, _concept_)( \ - (::concepts::detail::tag<__VA_ARGS__>*)nullptr))) \ - /**/ + (::concepts::detail::tag<__VA_ARGS__>*)nullptr))) /// INTERNAL ONLY #define CPP_TEMPLATE_AUX_ CPP_TEMPLATE_SFINAE_AUX_ @@ -266,27 +272,23 @@ #define CPP_template_sfinae(...) \ CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ - template<__VA_ARGS__ CPP_TEMPLATE_SFINAE_AUX_ \ - /**/ + template<__VA_ARGS__ CPP_TEMPLATE_SFINAE_AUX_ /// INTERNAL ONLY #define CPP_TEMPLATE_SFINAE_PROBE_CONCEPT_concept \ - CPP_PP_PROBE(~) \ - /**/ + 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)) \ - /**/ + 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__) \ - /**/ + CPP_TEMPLATE_SFINAE_AUX_WHICH_(__VA_ARGS__,))(__VA_ARGS__) // A template with a requires clause /// INTERNAL ONLY @@ -296,8 +298,7 @@ CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && \ CPP_BOOL(CPP_true), \ int> = 0> \ - CPP_PP_IGNORE_CXX2A_COMPAT_END \ - /**/ + CPP_PP_IGNORE_CXX2A_COMPAT_END // A concept definition /// INTERNAL ONLY @@ -308,37 +309,30 @@ ::concepts::detail::tag*) \ -> char(&)[1]; \ auto CPP_CONCEPT_NAME_(DECL)(...) -> char(&)[2] \ - CPP_PP_IGNORE_CXX2A_COMPAT_END \ - /**/ + 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_) \ - /**/ + 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)) \ - /**/ + CPP_PP_EVAL(CPP_PP_SECOND, CPP_EAT_CONCEPT_(DECL)) /// INTERNAL ONLY #define CPP_EAT_CONCEPT_(DECL) \ - CPP_PP_CAT(CPP_EAT_CONCEPT_, DECL) \ - /**/ + CPP_PP_CAT(CPP_EAT_CONCEPT_, DECL) /// INTERNAL ONLY -#define CPP_EAT_CONCEPT_concept \ - /**/ +#define CPP_EAT_CONCEPT_concept #define CPP_and_sfinae \ - && CPP_BOOL(CPP_true), int> = 0, std::enable_if_t< \ - /**/ + && CPP_BOOL(CPP_true), int> = 0, std::enable_if_t< #define CPP_template_def_sfinae(...) \ - template<__VA_ARGS__ CPP_TEMPLATE_DEF_SFINAE_AUX_ \ - /**/ + template<__VA_ARGS__ CPP_TEMPLATE_DEF_SFINAE_AUX_ /// INTERNAL ONLY #define CPP_TEMPLATE_DEF_SFINAE_AUX_(...) , \ @@ -346,42 +340,35 @@ std::enable_if_t< \ CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && \ CPP_BOOL(CPP_true), \ - int>> \ - /**/ + int>> #define CPP_and_sfinae_def \ - && CPP_BOOL(CPP_true), int>, std::enable_if_t< \ - /**/ + && 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 \ - /**/ + CPP_broken_friend_member #define CPP_ctor_sfinae(TYPE) \ CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ - TYPE CPP_CTOR_SFINAE_IMPL_1_ \ - /**/ + 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 \ - /**/ + CPP_CTOR_SFINAE_REQUIRES /// INTERNAL ONLY #define CPP_CTOR_SFINAE_PROBE_NOEXCEPT_noexcept \ - CPP_PP_PROBE(~) \ - /**/ + CPP_PP_PROBE(~) /// INTERNAL ONLY #define CPP_CTOR_SFINAE_MAKE_PROBE(FIRST,...) \ - CPP_PP_CAT(CPP_CTOR_SFINAE_PROBE_NOEXCEPT_, FIRST) \ - /**/ + CPP_PP_CAT(CPP_CTOR_SFINAE_PROBE_NOEXCEPT_, FIRST) /// INTERNAL ONLY #define CPP_CTOR_SFINAE_REQUIRES(...) \ @@ -389,8 +376,7 @@ CPP_CTOR_SFINAE_REQUIRES_, \ CPP_PP_EVAL( \ CPP_PP_CHECK, \ - CPP_CTOR_SFINAE_MAKE_PROBE(__VA_ARGS__,)))(__VA_ARGS__) \ - /**/ + CPP_CTOR_SFINAE_MAKE_PROBE(__VA_ARGS__,)))(__VA_ARGS__) // No noexcept-clause: /// INTERNAL ONLY @@ -399,8 +385,7 @@ CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && CPP_TRUE_FN, \ ::concepts::detail::Nil \ > = {}) \ - CPP_PP_IGNORE_CXX2A_COMPAT_END \ - /**/ + CPP_PP_IGNORE_CXX2A_COMPAT_END // Yes noexcept-clause: /// INTERNAL ONLY @@ -411,8 +396,7 @@ 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__))) \ - /**/ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_CTOR_SFINAE_SHOW_NOEXCEPT_, __VA_ARGS__))) /// INTERNAL ONLY #define CPP_CTOR_SFINAE_EAT_NOEXCEPT_noexcept(...) @@ -421,82 +405,71 @@ #define CPP_CTOR_SFINAE_SHOW_NOEXCEPT_noexcept(...) \ noexcept(__VA_ARGS__) \ CPP_PP_IGNORE_CXX2A_COMPAT_END \ - CPP_PP_EAT CPP_PP_LPAREN \ - /**/ + CPP_PP_EAT CPP_PP_LPAREN #ifdef CPP_DOXYGEN_INVOKED #define CPP_broken_friend_ret(...) \ - __VA_ARGS__ CPP_PP_EXPAND \ - /**/ + __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> \ - /**/ + __VA_ARGS__ && CPP_TRUE_FN>> #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_> \ - /**/ + ::concepts::detail::CPP_true_fn_> + #else // ^^^ workaround / no workaround vvv #define CPP_broken_friend_member \ template \ - /**/ + ::concepts::detail::CPP_true_fn> + #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) \ - /**/ + CPP_PP_CAT(CPP_REQUIRES_, REQS) #define CPP_requires_ref(NAME, ...) \ - CPP_PP_CAT(NAME, _requires_)<__VA_ARGS__> \ - /**/ + CPP_PP_CAT(NAME, _requires_)<__VA_ARGS__> /// INTERNAL ONLY #define CPP_REQUIRES_requires(...) \ - requires(__VA_ARGS__) CPP_REQUIRES_AUX_ \ - /**/ + requires(__VA_ARGS__) CPP_REQUIRES_AUX_ /// INTERNAL ONLY #define CPP_REQUIRES_AUX_(...) \ - { __VA_ARGS__; } \ - /**/ + { __VA_ARGS__; } #else #define CPP_requires(NAME, REQS) \ auto CPP_PP_CAT(NAME, _requires_test_) \ - CPP_REQUIRES_AUX_(NAME, CPP_REQUIRES_ ## REQS) \ - /**/ + 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))) \ - /**/ + (::concepts::detail::tag<__VA_ARGS__>*)nullptr))) /// INTERNAL ONLY #define CPP_REQUIRES_requires(...) \ - (__VA_ARGS__) -> decltype CPP_REQUIRES_RETURN_ \ - /**/ + (__VA_ARGS__) -> decltype CPP_REQUIRES_RETURN_ /// INTERNAL ONLY #define CPP_REQUIRES_RETURN_(...) (__VA_ARGS__, void()) {} @@ -509,28 +482,45 @@ CPP_concept 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] \ - /**/ + 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 \ - /**/ + __VA_ARGS__ CPP_PP_EXPAND +#endif + #else #define CPP_ret \ - CPP_broken_friend_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_PP_EXPAND \ - /**/ + 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 @@ -538,23 +528,20 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = (__VA_ARGS__ \ CPP_PP_COMMA_IIF( \ CPP_PP_NOT(CPP_PP_IS_NOT_EMPTY(__VA_ARGS__))) \ - CPP_FUN_IMPL_REQUIRES \ - /**/ + CPP_FUN_IMPL_REQUIRES /// INTERNAL ONLY #define CPP_FUN_IMPL_REQUIRES(...) \ CPP_PP_EVAL2_( \ CPP_FUN_IMPL_SELECT_CONST_, \ (__VA_ARGS__,) \ - )(__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))) \ - /**/ + CPP_PP_PROBE_CONST_PROBE_, MAYBE_CONST))) /// INTERNAL ONLY #define CPP_PP_PROBE_CONST_PROBE_const CPP_PP_PROBE(~) @@ -564,15 +551,13 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = 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__)) \ - /**/ + 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))) \ - /**/ + CPP_PP_PROBE_NOEXCEPT_PROBE_, MAYBE_NOEXCEPT))) /// INTERNAL ONLY #define CPP_PP_PROBE_NOEXCEPT_PROBE_noexcept CPP_PP_PROBE(~) @@ -586,8 +571,7 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = __VA_ARGS__) && CPP_TRUE_FN, \ ::concepts::detail::Nil \ > = {}) const \ - CPP_PP_IGNORE_CXX2A_COMPAT_END \ - /**/ + CPP_PP_IGNORE_CXX2A_COMPAT_END /// INTERNAL ONLY #define CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_1(...) \ @@ -598,8 +582,7 @@ CPP_concept CPP_PP_CAT(NAME, _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__))) \ - /**/ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_FUN_IMPL_SHOW_NOEXCEPT_, __VA_ARGS__))) /// INTERNAL ONLY #define CPP_FUN_IMPL_EAT_NOEXCEPT_noexcept(...) @@ -607,23 +590,20 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = /// INTERNAL ONLY #define CPP_FUN_IMPL_SHOW_NOEXCEPT_noexcept(...) \ noexcept(__VA_ARGS__) CPP_PP_IGNORE_CXX2A_COMPAT_END \ - CPP_PP_EAT CPP_PP_LPAREN \ - /**/ + 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__) \ - /**/ + )(__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))) \ - /**/ + CPP_PP_PROBE_NOEXCEPT_PROBE_, MAYBE_NOEXCEPT))) /// INTERNAL ONLY #define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_0(...) \ @@ -631,8 +611,7 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = CPP_PP_CAT(CPP_FUN_IMPL_EAT_REQUIRES_, __VA_ARGS__) && CPP_TRUE_FN, \ ::concepts::detail::Nil \ > = {}) \ - CPP_PP_IGNORE_CXX2A_COMPAT_END \ - /**/ + CPP_PP_IGNORE_CXX2A_COMPAT_END /// INTERNAL ONLY #define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_1(...) \ @@ -644,8 +623,7 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = ) && CPP_TRUE_FN, \ ::concepts::detail::Nil \ > = {}) \ - CPP_PP_EXPAND(CPP_PP_CAT(CPP_FUN_IMPL_SHOW_NOEXCEPT_, __VA_ARGS__))) \ - /**/ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_FUN_IMPL_SHOW_NOEXCEPT_, __VA_ARGS__))) /// INTERNAL ONLY #define CPP_FUN_IMPL_EAT_CONST_const @@ -684,15 +662,13 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = CPP_PP_EVAL2_( \ CPP_AUTO_FUN_SELECT_RETURNS_, \ (__VA_ARGS__,) \ - )(__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))) \ - /**/ + CPP_PP_PROBE_CONST_MUTABLE_PROBE_, MAYBE_CONST))) /// INTERNAL ONLY #define CPP_PP_PROBE_CONST_MUTABLE_PROBE_const CPP_PP_PROBE_N(~, 1) @@ -709,14 +685,12 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = /// INTERNAL ONLY #define CPP_AUTO_FUN_RETURNS_CONST_1(...) \ - __VA_ARGS__ CPP_AUTO_FUN_RETURNS_CONST_0 \ - /**/ + __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__)) \ - /**/ + CPP_PP_CAT(CPP_AUTO_FUN_RETURNS_, __VA_ARGS__)) /// INTERNAL ONLY #define CPP_AUTO_FUN_RETURNS_return @@ -725,15 +699,15 @@ CPP_concept CPP_PP_CAT(NAME, _requires_) = /// INTERNAL ONLY #define CPP_AUTO_FUN_DECLTYPE_NOEXCEPT_(...) \ noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ - { return (__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__); } \ - /**/ + { return (__VA_ARGS__); } + #endif namespace concepts diff --git a/include/range/v3/action/action.hpp b/include/range/v3/action/action.hpp index dfe9881991..3d6ee24271 100644 --- a/include/range/v3/action/action.hpp +++ b/include/range/v3/action/action.hpp @@ -72,9 +72,10 @@ namespace ranges { // clang-format off // Piping requires things are passed by value. - template(typename Rng, typename ActionFn)( // - requires (!std::is_lvalue_reference::value) AND // - range AND invocable_action_closure) // + template(typename Rng, typename ActionFn)( + /// \pre + requires (!std::is_lvalue_reference::value) AND + range AND invocable_action_closure) friend constexpr auto operator|(Rng && rng, action_closure act) { @@ -96,6 +97,7 @@ namespace ranges template friend constexpr auto operator|(action_closure act, Pipeable pipe) -> CPP_broken_friend_ret(action_closure>)( + /// \pre requires (is_pipeable_v)) { return make_action_closure(compose(static_cast(pipe), @@ -104,7 +106,8 @@ namespace ranges template friend constexpr auto operator|=(Rng & rng, action_closure act) // - -> CPP_broken_friend_ret(Rng &)( // + -> CPP_broken_friend_ret(Rng &)( + /// \pre requires range && invocable) { static_cast(act)(rng); @@ -204,8 +207,9 @@ namespace ranges {} // Calling directly requires things are passed by reference. - template(typename Rng, typename... Rest)( // - requires range AND invocable) // + template(typename Rng, typename... Rest)( + /// \pre + requires range AND invocable) invoke_result_t // operator()(Rng & rng, Rest &&... rest) const { @@ -215,6 +219,7 @@ namespace ranges // Currying overload. // clang-format off template(typename... Rest, typename A = Action)( + /// \pre requires (sizeof...(Rest) != 0)) auto CPP_auto_fun(operator())(Rest &&... rest)(const) ( diff --git a/include/range/v3/action/adjacent_remove_if.hpp b/include/range/v3/action/adjacent_remove_if.hpp index b1262c34e4..bcd7e158c2 100644 --- a/include/range/v3/action/adjacent_remove_if.hpp +++ b/include/range/v3/action/adjacent_remove_if.hpp @@ -36,7 +36,8 @@ namespace ranges { struct adjacent_remove_if_fn { - template(typename Pred, typename Proj = identity)( // + template(typename Pred, typename Proj = identity)( + /// \pre requires (!range)) constexpr auto operator()(Pred pred, Proj proj = {}) const { @@ -44,11 +45,12 @@ namespace ranges bind_back(adjacent_remove_if_fn{}, std::move(pred), std::move(proj))); } - template(typename Rng, typename Pred, typename Proj = identity)( // + template(typename Rng, typename Pred, typename Proj = identity)( + /// \pre requires forward_range AND erasable_range, sentinel_t> AND indirect_relation, Proj>> AND - permutable>) // + permutable>) Rng operator()(Rng && rng, Pred pred, Proj proj = {}) const { auto i = adjacent_remove_if(rng, std::move(pred), std::move(proj)); diff --git a/include/range/v3/action/concepts.hpp b/include/range/v3/action/concepts.hpp index f09affc6de..3db316727d 100644 --- a/include/range/v3/action/concepts.hpp +++ b/include/range/v3/action/concepts.hpp @@ -111,30 +111,34 @@ namespace ranges /// \cond namespace detail { - template(typename T)( // - requires container) // + template(typename T)( + /// \pre + requires container) std::true_type is_lvalue_container_like(T &) noexcept { return {}; } - template(typename T)( // - requires container) // + template(typename T)( + /// \pre + requires container) meta::not_> // is_lvalue_container_like(reference_wrapper) noexcept { return {}; } - template(typename T)( // - requires container) // + template(typename T)( + /// \pre + requires container) std::true_type is_lvalue_container_like(std::reference_wrapper) noexcept { return {}; } - template(typename T)( // - requires container) // + template(typename T)( + /// \pre + requires container) std::true_type is_lvalue_container_like(ref_view) noexcept { return {}; diff --git a/include/range/v3/action/drop.hpp b/include/range/v3/action/drop.hpp index 119407a955..3090dc5689 100644 --- a/include/range/v3/action/drop.hpp +++ b/include/range/v3/action/drop.hpp @@ -34,7 +34,8 @@ namespace ranges { struct drop_fn { - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { @@ -42,9 +43,10 @@ namespace ranges return make_action_closure(bind_back(drop_fn{}, n)); } - template(typename Rng)( // - requires forward_range AND // - erasable_range, iterator_t>) // + template(typename Rng)( + /// \pre + requires forward_range AND + erasable_range, iterator_t>) Rng operator()(Rng && rng, range_difference_t n) const { RANGES_EXPECT(n >= 0); diff --git a/include/range/v3/action/drop_while.hpp b/include/range/v3/action/drop_while.hpp index a713df7371..4b8b7da5f9 100644 --- a/include/range/v3/action/drop_while.hpp +++ b/include/range/v3/action/drop_while.hpp @@ -34,17 +34,19 @@ namespace ranges { struct drop_while_fn { - template(typename Fun)( // + template(typename Fun)( + /// \pre requires (!range)) constexpr auto operator()(Fun fun) const { return make_action_closure(bind_back(drop_while_fn{}, std::move(fun))); } - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires forward_range AND indirect_unary_predicate> AND - erasable_range, iterator_t>) // + erasable_range, iterator_t>) Rng operator()(Rng && rng, Fun fun) const { ranges::actions::erase( diff --git a/include/range/v3/action/erase.hpp b/include/range/v3/action/erase.hpp index 98d9a81711..4b431f01ba 100644 --- a/include/range/v3/action/erase.hpp +++ b/include/range/v3/action/erase.hpp @@ -28,9 +28,10 @@ namespace ranges /// \cond namespace adl_erase_detail { - template(typename Cont, typename I, typename S)( // - requires lvalue_container_like AND forward_iterator AND // - sentinel_for) // + template(typename Cont, typename I, typename S)( + /// \pre + requires lvalue_container_like AND forward_iterator AND + sentinel_for) auto erase(Cont && cont, I first, S last) // -> decltype(unwrap_reference(cont).erase(first, last)) { @@ -39,8 +40,9 @@ namespace ranges struct erase_fn { - template(typename Rng, typename I, typename S)( // - requires range AND forward_iterator AND sentinel_for) // + template(typename Rng, typename I, typename S)( + /// \pre + requires range AND forward_iterator AND sentinel_for) auto operator()(Rng && rng, I first, S last) const -> decltype(erase((Rng &&) rng, first, last)) { diff --git a/include/range/v3/action/insert.hpp b/include/range/v3/action/insert.hpp index 875a922101..24c817c1b1 100644 --- a/include/range/v3/action/insert.hpp +++ b/include/range/v3/action/insert.hpp @@ -36,7 +36,8 @@ namespace ranges using insert_result_t = decltype( unwrap_reference(std::declval()).insert(std::declval()...)); - template(typename Cont, typename T)( // + template(typename Cont, typename T)( + /// \pre requires lvalue_container_like AND (!range && constructible_from, T>)) // insert_result_t insert(Cont && cont, T && t) @@ -44,7 +45,8 @@ namespace ranges return unwrap_reference(cont).insert(static_cast(t)); } - template(typename Cont, typename I, typename S)( // + template(typename Cont, typename I, typename S)( + /// \pre requires lvalue_container_like AND sentinel_for AND (!range)) insert_result_t, detail::cpp17_iterator_t> @@ -54,8 +56,9 @@ namespace ranges detail::cpp17_iterator_t{j}); } - template(typename Cont, typename Rng)( // - requires lvalue_container_like AND range) // + template(typename Cont, typename Rng)( + /// \pre + requires lvalue_container_like AND range) insert_result_t, detail::range_cpp17_iterator_t> insert(Cont && cont, Rng && rng) @@ -65,17 +68,19 @@ namespace ranges detail::range_cpp17_iterator_t{ranges::end(rng)}); } - template(typename Cont, typename I, typename T)( // - requires lvalue_container_like AND input_iterator AND // + template(typename Cont, typename I, typename T)( + /// \pre + requires lvalue_container_like AND input_iterator AND (!range && constructible_from, T>)) // insert_result_t insert(Cont && cont, I p, T && t) { return unwrap_reference(cont).insert(p, static_cast(t)); } - template(typename Cont, typename I, typename N, typename T)( // - requires lvalue_container_like AND input_iterator AND // - integral AND constructible_from, T>) // + template(typename Cont, typename I, typename N, typename T)( + /// \pre + requires lvalue_container_like AND input_iterator AND + integral AND constructible_from, T>) insert_result_t insert(Cont && cont, I p, N n, T && t) { return unwrap_reference(cont).insert(p, n, static_cast(t)); @@ -87,9 +92,10 @@ namespace ranges using ranges::detail::cpp17_iterator_t; using ranges::detail::range_cpp17_iterator_t; - template(typename Cont, typename P)( // + template(typename Cont, typename P)( + /// \pre requires container AND input_iterator

AND - random_access_reservable) // + random_access_reservable) iterator_t insert_reserve_helper( Cont & cont, P const p, range_size_t const delta) { @@ -110,7 +116,8 @@ namespace ranges return ranges::begin(cont) + index; } - template(typename Cont, typename P, typename I, typename S)( // + template(typename Cont, typename P, typename I, typename S)( + /// \pre requires sentinel_for AND (!range)) // auto insert_impl(Cont && cont, P p, I i, S j, std::false_type) -> decltype(unwrap_reference(cont).insert( @@ -120,7 +127,8 @@ namespace ranges return unwrap_reference(cont).insert(p, C{i}, C{j}); } - template(typename Cont, typename P, typename I, typename S)( // + template(typename Cont, typename P, typename I, typename S)( + /// \pre requires sized_sentinel_for AND random_access_reservable AND (!range)) // auto insert_impl(Cont && cont_, P p, I i, S j, std::true_type) @@ -135,8 +143,9 @@ namespace ranges return cont.insert(pos, C{std::move(i)}, C{std::move(j)}); } - template(typename Cont, typename I, typename Rng)( // - requires range) // + template(typename Cont, typename I, typename Rng)( + /// \pre + requires range) auto insert_impl(Cont && cont, I p, Rng && rng, std::false_type) -> decltype(unwrap_reference(cont).insert( p, range_cpp17_iterator_t{ranges::begin(rng)}, @@ -147,8 +156,9 @@ namespace ranges p, C{ranges::begin(rng)}, C{ranges::end(rng)}); } - template(typename Cont, typename I, typename Rng)( // - requires random_access_reservable AND sized_range) // + template(typename Cont, typename I, typename Rng)( + /// \pre + requires random_access_reservable AND sized_range) auto insert_impl(Cont && cont_, I p, Rng && rng, std::true_type) -> decltype(unwrap_reference(cont_).insert( begin(unwrap_reference(cont_)), @@ -164,7 +174,8 @@ namespace ranges } // namespace detail /// \endcond - template(typename Cont, typename P, typename I, typename S)( // + template(typename Cont, typename P, typename I, typename S)( + /// \pre requires lvalue_container_like AND input_iterator

AND sentinel_for AND (!range)) // @@ -185,8 +196,9 @@ namespace ranges sized_sentinel_for>{}); } - template(typename Cont, typename I, typename Rng)( // - requires lvalue_container_like AND input_iterator AND range) // + template(typename Cont, typename I, typename Rng)( + /// \pre + requires lvalue_container_like AND input_iterator AND range) auto insert(Cont && cont, I p, Rng && rng) -> decltype(detail::insert_impl( static_cast(cont), std::move(p), static_cast(rng), @@ -205,16 +217,18 @@ namespace ranges using insert_result_t = decltype(insert(std::declval(), std::declval()...)); - template(typename Rng, typename T)( // - requires range AND // - (!range)&&constructible_from, T>) // + template(typename Rng, typename T)( + /// \pre + requires range AND + (!range)&&constructible_from, T>) insert_result_t operator()(Rng && rng, T && t) const { return insert(static_cast(rng), static_cast(t)); } - template(typename Rng, typename Rng2)( // - requires range AND range) // + template(typename Rng, typename Rng2)( + /// \pre + requires range AND range) insert_result_t operator()(Rng && rng, Rng2 && rng2) const { static_assert(!is_infinite::value, @@ -222,32 +236,36 @@ namespace ranges return insert(static_cast(rng), static_cast(rng2)); } - template(typename Rng, typename T)( // - requires range) // + template(typename Rng, typename T)( + /// \pre + requires range) insert_result_t &> // operator()(Rng && rng, std::initializer_list rng2) const { return insert(static_cast(rng), rng2); } - template(typename Rng, typename I, typename S)( // + template(typename Rng, typename I, typename S)( + /// \pre requires range AND sentinel_for AND (!range)) // insert_result_t operator()(Rng && rng, I i, S j) const { return insert(static_cast(rng), std::move(i), std::move(j)); } - template(typename Rng, typename I, typename T)( // - requires range AND input_iterator AND // - (!range)&&constructible_from, T>) // + template(typename Rng, typename I, typename T)( + /// \pre + requires range AND input_iterator AND + (!range)&&constructible_from, T>) insert_result_t operator()(Rng && rng, I p, T && t) const { return insert( static_cast(rng), std::move(p), static_cast(t)); } - template(typename Rng, typename I, typename Rng2)( // - requires range AND input_iterator AND range) // + template(typename Rng, typename I, typename Rng2)( + /// \pre + requires range AND input_iterator AND range) insert_result_t operator()(Rng && rng, I p, Rng2 && rng2) const { static_assert(!is_infinite::value, @@ -256,25 +274,28 @@ namespace ranges static_cast(rng), std::move(p), static_cast(rng2)); } - template(typename Rng, typename I, typename T)( // - requires range AND input_iterator) // + template(typename Rng, typename I, typename T)( + /// \pre + requires range AND input_iterator) insert_result_t &> // operator()(Rng && rng, I p, std::initializer_list rng2) const { return insert(static_cast(rng), std::move(p), rng2); } - template(typename Rng, typename I, typename N, typename T)( // - requires range AND input_iterator AND integral AND // - (!range)&&constructible_from, T>) // + template(typename Rng, typename I, typename N, typename T)( + /// \pre + requires range AND input_iterator AND integral AND + (!range)&&constructible_from, T>) insert_result_t operator()(Rng && rng, I p, N n, T && t) const { return insert( static_cast(rng), std::move(p), n, static_cast(t)); } - template(typename Rng, typename P, typename I, typename S)( // - requires range AND input_iterator

AND sentinel_for AND // + template(typename Rng, typename P, typename I, typename S)( + /// \pre + requires range AND input_iterator

AND sentinel_for AND (!range)) // insert_result_t operator()(Rng && rng, P p, I i, S j) const { diff --git a/include/range/v3/action/join.hpp b/include/range/v3/action/join.hpp index d25b67e9d8..e49f6ae365 100644 --- a/include/range/v3/action/join.hpp +++ b/include/range/v3/action/join.hpp @@ -43,9 +43,10 @@ namespace ranges struct join_fn { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires input_range AND input_range> AND - semiregular>) // + semiregular>) join_action_value_t_ operator()(Rng && rng) const { join_action_value_t_ ret; diff --git a/include/range/v3/action/push_back.hpp b/include/range/v3/action/push_back.hpp index df43b052e5..cef5092062 100644 --- a/include/range/v3/action/push_back.hpp +++ b/include/range/v3/action/push_back.hpp @@ -45,16 +45,18 @@ namespace ranges ranges::insert(std::declval(), std::declval>(), std::declval()))); - template(typename Cont, typename T)( // + template(typename Cont, typename T)( + /// \pre requires lvalue_container_like AND - (!range)&&constructible_from, T>) // + (!range)&&constructible_from, T>) push_back_t push_back(Cont && cont, T && t) { unwrap_reference(cont).push_back(static_cast(t)); } - template(typename Cont, typename Rng)( // - requires lvalue_container_like AND range) // + template(typename Cont, typename Rng)( + /// \pre + requires lvalue_container_like AND range) insert_t push_back(Cont && cont, Rng && rng) { ranges::insert(cont, end(cont), static_cast(rng)); @@ -83,7 +85,8 @@ namespace ranges bind_back(push_back_fn{}, static_cast(val))); } - template(typename T)( // + template(typename T)( + /// \pre requires range) constexpr auto operator()(T & t) const { @@ -97,8 +100,9 @@ namespace ranges return make_action_closure(bind_back(push_back_fn{}, val)); } - template(typename Rng, typename T)( // - requires input_range AND can_push_back_ AND // + template(typename Rng, typename T)( + /// \pre + requires input_range AND can_push_back_ AND (range || constructible_from, T>)) // Rng operator()(Rng && rng, T && t) const // { @@ -106,10 +110,11 @@ namespace ranges return static_cast(rng); } - template(typename Rng, typename T)( // - requires input_range AND // - can_push_back_> AND // - constructible_from, T const &>) // + template(typename Rng, typename T)( + /// \pre + requires input_range AND + can_push_back_> AND + constructible_from, T const &>) Rng operator()(Rng && rng, std::initializer_list t) const // { push_back(rng, t); diff --git a/include/range/v3/action/push_front.hpp b/include/range/v3/action/push_front.hpp index 8fb7948af4..392411ea6e 100644 --- a/include/range/v3/action/push_front.hpp +++ b/include/range/v3/action/push_front.hpp @@ -45,16 +45,18 @@ namespace ranges ranges::insert(std::declval(), std::declval>(), std::declval()))); - template(typename Cont, typename T)( // + template(typename Cont, typename T)( + /// \pre requires lvalue_container_like AND - (!range)&&constructible_from, T>) // + (!range)&&constructible_from, T>) push_front_t push_front(Cont && cont, T && t) { unwrap_reference(cont).push_front(static_cast(t)); } - template(typename Cont, typename Rng)( // - requires lvalue_container_like AND range) // + template(typename Cont, typename Rng)( + /// \pre + requires lvalue_container_like AND range) insert_t push_front(Cont && cont, Rng && rng) { ranges::insert(cont, begin(cont), static_cast(rng)); @@ -87,7 +89,8 @@ namespace ranges return make_action_closure(bind_back(push_front_fn{}, val)); } - template(typename T)( // + template(typename T)( + /// \pre requires range) constexpr auto operator()(T & t) const { @@ -95,8 +98,9 @@ namespace ranges bind_back(push_front_fn{}, detail::reference_wrapper_(t))); } - template(typename Rng, typename T)( // - requires input_range AND can_push_front_ AND // + template(typename Rng, typename T)( + /// \pre + requires input_range AND can_push_front_ AND (range || constructible_from, T>)) // Rng operator()(Rng && rng, T && t) const // { @@ -104,10 +108,11 @@ namespace ranges return static_cast(rng); } - template(typename Rng, typename T)( // - requires input_range AND // + template(typename Rng, typename T)( + /// \pre + requires input_range AND can_push_front_> AND - constructible_from, T const &>) // + constructible_from, T const &>) Rng operator()(Rng && rng, std::initializer_list t) const // { push_front(rng, t); diff --git a/include/range/v3/action/remove.hpp b/include/range/v3/action/remove.hpp index 0460f9ee2c..b2038dcf42 100644 --- a/include/range/v3/action/remove.hpp +++ b/include/range/v3/action/remove.hpp @@ -35,7 +35,8 @@ namespace ranges { struct remove_fn { - template(typename V, typename P)( // + template(typename V, typename P)( + /// \pre requires (!range)) constexpr auto operator()(V && value, P proj) const { @@ -50,11 +51,12 @@ namespace ranges bind_back(remove_fn{}, static_cast(value), identity{})); } - template(typename Rng, typename V, typename P = identity)( // + template(typename Rng, typename V, typename P = identity)( + /// \pre requires forward_range AND permutable> AND erasable_range, sentinel_t> AND indirect_relation, P>, - V const *>) // + V const *>) Rng operator()(Rng && rng, V const & value, P proj = {}) const { auto it = ranges::remove(rng, value, std::move(proj)); diff --git a/include/range/v3/action/remove_if.hpp b/include/range/v3/action/remove_if.hpp index b65f855710..3149501e0b 100644 --- a/include/range/v3/action/remove_if.hpp +++ b/include/range/v3/action/remove_if.hpp @@ -38,7 +38,8 @@ namespace ranges { struct remove_if_fn { - template(typename C, typename P = identity)( // + template(typename C, typename P = identity)( + /// \pre requires (!range)) constexpr auto operator()(C pred, P proj = P{}) const { @@ -46,11 +47,12 @@ namespace ranges bind_back(remove_if_fn{}, std::move(pred), std::move(proj))); } - template(typename Rng, typename C, typename P = identity)( // + template(typename Rng, typename C, typename P = identity)( + /// \pre requires forward_range AND erasable_range, iterator_t> AND permutable> AND - indirect_unary_predicate, P>>) // + indirect_unary_predicate, P>>) Rng operator()(Rng && rng, C pred, P proj = P{}) const { auto it = ranges::remove_if(rng, std::move(pred), std::move(proj)); diff --git a/include/range/v3/action/reverse.hpp b/include/range/v3/action/reverse.hpp index 1e25c1abbd..6c392699cf 100644 --- a/include/range/v3/action/reverse.hpp +++ b/include/range/v3/action/reverse.hpp @@ -34,8 +34,9 @@ namespace ranges /// Reversed the source range in-place. struct reverse_fn { - template(typename Rng)( // - requires bidirectional_range AND permutable>) // + template(typename Rng)( + /// \pre + requires bidirectional_range AND permutable>) Rng operator()(Rng && rng) const { ranges::reverse(rng); diff --git a/include/range/v3/action/shuffle.hpp b/include/range/v3/action/shuffle.hpp index c18b3b8248..9c542380ad 100644 --- a/include/range/v3/action/shuffle.hpp +++ b/include/range/v3/action/shuffle.hpp @@ -35,7 +35,8 @@ namespace ranges { struct shuffle_fn { - template(typename Gen)( // + template(typename Gen)( + /// \pre requires uniform_random_bit_generator) constexpr auto operator()(Gen & gen) const { @@ -43,7 +44,8 @@ namespace ranges bind_back(shuffle_fn{}, detail::reference_wrapper_(gen))); } - template(typename Gen)( // + template(typename Gen)( + /// \pre requires uniform_random_bit_generator) constexpr auto operator()(Gen && gen) const { @@ -51,7 +53,8 @@ namespace ranges bind_back(shuffle_fn{}, static_cast(gen))); } - template(typename Rng, typename Gen)( // + template(typename Rng, typename Gen)( + /// \pre requires random_access_range AND permutable> AND uniform_random_bit_generator> AND convertible_to, range_difference_t>) diff --git a/include/range/v3/action/slice.hpp b/include/range/v3/action/slice.hpp index 5c9d6710da..fb6b990cfb 100644 --- a/include/range/v3/action/slice.hpp +++ b/include/range/v3/action/slice.hpp @@ -43,40 +43,46 @@ namespace ranges public: // Overloads for the pipe syntax: rng | actions::slice(from, to) - template(typename D)( // + template(typename D)( + /// \pre requires integral) constexpr auto operator()(D from, D to) const { return make_action_closure(bind_back(slice_fn{}, from, to)); } - template(typename D)( // + template(typename D)( + /// \pre requires integral) constexpr auto operator()(D from, detail::from_end_ to) const { return make_action_closure(bind_back(slice_fn{}, from, to)); } - template(typename D)( // + template(typename D)( + /// \pre requires integral) constexpr auto operator()(detail::from_end_ from, detail::from_end_ to) const { return make_action_closure(bind_back(slice_fn{}, from, to)); } - template(typename D)( // + template(typename D)( + /// \pre requires integral) constexpr auto operator()(D from, end_fn const & to) const { return make_action_closure(bind_back(slice_fn{}, from, to)); } - template(typename D)( // + template(typename D)( + /// \pre requires integral) constexpr auto operator()(detail::from_end_ from, end_fn const & to) const { return make_action_closure(bind_back(slice_fn{}, from, to)); } - template(typename Rng, typename I = iterator_t)( // - requires forward_range AND erasable_range) // + template(typename Rng, typename I = iterator_t)( + /// \pre + requires forward_range AND erasable_range) Rng operator()(Rng && rng, diff_t from, diff_t to) const { RANGES_EXPECT(0 <= from && 0 <= to && from <= to); @@ -86,8 +92,9 @@ namespace ranges return static_cast(rng); } - template(typename Rng, typename I = iterator_t)( // - requires bidirectional_range AND erasable_range) // + template(typename Rng, typename I = iterator_t)( + /// \pre + requires bidirectional_range AND erasable_range) Rng operator()(Rng && rng, diff_t from, detail::from_end_> to) const @@ -103,8 +110,9 @@ namespace ranges return static_cast(rng); } - template(typename Rng, typename I = iterator_t)( // - requires bidirectional_range AND erasable_range) // + template(typename Rng, typename I = iterator_t)( + /// \pre + requires bidirectional_range AND erasable_range) Rng operator()(Rng && rng, detail::from_end_> from, detail::from_end_> to) const @@ -119,8 +127,9 @@ namespace ranges return static_cast(rng); } - template(typename Rng, typename I = iterator_t)( // - requires forward_range AND erasable_range) // + template(typename Rng, typename I = iterator_t)( + /// \pre + requires forward_range AND erasable_range) Rng operator()(Rng && rng, diff_t from, end_fn const &) const { RANGES_EXPECT(0 <= from); @@ -129,8 +138,9 @@ namespace ranges return static_cast(rng); } - template(typename Rng, typename I = iterator_t)( // - requires bidirectional_range AND erasable_range) // + template(typename Rng, typename I = iterator_t)( + /// \pre + requires bidirectional_range AND erasable_range) Rng operator()(Rng && rng, detail::from_end_> from, end_fn const &) const diff --git a/include/range/v3/action/sort.hpp b/include/range/v3/action/sort.hpp index a0ee4b3149..86d771c68f 100644 --- a/include/range/v3/action/sort.hpp +++ b/include/range/v3/action/sort.hpp @@ -35,7 +35,8 @@ namespace ranges { struct sort_fn { - template(typename C, typename P = identity)( // + template(typename C, typename P = identity)( + /// \pre requires (!range)) constexpr auto operator()(C pred, P proj = {}) const { @@ -43,8 +44,9 @@ namespace ranges bind_back(sort_fn{}, std::move(pred), std::move(proj))); } - template(typename Rng, typename C = less, typename P = identity)( // - requires forward_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires forward_range AND sortable, C, P>) Rng operator()(Rng && rng, C pred = {}, P proj = {}) const { ranges::sort(rng, std::move(pred), std::move(proj)); diff --git a/include/range/v3/action/split.hpp b/include/range/v3/action/split.hpp index 0bc4b58a31..0f7f5649de 100644 --- a/include/range/v3/action/split.hpp +++ b/include/range/v3/action/split.hpp @@ -44,7 +44,8 @@ namespace ranges meta::if_c<(bool)ranges::container, // uncvref_t, std::vector>>; - template(typename T)( // + template(typename T)( + /// \pre requires range) constexpr auto operator()(T & t) const { @@ -60,9 +61,10 @@ namespace ranges // BUGBUG something is not right with the actions. It should be possible // to move a container into a split and have elements moved into the result. - template(typename Rng)( // + template(typename Rng)( + /// \pre requires input_range AND indirectly_comparable< - iterator_t, range_value_t const *, ranges::equal_to>) // + iterator_t, range_value_t const *, ranges::equal_to>) std::vector> // operator()(Rng && rng, range_value_t val) const { @@ -70,9 +72,10 @@ namespace ranges to>>(); } - template(typename Rng, typename Pattern)( // + template(typename Rng, typename Pattern)( + /// \pre requires input_range AND viewable_range AND - forward_range AND // + forward_range AND indirectly_comparable< iterator_t, iterator_t, diff --git a/include/range/v3/action/split_when.hpp b/include/range/v3/action/split_when.hpp index 742a9a9d1b..4bc8d7eb50 100644 --- a/include/range/v3/action/split_when.hpp +++ b/include/range/v3/action/split_when.hpp @@ -54,24 +54,26 @@ namespace ranges // BUGBUG something is not right with the actions. It should be possible // to move a container into a split and have elements moved into the result. - template(typename Rng, typename Fun)( // - requires forward_range AND // - invocable, sentinel_t> AND // + template(typename Rng, typename Fun)( + /// \pre + requires forward_range AND + invocable, sentinel_t> AND invocable, iterator_t> AND copy_constructible AND convertible_to, sentinel_t>, - std::pair>>) // + std::pair>>) std::vector> operator()(Rng && rng, Fun fun) const { return views::split_when(rng, std::move(fun)) | to>>(); } - template(typename Rng, typename Fun)( // - requires forward_range AND // - predicate> AND // - copy_constructible) // + template(typename Rng, typename Fun)( + /// \pre + requires forward_range AND + predicate> AND + copy_constructible) std::vector> operator()(Rng && rng, Fun fun) const { return views::split_when(rng, std::move(fun)) | diff --git a/include/range/v3/action/stable_sort.hpp b/include/range/v3/action/stable_sort.hpp index d773029338..9542c442c0 100644 --- a/include/range/v3/action/stable_sort.hpp +++ b/include/range/v3/action/stable_sort.hpp @@ -35,7 +35,8 @@ namespace ranges { struct stable_sort_fn { - template(typename C, typename P = identity)( // + template(typename C, typename P = identity)( + /// \pre requires (!range)) constexpr auto operator()(C pred, P proj = P{}) const { @@ -43,8 +44,9 @@ namespace ranges bind_back(stable_sort_fn{}, std::move(pred), std::move(proj))); } - template(typename Rng, typename C = less, typename P = identity)( // - requires forward_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires forward_range AND sortable, C, P>) Rng operator()(Rng && rng, C pred = C{}, P proj = P{}) const { ranges::stable_sort(rng, std::move(pred), std::move(proj)); diff --git a/include/range/v3/action/stride.hpp b/include/range/v3/action/stride.hpp index 118095fa19..3a32e77569 100644 --- a/include/range/v3/action/stride.hpp +++ b/include/range/v3/action/stride.hpp @@ -34,17 +34,19 @@ namespace ranges { struct stride_fn { - template(typename D)( // + template(typename D)( + /// \pre requires detail::integer_like_) constexpr auto operator()(D step) const { return make_action_closure(bind_back(stride_fn{}, step)); } - template(typename Rng, typename D = range_difference_t)( // - requires forward_range AND // - erasable_range, sentinel_t> AND // - permutable>) // + template(typename Rng, typename D = range_difference_t)( + /// \pre + requires forward_range AND + erasable_range, sentinel_t> AND + permutable>) Rng operator()(Rng && rng, range_difference_t const step) const { using I = iterator_t; diff --git a/include/range/v3/action/take.hpp b/include/range/v3/action/take.hpp index 5d59485676..d17c56fe66 100644 --- a/include/range/v3/action/take.hpp +++ b/include/range/v3/action/take.hpp @@ -34,16 +34,18 @@ namespace ranges { struct take_fn { - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { return make_action_closure(bind_back(take_fn{}, n)); } - template(typename Rng)( // - requires forward_range AND // - erasable_range, sentinel_t>) // + template(typename Rng)( + /// \pre + requires forward_range AND + erasable_range, sentinel_t>) Rng operator()(Rng && rng, range_difference_t n) const { RANGES_EXPECT(n >= 0); diff --git a/include/range/v3/action/take_while.hpp b/include/range/v3/action/take_while.hpp index 1a30eab184..280a12b3dd 100644 --- a/include/range/v3/action/take_while.hpp +++ b/include/range/v3/action/take_while.hpp @@ -34,17 +34,19 @@ namespace ranges { struct take_while_fn { - template(typename Fun)( // + template(typename Fun)( + /// \pre requires (!range)) constexpr auto operator()(Fun fun) const { return make_action_closure(bind_back(take_while_fn{}, std::move(fun))); } - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires forward_range AND erasable_range, sentinel_t> AND - indirect_unary_predicate>) // + indirect_unary_predicate>) Rng operator()(Rng && rng, Fun fun) const { ranges::actions::erase( diff --git a/include/range/v3/action/transform.hpp b/include/range/v3/action/transform.hpp index c49cc4197a..0cfc5fb35b 100644 --- a/include/range/v3/action/transform.hpp +++ b/include/range/v3/action/transform.hpp @@ -34,7 +34,8 @@ namespace ranges { struct transform_fn { - template(typename F, typename P = identity)( // + template(typename F, typename P = identity)( + /// \pre requires (!range)) constexpr auto operator()(F fun, P proj = P{}) const { @@ -42,11 +43,12 @@ namespace ranges bind_back(transform_fn{}, std::move(fun), std::move(proj))); } - template(typename Rng, typename F, typename P = identity)( // + template(typename Rng, typename F, typename P = identity)( + /// \pre requires input_range AND copy_constructible AND indirectly_writable< iterator_t, - indirect_result_t, P>>>) // + indirect_result_t, P>>>) Rng operator()(Rng && rng, F fun, P proj = P{}) const { ranges::transform(rng, begin(rng), std::move(fun), std::move(proj)); diff --git a/include/range/v3/action/unique.hpp b/include/range/v3/action/unique.hpp index 4d376f082b..66c0cfb121 100644 --- a/include/range/v3/action/unique.hpp +++ b/include/range/v3/action/unique.hpp @@ -36,7 +36,8 @@ namespace ranges { struct unique_fn { - template(typename C, typename P = identity)( // + template(typename C, typename P = identity)( + /// \pre requires (!range)) constexpr auto operator()(C pred, P proj = P{}) const { @@ -44,10 +45,11 @@ namespace ranges bind_back(unique_fn{}, std::move(pred), std::move(proj))); } - template(typename Rng, typename C = equal_to, typename P = identity)( // - requires forward_range AND // - erasable_range, sentinel_t> AND // - sortable, C, P>) // + template(typename Rng, typename C = equal_to, typename P = identity)( + /// \pre + requires forward_range AND + erasable_range, sentinel_t> AND + sortable, C, P>) Rng operator()(Rng && rng, C pred = C{}, P proj = P{}) const { auto it = ranges::unique(rng, std::move(pred), std::move(proj)); diff --git a/include/range/v3/action/unstable_remove_if.hpp b/include/range/v3/action/unstable_remove_if.hpp index 0d2c741608..a663ef6300 100644 --- a/include/range/v3/action/unstable_remove_if.hpp +++ b/include/range/v3/action/unstable_remove_if.hpp @@ -38,7 +38,8 @@ namespace ranges { struct unstable_remove_if_fn { - template(typename C, typename P = identity)( // + template(typename C, typename P = identity)( + /// \pre requires (!range)) constexpr auto operator()(C pred, P proj = P{}) const { @@ -46,11 +47,12 @@ namespace ranges bind_back(unstable_remove_if_fn{}, std::move(pred), std::move(proj))); } - template(typename Rng, typename C, typename P = identity)( // + template(typename Rng, typename C, typename P = identity)( + /// \pre requires bidirectional_range AND common_range AND permutable> AND indirect_unary_predicate, P>> AND - erasable_range, iterator_t>) // + erasable_range, iterator_t>) Rng operator()(Rng && rng, C pred, P proj = P{}) const { auto it = ranges::unstable_remove_if(ranges::begin(rng), diff --git a/include/range/v3/algorithm/adjacent_find.hpp b/include/range/v3/algorithm/adjacent_find.hpp index bc1f71629f..b4ba14e214 100644 --- a/include/range/v3/algorithm/adjacent_find.hpp +++ b/include/range/v3/algorithm/adjacent_find.hpp @@ -38,9 +38,10 @@ namespace ranges /// /// \pre `Rng` is a model of the `range` concept /// \pre `C` is a model of the `BinaryPredicate` concept - template(typename I, typename S, typename C = equal_to, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - indirect_relation>) // + template(typename I, typename S, typename C = equal_to, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + indirect_relation>) I RANGES_FUNC(adjacent_find)(I first, S last, C pred = C{}, P proj = P{}) { if(first == last) @@ -53,9 +54,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C = equal_to, typename P = identity)( // - requires forward_range AND // - indirect_relation, P>>) // + template(typename Rng, typename C = equal_to, typename P = identity)( + /// \pre + requires forward_range AND + indirect_relation, P>>) borrowed_iterator_t // RANGES_FUNC(adjacent_find)(Rng && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/adjacent_remove_if.hpp b/include/range/v3/algorithm/adjacent_remove_if.hpp index 01c18706e0..ec6c1f8d34 100644 --- a/include/range/v3/algorithm/adjacent_remove_if.hpp +++ b/include/range/v3/algorithm/adjacent_remove_if.hpp @@ -44,9 +44,10 @@ namespace ranges /// /// \pre `Rng` is a model of the `forward_range` concept. /// \pre `Pred` is a model of the `BinaryPredicate` concept. - template(typename I, typename S, typename Pred, typename Proj = identity)( // + template(typename I, typename S, typename Pred, typename Proj = identity)( + /// \pre requires permutable AND sentinel_for AND - indirect_relation>) // + indirect_relation>) I RANGES_FUNC(adjacent_remove_if)(I first, S last, Pred pred = {}, Proj proj = {}) { first = adjacent_find(std::move(first), last, std::ref(pred), std::ref(proj)); @@ -69,10 +70,11 @@ namespace ranges } /// \overload - template(typename Rng, typename Pred, typename Proj = identity)( // - requires forward_range AND // - indirect_relation, Proj>> AND // - permutable>) // + template(typename Rng, typename Pred, typename Proj = identity)( + /// \pre + requires forward_range AND + indirect_relation, Proj>> AND + permutable>) borrowed_iterator_t RANGES_FUNC(adjacent_remove_if)(Rng && rng, Pred pred, Proj proj = {}) // { diff --git a/include/range/v3/algorithm/all_of.hpp b/include/range/v3/algorithm/all_of.hpp index b7700adbe2..d6780896dc 100644 --- a/include/range/v3/algorithm/all_of.hpp +++ b/include/range/v3/algorithm/all_of.hpp @@ -35,9 +35,10 @@ namespace ranges RANGES_FUNC_BEGIN(all_of) /// \brief function template \c all_of - template(typename I, typename S, typename F, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename F, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_unary_predicate>) bool RANGES_FUNC(all_of)(I first, S last, F pred, P proj = P{}) // { for(; first != last; ++first) @@ -47,9 +48,10 @@ namespace ranges } /// \overload - template(typename Rng, typename F, typename P = identity)( // - requires input_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename F, typename P = identity)( + /// \pre + requires input_range AND + indirect_unary_predicate, P>>) bool RANGES_FUNC(all_of)(Rng && rng, F pred, P proj = P{}) // { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); diff --git a/include/range/v3/algorithm/any_of.hpp b/include/range/v3/algorithm/any_of.hpp index 7a6b0fa2b5..324e815b44 100644 --- a/include/range/v3/algorithm/any_of.hpp +++ b/include/range/v3/algorithm/any_of.hpp @@ -36,9 +36,10 @@ namespace ranges RANGES_FUNC_BEGIN(any_of) /// \brief function template \c any_of - template(typename I, typename S, typename F, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename F, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_unary_predicate>) bool RANGES_FUNC(any_of)(I first, S last, F pred, P proj = P{}) // { for(; first != last; ++first) @@ -48,9 +49,10 @@ namespace ranges } /// \overload - template(typename Rng, typename F, typename P = identity)( // - requires input_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename F, typename P = identity)( + /// \pre + requires input_range AND + indirect_unary_predicate, P>>) bool RANGES_FUNC(any_of)(Rng && rng, F pred, P proj = P{}) // { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); diff --git a/include/range/v3/algorithm/aux_/equal_range_n.hpp b/include/range/v3/algorithm/aux_/equal_range_n.hpp index 9105a2062e..9ffc797ff0 100644 --- a/include/range/v3/algorithm/aux_/equal_range_n.hpp +++ b/include/range/v3/algorithm/aux_/equal_range_n.hpp @@ -37,9 +37,10 @@ namespace ranges { struct equal_range_n_fn { - template(typename I, typename V, typename R = less, typename P = identity)( // + template(typename I, typename V, typename R = less, typename P = identity)( + /// \pre requires forward_iterator AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) subrange operator()(I first, iter_difference_t dist, V const & val, diff --git a/include/range/v3/algorithm/aux_/lower_bound_n.hpp b/include/range/v3/algorithm/aux_/lower_bound_n.hpp index 15d8b7b837..16c6f1614c 100644 --- a/include/range/v3/algorithm/aux_/lower_bound_n.hpp +++ b/include/range/v3/algorithm/aux_/lower_bound_n.hpp @@ -57,9 +57,10 @@ namespace ranges { struct lower_bound_n_fn { - template(typename I, typename V, typename C = less, typename P = identity)( // + template(typename I, typename V, typename C = less, typename P = identity)( + /// \pre requires forward_iterator AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) I operator()(I first, iter_difference_t d, V const & val, diff --git a/include/range/v3/algorithm/aux_/merge_n.hpp b/include/range/v3/algorithm/aux_/merge_n.hpp index ceec89b212..cb94349526 100644 --- a/include/range/v3/algorithm/aux_/merge_n.hpp +++ b/include/range/v3/algorithm/aux_/merge_n.hpp @@ -56,8 +56,9 @@ namespace ranges struct merge_n_fn { template(typename I0, typename I1, typename O, typename C = less, - typename P0 = identity, typename P1 = identity)( // - requires mergeable) // + typename P0 = identity, typename P1 = identity)( + /// \pre + requires mergeable) merge_n_result operator()(I0 begin0, iter_difference_t n0, I1 begin1, diff --git a/include/range/v3/algorithm/aux_/merge_n_with_buffer.hpp b/include/range/v3/algorithm/aux_/merge_n_with_buffer.hpp index 36341f28d2..a68d0cd44d 100644 --- a/include/range/v3/algorithm/aux_/merge_n_with_buffer.hpp +++ b/include/range/v3/algorithm/aux_/merge_n_with_buffer.hpp @@ -48,10 +48,11 @@ namespace ranges { struct merge_n_with_buffer_fn { - template(typename I, typename B, typename C = less, typename P = identity)( // + template(typename I, typename B, typename C = less, typename P = identity)( + /// \pre requires same_as, iter_common_reference_t> AND - indirectly_copyable AND mergeable) // + indirectly_copyable AND mergeable) I operator()(I begin0, iter_difference_t n0, I begin1, diff --git a/include/range/v3/algorithm/aux_/partition_point_n.hpp b/include/range/v3/algorithm/aux_/partition_point_n.hpp index 8ae6b01f6b..231a63ed9b 100644 --- a/include/range/v3/algorithm/aux_/partition_point_n.hpp +++ b/include/range/v3/algorithm/aux_/partition_point_n.hpp @@ -29,9 +29,10 @@ namespace ranges { struct partition_point_n_fn { - template(typename I, typename C, typename P = identity)( // + template(typename I, typename C, typename P = identity)( + /// \pre requires forward_iterator AND - indirect_unary_predicate>) // + indirect_unary_predicate>) I operator()(I first, iter_difference_t d, C pred, diff --git a/include/range/v3/algorithm/aux_/sort_n_with_buffer.hpp b/include/range/v3/algorithm/aux_/sort_n_with_buffer.hpp index 46a651fe00..1358570491 100644 --- a/include/range/v3/algorithm/aux_/sort_n_with_buffer.hpp +++ b/include/range/v3/algorithm/aux_/sort_n_with_buffer.hpp @@ -48,10 +48,11 @@ namespace ranges { struct sort_n_with_buffer_fn { - template(typename I, typename B, typename C = less, typename P = identity)( // + template(typename I, typename B, typename C = less, typename P = identity)( + /// \pre requires same_as, iter_common_reference_t> AND - indirectly_copyable AND mergeable) // + indirectly_copyable AND mergeable) I operator()(I first, iter_difference_t n, B buff, C r = C{}, P p = P{}) const { diff --git a/include/range/v3/algorithm/aux_/upper_bound_n.hpp b/include/range/v3/algorithm/aux_/upper_bound_n.hpp index 596dfccee3..e4a5a9c3cc 100644 --- a/include/range/v3/algorithm/aux_/upper_bound_n.hpp +++ b/include/range/v3/algorithm/aux_/upper_bound_n.hpp @@ -62,9 +62,10 @@ namespace ranges /// range-based version of the `upper_bound` std algorithm /// /// \pre `Rng` is a model of the `range` concept - template(typename I, typename V, typename C = less, typename P = identity)( // + template(typename I, typename V, typename C = less, typename P = identity)( + /// \pre requires forward_iterator AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) I operator()(I first, iter_difference_t d, V const & val, diff --git a/include/range/v3/algorithm/binary_search.hpp b/include/range/v3/algorithm/binary_search.hpp index 5ce93081d5..baf670c580 100644 --- a/include/range/v3/algorithm/binary_search.hpp +++ b/include/range/v3/algorithm/binary_search.hpp @@ -45,9 +45,10 @@ namespace ranges typename S, typename V, typename C = less, - typename P = identity)( // + typename P = identity)( + /// \pre requires forward_iterator AND sentinel_for AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) bool RANGES_FUNC(binary_search)( I first, S last, V const & val, C pred = C{}, P proj = P{}) { @@ -57,7 +58,8 @@ namespace ranges } /// \overload - template(typename Rng, typename V, typename C = less, typename P = identity)( // + template(typename Rng, typename V, typename C = less, typename P = identity)( + /// \pre requires forward_range AND indirect_strict_weak_order, P>>) bool RANGES_FUNC(binary_search)( diff --git a/include/range/v3/algorithm/contains.hpp b/include/range/v3/algorithm/contains.hpp index 58a9f5835f..bf93cf8ffd 100644 --- a/include/range/v3/algorithm/contains.hpp +++ b/include/range/v3/algorithm/contains.hpp @@ -34,18 +34,20 @@ namespace ranges RANGES_FUNC_BEGIN(contains) /// \brief function template \c contains - template(typename I, typename S, typename T, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_relation, const T *>) // + template(typename I, typename S, typename T, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_relation, const T *>) constexpr bool RANGES_FUNC(contains)(I first, S last, const T & val, P proj = {}) { return find(std::move(first), last, val, std::move(proj)) != last; } /// \overload - template(typename Rng, typename T, typename P = identity)( // - requires input_range AND // - indirect_relation, P>, const T *>) // + template(typename Rng, typename T, typename P = identity)( + /// \pre + requires input_range AND + indirect_relation, P>, const T *>) constexpr bool RANGES_FUNC(contains)(Rng && rng, const T & val, P proj = {}) { return (*this)(begin(rng), end(rng), val, std::move(proj)); diff --git a/include/range/v3/algorithm/copy.hpp b/include/range/v3/algorithm/copy.hpp index f547e7f328..401f68ff7c 100644 --- a/include/range/v3/algorithm/copy.hpp +++ b/include/range/v3/algorithm/copy.hpp @@ -41,9 +41,10 @@ namespace ranges RANGES_FUNC_BEGIN(copy) /// \brief function template \c copy - template(typename I, typename S, typename O)( // - requires input_iterator AND sentinel_for AND // - weakly_incrementable AND indirectly_copyable) // + template(typename I, typename S, typename O)( + /// \pre + requires input_iterator AND sentinel_for AND + weakly_incrementable AND indirectly_copyable) constexpr copy_result RANGES_FUNC(copy)(I first, S last, O out) // { for(; first != last; ++first, ++out) @@ -52,9 +53,10 @@ namespace ranges } /// \overload - template(typename Rng, typename O)( // - requires input_range AND weakly_incrementable AND // - indirectly_copyable, O>) // + template(typename Rng, typename O)( + /// \pre + requires input_range AND weakly_incrementable AND + indirectly_copyable, O>) constexpr copy_result, O> // RANGES_FUNC(copy)(Rng && rng, O out) // { diff --git a/include/range/v3/algorithm/copy_backward.hpp b/include/range/v3/algorithm/copy_backward.hpp index ba28d26394..b0f57e7820 100644 --- a/include/range/v3/algorithm/copy_backward.hpp +++ b/include/range/v3/algorithm/copy_backward.hpp @@ -39,9 +39,10 @@ namespace ranges RANGES_FUNC_BEGIN(copy_backward) /// \brief function template \c copy_backward - template(typename I, typename S, typename O)( // - requires bidirectional_iterator AND sentinel_for AND // - bidirectional_iterator AND indirectly_copyable) // + template(typename I, typename S, typename O)( + /// \pre + requires bidirectional_iterator AND sentinel_for AND + bidirectional_iterator AND indirectly_copyable) copy_backward_result RANGES_FUNC(copy_backward)(I first, S end_, O out) { I i = ranges::next(first, end_), last = i; @@ -51,9 +52,10 @@ namespace ranges } /// \overload - template(typename Rng, typename O)( // - requires bidirectional_range AND bidirectional_iterator AND // - indirectly_copyable, O>) // + template(typename Rng, typename O)( + /// \pre + requires bidirectional_range AND bidirectional_iterator AND + indirectly_copyable, O>) copy_backward_result, O> // RANGES_FUNC(copy_backward)(Rng && rng, O out) { diff --git a/include/range/v3/algorithm/copy_if.hpp b/include/range/v3/algorithm/copy_if.hpp index 0ba9eda38a..6f974cc5d1 100644 --- a/include/range/v3/algorithm/copy_if.hpp +++ b/include/range/v3/algorithm/copy_if.hpp @@ -42,10 +42,11 @@ namespace ranges /// \brief function template \c copy_if template(typename I, typename S, typename O, typename F, typename P = identity)( - requires input_iterator AND sentinel_for AND // - weakly_incrementable AND // - indirect_unary_predicate> AND // - indirectly_copyable) // + /// \pre + requires input_iterator AND sentinel_for AND + weakly_incrementable AND + indirect_unary_predicate> AND + indirectly_copyable) copy_if_result // RANGES_FUNC(copy_if)(I first, S last, O out, F pred, P proj = P{}) // { @@ -62,10 +63,11 @@ namespace ranges } /// \overload - template(typename Rng, typename O, typename F, typename P = identity)( // - requires input_range AND weakly_incrementable AND // - indirect_unary_predicate, P>> AND // - indirectly_copyable, O>) // + template(typename Rng, typename O, typename F, typename P = identity)( + /// \pre + requires input_range AND weakly_incrementable AND + indirect_unary_predicate, P>> AND + indirectly_copyable, O>) copy_if_result, O> // RANGES_FUNC(copy_if)(Rng && rng, O out, F pred, P proj = P{}) { diff --git a/include/range/v3/algorithm/copy_n.hpp b/include/range/v3/algorithm/copy_n.hpp index 1f7e808e21..8a9d9ce260 100644 --- a/include/range/v3/algorithm/copy_n.hpp +++ b/include/range/v3/algorithm/copy_n.hpp @@ -41,9 +41,10 @@ namespace ranges RANGES_FUNC_BEGIN(copy_n) /// \brief function template \c copy_n - template(typename I, typename O, typename P = identity)( // - requires input_iterator AND weakly_incrementable AND // - indirectly_copyable) // + template(typename I, typename O, typename P = identity)( + /// \pre + requires input_iterator AND weakly_incrementable AND + indirectly_copyable) copy_n_result RANGES_FUNC(copy_n)(I first, iter_difference_t n, O out) { RANGES_EXPECT(0 <= n); diff --git a/include/range/v3/algorithm/count.hpp b/include/range/v3/algorithm/count.hpp index 1c85be2e84..a0993b71cd 100644 --- a/include/range/v3/algorithm/count.hpp +++ b/include/range/v3/algorithm/count.hpp @@ -35,9 +35,10 @@ namespace ranges RANGES_FUNC_BEGIN(count) /// \brief function template \c count - template(typename I, typename S, typename V, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_relation, V const *>) // + template(typename I, typename S, typename V, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_relation, V const *>) iter_difference_t // RANGES_FUNC(count)(I first, S last, V const & val, P proj = P{}) { @@ -49,9 +50,10 @@ namespace ranges } /// \overload - template(typename Rng, typename V, typename P = identity)( // - requires input_range AND // - indirect_relation, P>, V const *>) // + template(typename Rng, typename V, typename P = identity)( + /// \pre + requires input_range AND + indirect_relation, P>, V const *>) iter_difference_t> // RANGES_FUNC(count)(Rng && rng, V const & val, P proj = P{}) { diff --git a/include/range/v3/algorithm/count_if.hpp b/include/range/v3/algorithm/count_if.hpp index 7a14dcdb92..c9003d4ea0 100644 --- a/include/range/v3/algorithm/count_if.hpp +++ b/include/range/v3/algorithm/count_if.hpp @@ -35,9 +35,10 @@ namespace ranges RANGES_FUNC_BEGIN(count_if) /// \brief function template \c count_if - template(typename I, typename S, typename R, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename R, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_unary_predicate>) iter_difference_t RANGES_FUNC(count_if)(I first, S last, R pred, P proj = P{}) { iter_difference_t n = 0; @@ -48,9 +49,10 @@ namespace ranges } /// \overload - template(typename Rng, typename R, typename P = identity)( // - requires input_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename R, typename P = identity)( + /// \pre + requires input_range AND + indirect_unary_predicate, P>>) iter_difference_t> // RANGES_FUNC(count_if)(Rng && rng, R pred, P proj = P{}) { diff --git a/include/range/v3/algorithm/ends_with.hpp b/include/range/v3/algorithm/ends_with.hpp index 1fceaaed6b..6361fbca80 100644 --- a/include/range/v3/algorithm/ends_with.hpp +++ b/include/range/v3/algorithm/ends_with.hpp @@ -41,12 +41,13 @@ namespace ranges typename S1, typename C = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires ((forward_iterator && sentinel_for) || (input_iterator && sized_sentinel_for)) AND ((forward_iterator && sentinel_for) || (input_iterator && sized_sentinel_for)) AND - indirectly_comparable) // + indirectly_comparable) constexpr bool RANGES_FUNC(ends_with)(I0 begin0, S0 end0, I1 begin1, @@ -72,10 +73,11 @@ namespace ranges typename Rng1, typename C = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires (forward_range || (input_range && sized_range)) AND (forward_range || (input_range && sized_range)) AND - indirectly_comparable, iterator_t, C, P0, P1>) // + indirectly_comparable, iterator_t, C, P0, P1>) constexpr bool RANGES_FUNC(ends_with)( Rng0 && rng0, Rng1 && rng1, C pred = C{}, P0 proj0 = P0{}, P1 proj1 = P1{}) // { diff --git a/include/range/v3/algorithm/equal.hpp b/include/range/v3/algorithm/equal.hpp index 0c2bcb4f95..d3a9f0af78 100644 --- a/include/range/v3/algorithm/equal.hpp +++ b/include/range/v3/algorithm/equal.hpp @@ -59,7 +59,8 @@ namespace ranges typename I1, typename C = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND indirectly_comparable) RANGES_DEPRECATED( @@ -85,10 +86,11 @@ namespace ranges typename S1, typename C = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND sentinel_for AND - indirectly_comparable) // + indirectly_comparable) constexpr bool RANGES_FUNC(equal)(I0 begin0, S0 end0, I1 begin1, @@ -115,7 +117,8 @@ namespace ranges typename I1Ref, typename C = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_range AND input_iterator> AND indirectly_comparable, uncvref_t, C, P0, P1>) RANGES_DEPRECATED( @@ -143,9 +146,10 @@ namespace ranges typename Rng1, typename C = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_range AND input_range AND - indirectly_comparable, iterator_t, C, P0, P1>) // + indirectly_comparable, iterator_t, C, P0, P1>) constexpr bool RANGES_FUNC(equal)( Rng0 && rng0, Rng1 && rng1, C pred = C{}, P0 proj0 = P0{}, P1 proj1 = P1{}) // { diff --git a/include/range/v3/algorithm/equal_range.hpp b/include/range/v3/algorithm/equal_range.hpp index f72e6a313f..0a3f3c7fca 100644 --- a/include/range/v3/algorithm/equal_range.hpp +++ b/include/range/v3/algorithm/equal_range.hpp @@ -42,9 +42,10 @@ namespace ranges typename S, typename V, typename C = less, - typename P = identity)( // + typename P = identity)( + /// \pre requires forward_iterator AND sentinel_for AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) subrange RANGES_FUNC(equal_range)( I first, S last, V const & val, C pred = C{}, P proj = P{}) { @@ -100,7 +101,8 @@ namespace ranges } /// \overload - template(typename Rng, typename V, typename C = less, typename P = identity)( // + template(typename Rng, typename V, typename C = less, typename P = identity)( + /// \pre requires forward_range AND indirect_strict_weak_order, P>>) safe_subrange_t // diff --git a/include/range/v3/algorithm/fill.hpp b/include/range/v3/algorithm/fill.hpp index 024b1e5f46..1a6cc47093 100644 --- a/include/range/v3/algorithm/fill.hpp +++ b/include/range/v3/algorithm/fill.hpp @@ -31,8 +31,9 @@ namespace ranges RANGES_FUNC_BEGIN(fill) /// \brief function template \c fill - template(typename O, typename S, typename V)( // - requires output_iterator AND sentinel_for) // + template(typename O, typename S, typename V)( + /// \pre + requires output_iterator AND sentinel_for) O RANGES_FUNC(fill)(O first, S last, V const & val) // { for(; first != last; ++first) @@ -41,8 +42,9 @@ namespace ranges } /// \overload - template(typename Rng, typename V)( // - requires output_range) // + template(typename Rng, typename V)( + /// \pre + requires output_range) borrowed_iterator_t RANGES_FUNC(fill)(Rng && rng, V const & val) { return (*this)(begin(rng), end(rng), val); diff --git a/include/range/v3/algorithm/fill_n.hpp b/include/range/v3/algorithm/fill_n.hpp index 58d595500c..dda3609da2 100644 --- a/include/range/v3/algorithm/fill_n.hpp +++ b/include/range/v3/algorithm/fill_n.hpp @@ -33,8 +33,9 @@ namespace ranges RANGES_FUNC_BEGIN(fill_n) /// \brief function template \c equal - template(typename O, typename V)( // - requires output_iterator) // + template(typename O, typename V)( + /// \pre + requires output_iterator) O RANGES_FUNC(fill_n)(O first, iter_difference_t n, V const & val) { RANGES_EXPECT(n >= 0); diff --git a/include/range/v3/algorithm/find.hpp b/include/range/v3/algorithm/find.hpp index f0f10cc456..2c20b4d3e2 100644 --- a/include/range/v3/algorithm/find.hpp +++ b/include/range/v3/algorithm/find.hpp @@ -43,9 +43,10 @@ namespace ranges /// \pre `S` is a model of the `sentinel_for` concept /// \pre `P` is a model of the `invocable>` concept /// \pre The ResultType of `P` is equality_comparable with V - template(typename I, typename S, typename V, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_relation, V const *>) // + template(typename I, typename S, typename V, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_relation, V const *>) constexpr I RANGES_FUNC(find)(I first, S last, V const & val, P proj = P{}) { for(; first != last; ++first) @@ -55,9 +56,10 @@ namespace ranges } /// \overload - template(typename Rng, typename V, typename P = identity)( // - requires input_range AND // - indirect_relation, P>, V const *>) // + template(typename Rng, typename V, typename P = identity)( + /// \pre + requires input_range AND + indirect_relation, P>, V const *>) constexpr borrowed_iterator_t // RANGES_FUNC(find)(Rng && rng, V const & val, P proj = P{}) { diff --git a/include/range/v3/algorithm/find_end.hpp b/include/range/v3/algorithm/find_end.hpp index fb5f7cb6df..340d92d419 100644 --- a/include/range/v3/algorithm/find_end.hpp +++ b/include/range/v3/algorithm/find_end.hpp @@ -38,22 +38,25 @@ namespace ranges /// \cond namespace detail { - template(typename I, typename S)( // - requires input_iterator AND sentinel_for) // + template(typename I, typename S)( + /// \pre + requires input_iterator AND sentinel_for) I next_to_if(I i, S s, std::true_type) { return ranges::next(i, s); } - template(typename I, typename S)( // - requires input_iterator AND sentinel_for) // + template(typename I, typename S)( + /// \pre + requires input_iterator AND sentinel_for) S next_to_if(I, S s, std::false_type) { return s; } - template(bool B, typename I, typename S)( // - requires input_iterator AND sentinel_for) // + template(bool B, typename I, typename S)( + /// \pre + requires input_iterator AND sentinel_for) meta::if_c next_to_if(I i, S s) { return detail::next_to_if(std::move(i), std::move(s), meta::bool_{}); @@ -186,10 +189,11 @@ namespace ranges typename I2, typename S2, typename R = equal_to, - typename P = identity)( // + typename P = identity)( + /// \pre requires forward_iterator AND sentinel_for AND forward_iterator AND sentinel_for AND - indirect_relation, I2>) // + indirect_relation, I2>) subrange RANGES_FUNC(find_end)( I1 begin1, S1 end1, I2 begin2, S2 end2, R pred = R{}, P proj = P{}) // { @@ -209,9 +213,10 @@ namespace ranges template(typename Rng1, typename Rng2, typename R = equal_to, - typename P = identity)( // + typename P = identity)( + /// \pre requires forward_range AND forward_range AND - indirect_relation, P>, iterator_t>) // + indirect_relation, P>, iterator_t>) safe_subrange_t RANGES_FUNC(find_end)( Rng1 && rng1, Rng2 && rng2, R pred = R{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/find_first_of.hpp b/include/range/v3/algorithm/find_first_of.hpp index 09b2541884..846e302f06 100644 --- a/include/range/v3/algorithm/find_first_of.hpp +++ b/include/range/v3/algorithm/find_first_of.hpp @@ -48,10 +48,11 @@ namespace ranges typename S1, typename R = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_iterator AND sentinel_for AND forward_iterator AND sentinel_for AND - indirect_relation, projected>) // + indirect_relation, projected>) constexpr I0 RANGES_FUNC(find_first_of)(I0 begin0, S0 end0, I1 begin1, @@ -72,11 +73,12 @@ namespace ranges typename Rng1, typename R = equal_to, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_range AND forward_range AND indirect_relation, P0>, - projected, P1>>) // + projected, P1>>) constexpr borrowed_iterator_t RANGES_FUNC(find_first_of)( Rng0 && rng0, Rng1 && rng1, R pred = R{}, P0 proj0 = P0{}, P1 proj1 = P1{}) // { diff --git a/include/range/v3/algorithm/find_if.hpp b/include/range/v3/algorithm/find_if.hpp index 3350988704..05fae71800 100644 --- a/include/range/v3/algorithm/find_if.hpp +++ b/include/range/v3/algorithm/find_if.hpp @@ -45,9 +45,10 @@ namespace ranges /// value type of I. /// \pre `F` models `predicate`, where `X` is the result type /// of `invocable` - template(typename I, typename S, typename F, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename F, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_unary_predicate>) I RANGES_FUNC(find_if)(I first, S last, F pred, P proj = P{}) { for(; first != last; ++first) @@ -57,9 +58,10 @@ namespace ranges } /// \overload - template(typename Rng, typename F, typename P = identity)( // - requires input_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename F, typename P = identity)( + /// \pre + requires input_range AND + indirect_unary_predicate, P>>) borrowed_iterator_t RANGES_FUNC(find_if)(Rng && rng, F pred, P proj = P{}) { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); diff --git a/include/range/v3/algorithm/find_if_not.hpp b/include/range/v3/algorithm/find_if_not.hpp index 1e169c9617..3900823786 100644 --- a/include/range/v3/algorithm/find_if_not.hpp +++ b/include/range/v3/algorithm/find_if_not.hpp @@ -45,9 +45,10 @@ namespace ranges /// value type of I. /// \pre `F` models `predicate`, where `X` is the result type /// of `invocable` - template(typename I, typename S, typename F, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename F, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_unary_predicate>) I RANGES_FUNC(find_if_not)(I first, S last, F pred, P proj = P{}) { for(; first != last; ++first) @@ -57,9 +58,10 @@ namespace ranges } /// \overload - template(typename Rng, typename F, typename P = identity)( // - requires input_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename F, typename P = identity)( + /// \pre + requires input_range AND + indirect_unary_predicate, P>>) borrowed_iterator_t // RANGES_FUNC(find_if_not)(Rng && rng, F pred, P proj = P{}) { diff --git a/include/range/v3/algorithm/for_each.hpp b/include/range/v3/algorithm/for_each.hpp index 6b86346893..64cbbf8fbc 100644 --- a/include/range/v3/algorithm/for_each.hpp +++ b/include/range/v3/algorithm/for_each.hpp @@ -40,9 +40,10 @@ namespace ranges RANGES_FUNC_BEGIN(for_each) /// \brief function template \c for_each - template(typename I, typename S, typename F, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirectly_unary_invocable>) // + template(typename I, typename S, typename F, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirectly_unary_invocable>) for_each_result RANGES_FUNC(for_each)(I first, S last, F fun, P proj = P{}) { for(; first != last; ++first) @@ -53,9 +54,10 @@ namespace ranges } /// \overload - template(typename Rng, typename F, typename P = identity)( // - requires input_range AND // - indirectly_unary_invocable, P>>) // + template(typename Rng, typename F, typename P = identity)( + /// \pre + requires input_range AND + indirectly_unary_invocable, P>>) for_each_result, F> // RANGES_FUNC(for_each)(Rng && rng, F fun, P proj = P{}) { diff --git a/include/range/v3/algorithm/for_each_n.hpp b/include/range/v3/algorithm/for_each_n.hpp index b3e9cc7c36..9f9cb8987c 100644 --- a/include/range/v3/algorithm/for_each_n.hpp +++ b/include/range/v3/algorithm/for_each_n.hpp @@ -37,9 +37,10 @@ namespace ranges RANGES_FUNC_BEGIN(for_each_n) /// \brief function template \c for_each_n - template(typename I, typename F, typename P = identity)( // + template(typename I, typename F, typename P = identity)( + /// \pre requires input_iterator AND - indirectly_unary_invocable>) // + indirectly_unary_invocable>) I RANGES_FUNC(for_each_n)(I first, iter_difference_t n, F fun, P proj = P{}) { RANGES_EXPECT(0 <= n); @@ -51,9 +52,10 @@ namespace ranges } /// \overload - template(typename Rng, typename F, typename P = identity)( // + template(typename Rng, typename F, typename P = identity)( + /// \pre requires input_range AND - indirectly_unary_invocable, P>>) // + indirectly_unary_invocable, P>>) borrowed_iterator_t RANGES_FUNC(for_each_n)( Rng && rng, range_difference_t n, F fun, P proj = P{}) { diff --git a/include/range/v3/algorithm/generate.hpp b/include/range/v3/algorithm/generate.hpp index 3c99b03229..b160782385 100644 --- a/include/range/v3/algorithm/generate.hpp +++ b/include/range/v3/algorithm/generate.hpp @@ -39,9 +39,10 @@ namespace ranges RANGES_FUNC_BEGIN(generate) /// \brief function template \c generate_n - template(typename O, typename S, typename F)( // - requires invocable AND output_iterator> AND // - sentinel_for) // + template(typename O, typename S, typename F)( + /// \pre + requires invocable AND output_iterator> AND + sentinel_for) generate_result RANGES_FUNC(generate)(O first, S last, F fun) // { for(; first != last; ++first) @@ -50,8 +51,9 @@ namespace ranges } /// \overload - template(typename Rng, typename F)( // - requires invocable AND output_range>) // + template(typename Rng, typename F)( + /// \pre + requires invocable AND output_range>) generate_result, F> // RANGES_FUNC(generate)(Rng && rng, F fun) { diff --git a/include/range/v3/algorithm/generate_n.hpp b/include/range/v3/algorithm/generate_n.hpp index 90c989e90d..ef94bade37 100644 --- a/include/range/v3/algorithm/generate_n.hpp +++ b/include/range/v3/algorithm/generate_n.hpp @@ -39,8 +39,9 @@ namespace ranges RANGES_FUNC_BEGIN(generate_n) /// \brief function template \c generate_n - template(typename O, typename F)( // - requires invocable AND output_iterator>) // + template(typename O, typename F)( + /// \pre + requires invocable AND output_iterator>) generate_n_result // RANGES_FUNC(generate_n)(O first, iter_difference_t n, F fun) { diff --git a/include/range/v3/algorithm/heap_algorithm.hpp b/include/range/v3/algorithm/heap_algorithm.hpp index d0b7b69629..7030ba410e 100644 --- a/include/range/v3/algorithm/heap_algorithm.hpp +++ b/include/range/v3/algorithm/heap_algorithm.hpp @@ -48,9 +48,10 @@ namespace ranges { struct is_heap_until_n_fn { - template(typename I, typename C = less, typename P = identity)( // + template(typename I, typename C = less, typename P = identity)( + /// \pre requires random_access_iterator AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) I operator()(I const begin_, iter_difference_t const n_, C pred = C{}, P proj = P{}) const { @@ -78,9 +79,10 @@ namespace ranges struct is_heap_n_fn { - template(typename I, typename C = less, typename P = identity)( // + template(typename I, typename C = less, typename P = identity)( + /// \pre requires random_access_iterator AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) bool operator()(I first, iter_difference_t n, C pred = C{}, P proj = P{}) const { @@ -98,9 +100,10 @@ namespace ranges RANGES_FUNC_BEGIN(is_heap_until) /// \brief function template \c is_heap_until - template(typename I, typename S, typename C = less, typename P = identity)( // - requires random_access_iterator AND sentinel_for AND // - indirect_strict_weak_order>) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sentinel_for AND + indirect_strict_weak_order>) I RANGES_FUNC(is_heap_until)(I first, S last, C pred = C{}, P proj = P{}) { return detail::is_heap_until_n(std::move(first), @@ -110,9 +113,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires random_access_range AND // - indirect_strict_weak_order, P>>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires random_access_range AND + indirect_strict_weak_order, P>>) borrowed_iterator_t // RANGES_FUNC(is_heap_until)(Rng && rng, C pred = C{}, P proj = P{}) { @@ -130,9 +134,10 @@ namespace ranges RANGES_FUNC_BEGIN(is_heap) /// \brief function template \c is_heap - template(typename I, typename S, typename C = less, typename P = identity)( // - requires random_access_iterator AND sentinel_for AND // - indirect_strict_weak_order>) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sentinel_for AND + indirect_strict_weak_order>) bool RANGES_FUNC(is_heap)(I first, S last, C pred = C{}, P proj = P{}) // { return detail::is_heap_n(std::move(first), @@ -142,9 +147,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires random_access_range AND // - indirect_strict_weak_order, P>>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires random_access_range AND + indirect_strict_weak_order, P>>) bool RANGES_FUNC(is_heap)(Rng && rng, C pred = C{}, P proj = P{}) // { return detail::is_heap_n( @@ -259,9 +265,10 @@ namespace ranges RANGES_FUNC_BEGIN(push_heap) /// \brief function template \c push_heap - template(typename I, typename S, typename C = less, typename P = identity)( // - requires random_access_iterator AND sentinel_for AND // - sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sentinel_for AND + sortable) I RANGES_FUNC(push_heap)(I first, S last, C pred = C{}, P proj = P{}) { auto n = distance(first, last); @@ -270,8 +277,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires random_access_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires random_access_range AND sortable, C, P>) borrowed_iterator_t // RANGES_FUNC(push_heap)(Rng && rng, C pred = C{}, P proj = P{}) // { @@ -294,8 +302,9 @@ namespace ranges { struct pop_heap_n_fn { - template(typename I, typename C = less, typename P = identity)( // - requires random_access_iterator AND sortable) // + template(typename I, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sortable) void operator()(I first, iter_difference_t len, C pred = C{}, P proj = P{}) const { @@ -317,9 +326,10 @@ namespace ranges RANGES_FUNC_BEGIN(pop_heap) /// \brief function template \c pop_heap - template(typename I, typename S, typename C = less, typename P = identity)( // - requires random_access_iterator AND sentinel_for AND // - sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sentinel_for AND + sortable) I RANGES_FUNC(pop_heap)(I first, S last, C pred = C{}, P proj = P{}) { auto n = distance(first, last); @@ -328,8 +338,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires random_access_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires random_access_range AND sortable, C, P>) borrowed_iterator_t // RANGES_FUNC(pop_heap)(Rng && rng, C pred = C{}, P proj = P{}) { @@ -349,9 +360,10 @@ namespace ranges RANGES_FUNC_BEGIN(make_heap) /// \brief function template \c make_heap - template(typename I, typename S, typename C = less, typename P = identity)( // - requires random_access_iterator AND sentinel_for AND // - sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sentinel_for AND + sortable) I RANGES_FUNC(make_heap)(I first, S last, C pred = C{}, P proj = P{}) { iter_difference_t const n = distance(first, last); @@ -364,8 +376,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires random_access_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires random_access_range AND sortable, C, P>) borrowed_iterator_t // RANGES_FUNC(make_heap)(Rng && rng, C pred = C{}, P proj = P{}) { @@ -388,9 +401,10 @@ namespace ranges RANGES_FUNC_BEGIN(sort_heap) - template(typename I, typename S, typename C = less, typename P = identity)( // - requires random_access_iterator AND sentinel_for AND // - sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sentinel_for AND + sortable) I RANGES_FUNC(sort_heap)(I first, S last, C pred = C{}, P proj = P{}) { iter_difference_t const n = distance(first, last); @@ -399,8 +413,9 @@ namespace ranges return first + n; } - template(typename Rng, typename C = less, typename P = identity)( // - requires random_access_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires random_access_range AND sortable, C, P>) borrowed_iterator_t // RANGES_FUNC(sort_heap)(Rng && rng, C pred = C{}, P proj = P{}) { diff --git a/include/range/v3/algorithm/inplace_merge.hpp b/include/range/v3/algorithm/inplace_merge.hpp index 1d34c09cf9..336a868c11 100644 --- a/include/range/v3/algorithm/inplace_merge.hpp +++ b/include/range/v3/algorithm/inplace_merge.hpp @@ -96,8 +96,9 @@ namespace ranges } public: - template(typename I, typename C = less, typename P = identity)( // - requires bidirectional_iterator AND sortable) // + template(typename I, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_iterator AND sortable) void operator()(I first, I middle, I last, iter_difference_t len1, iter_difference_t len2, iter_value_t * buf, std::ptrdiff_t buf_size, C pred = C{}, P proj = P{}) const @@ -220,8 +221,9 @@ namespace ranges struct inplace_merge_no_buffer_fn { - template(typename I, typename C = less, typename P = identity)( // - requires bidirectional_iterator AND sortable) // + template(typename I, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_iterator AND sortable) void operator()(I first, I middle, I last, iter_difference_t len1, iter_difference_t len2, C pred = C{}, P proj = P{}) const { @@ -248,8 +250,9 @@ namespace ranges // TODO reimplement to only need forward iterators /// \brief function template \c inplace_merge - template(typename I, typename S, typename C = less, typename P = identity)( // - requires bidirectional_iterator AND sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_iterator AND sortable) I RANGES_FUNC(inplace_merge)( I first, I middle, S last, C pred = C{}, P proj = P{}) { @@ -277,8 +280,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires bidirectional_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_range AND sortable, C, P>) borrowed_iterator_t RANGES_FUNC(inplace_merge)( Rng && rng, iterator_t middle, C pred = C{}, P proj = P{}) { diff --git a/include/range/v3/algorithm/is_partitioned.hpp b/include/range/v3/algorithm/is_partitioned.hpp index bf1bc627a0..1c1a34d177 100644 --- a/include/range/v3/algorithm/is_partitioned.hpp +++ b/include/range/v3/algorithm/is_partitioned.hpp @@ -43,9 +43,10 @@ namespace ranges RANGES_FUNC_BEGIN(is_partitioned) /// \brief function template \c is_partitioned - template(typename I, typename S, typename C, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename C, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_unary_predicate>) bool RANGES_FUNC(is_partitioned)(I first, S last, C pred, P proj = P{}) // { for(; first != last; ++first) @@ -58,9 +59,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C, typename P = identity)( // - requires input_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename C, typename P = identity)( + /// \pre + requires input_range AND + indirect_unary_predicate, P>>) bool RANGES_FUNC(is_partitioned)(Rng && rng, C pred, P proj = P{}) // { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); diff --git a/include/range/v3/algorithm/is_sorted.hpp b/include/range/v3/algorithm/is_sorted.hpp index c16414605a..c3e01555db 100644 --- a/include/range/v3/algorithm/is_sorted.hpp +++ b/include/range/v3/algorithm/is_sorted.hpp @@ -45,9 +45,10 @@ namespace ranges /// \pre `R` and `projected` model the `indirect_strict_weak_order>` concept /// - template(typename I, typename S, typename R = less, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - indirect_strict_weak_order>) // + template(typename I, typename S, typename R = less, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + indirect_strict_weak_order>) bool RANGES_FUNC(is_sorted)(I first, S last, R rel = R{}, P proj = P{}) { return is_sorted_until( @@ -55,9 +56,10 @@ namespace ranges } /// \overload - template(typename Rng, typename R = less, typename P = identity)( // - requires forward_range AND // - indirect_strict_weak_order, P>>) // + template(typename Rng, typename R = less, typename P = identity)( + /// \pre + requires forward_range AND + indirect_strict_weak_order, P>>) bool RANGES_FUNC(is_sorted)(Rng && rng, R rel = R{}, P proj = P{}) // { return (*this)(begin(rng), end(rng), std::move(rel), std::move(proj)); diff --git a/include/range/v3/algorithm/is_sorted_until.hpp b/include/range/v3/algorithm/is_sorted_until.hpp index cb516d774d..590cae0d94 100644 --- a/include/range/v3/algorithm/is_sorted_until.hpp +++ b/include/range/v3/algorithm/is_sorted_until.hpp @@ -47,9 +47,10 @@ namespace ranges /// \pre `R` and `projected` model the `indirect_strict_weak_order>` concept /// - template(typename I, typename S, typename R = less, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - indirect_strict_weak_order>) // + template(typename I, typename S, typename R = less, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + indirect_strict_weak_order>) I RANGES_FUNC(is_sorted_until)(I first, S last, R pred = R{}, P proj = P{}) { auto i = first; @@ -66,9 +67,10 @@ namespace ranges } /// \overload - template(typename Rng, typename R = less, typename P = identity)( // - requires forward_range AND // - indirect_strict_weak_order, P>>) // + template(typename Rng, typename R = less, typename P = identity)( + /// \pre + requires forward_range AND + indirect_strict_weak_order, P>>) borrowed_iterator_t // RANGES_FUNC(is_sorted_until)(Rng && rng, R pred = R{}, P proj = P{}) { diff --git a/include/range/v3/algorithm/lexicographical_compare.hpp b/include/range/v3/algorithm/lexicographical_compare.hpp index 71a1806b11..c0432f9390 100644 --- a/include/range/v3/algorithm/lexicographical_compare.hpp +++ b/include/range/v3/algorithm/lexicographical_compare.hpp @@ -40,10 +40,11 @@ namespace ranges typename S1, typename C = less, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND sentinel_for AND - indirect_strict_weak_order, projected>) // + indirect_strict_weak_order, projected>) bool RANGES_FUNC(lexicographical_compare)(I0 begin0, S0 end0, I1 begin1, @@ -68,11 +69,12 @@ namespace ranges typename Rng1, typename C = less, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_range AND input_range AND indirect_strict_weak_order, P0>, - projected, P1>>) // + projected, P1>>) bool RANGES_FUNC(lexicographical_compare)( Rng0 && rng0, Rng1 && rng1, C pred = C{}, P0 proj0 = P0{}, P1 proj1 = P1{}) // { diff --git a/include/range/v3/algorithm/lower_bound.hpp b/include/range/v3/algorithm/lower_bound.hpp index aace4fa5d8..f740908a7f 100644 --- a/include/range/v3/algorithm/lower_bound.hpp +++ b/include/range/v3/algorithm/lower_bound.hpp @@ -41,9 +41,10 @@ namespace ranges typename S, typename V, typename C = less, - typename P = identity)( // + typename P = identity)( + /// \pre requires forward_iterator AND sentinel_for AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) I RANGES_FUNC(lower_bound)( I first, S last, V const & val, C pred = C{}, P proj = P{}) { @@ -54,7 +55,8 @@ namespace ranges } /// \overload - template(typename Rng, typename V, typename C = less, typename P = identity)( // + template(typename Rng, typename V, typename C = less, typename P = identity)( + /// \pre requires forward_range AND indirect_strict_weak_order, P>>) borrowed_iterator_t // diff --git a/include/range/v3/algorithm/max.hpp b/include/range/v3/algorithm/max.hpp index de4d8e0cf6..da642788ec 100644 --- a/include/range/v3/algorithm/max.hpp +++ b/include/range/v3/algorithm/max.hpp @@ -37,8 +37,9 @@ namespace ranges RANGES_FUNC_BEGIN(max) /// \brief function template \c max - template(typename T, typename C = less, typename P = identity)( // - requires indirect_strict_weak_order>) // + template(typename T, typename C = less, typename P = identity)( + /// \pre + requires indirect_strict_weak_order>) constexpr T const & RANGES_FUNC(max)( T const & a, T const & b, C pred = C{}, P proj = P{}) // { @@ -46,10 +47,11 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires input_range AND // - indirect_strict_weak_order, P>> AND // - indirectly_copyable_storable, range_value_t *>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires input_range AND + indirect_strict_weak_order, P>> AND + indirectly_copyable_storable, range_value_t *>) constexpr range_value_t // RANGES_FUNC(max)(Rng && rng, C pred = C{}, P proj = P{}) // { @@ -67,9 +69,10 @@ namespace ranges } /// \overload - template(typename T, typename C = less, typename P = identity)( // + template(typename T, typename C = less, typename P = identity)( + /// \pre requires copyable AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) constexpr T RANGES_FUNC(max)( std::initializer_list const && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/max_element.hpp b/include/range/v3/algorithm/max_element.hpp index 58c1168a49..3b4f755716 100644 --- a/include/range/v3/algorithm/max_element.hpp +++ b/include/range/v3/algorithm/max_element.hpp @@ -36,9 +36,10 @@ namespace ranges RANGES_FUNC_BEGIN(max_element) /// \brief function template \c max_element - template(typename I, typename S, typename C = less, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - indirect_strict_weak_order>) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + indirect_strict_weak_order>) I RANGES_FUNC(max_element)(I first, S last, C pred = C{}, P proj = P{}) { if(first != last) @@ -49,9 +50,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires forward_range AND // - indirect_strict_weak_order, P>>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires forward_range AND + indirect_strict_weak_order, P>>) borrowed_iterator_t // RANGES_FUNC(max_element)(Rng && rng, C pred = C{}, P proj = P{}) { diff --git a/include/range/v3/algorithm/merge.hpp b/include/range/v3/algorithm/merge.hpp index cf1121a12d..da5ee243b3 100644 --- a/include/range/v3/algorithm/merge.hpp +++ b/include/range/v3/algorithm/merge.hpp @@ -64,9 +64,10 @@ namespace ranges typename O, typename C = less, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - mergeable) // + mergeable) merge_result RANGES_FUNC(merge)(I0 begin0, S0 end0, I1 begin1, @@ -100,9 +101,10 @@ namespace ranges typename O, typename C = less, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires range AND range AND - mergeable, iterator_t, O, C, P0, P1>) // + mergeable, iterator_t, O, C, P0, P1>) merge_result, borrowed_iterator_t, O> RANGES_FUNC(merge)(Rng0 && rng0, Rng1 && rng1, diff --git a/include/range/v3/algorithm/min.hpp b/include/range/v3/algorithm/min.hpp index 867d8344ce..2fba9f0267 100644 --- a/include/range/v3/algorithm/min.hpp +++ b/include/range/v3/algorithm/min.hpp @@ -37,8 +37,9 @@ namespace ranges RANGES_FUNC_BEGIN(min) /// \brief function template \c min - template(typename T, typename C = less, typename P = identity)( // - requires indirect_strict_weak_order>) // + template(typename T, typename C = less, typename P = identity)( + /// \pre + requires indirect_strict_weak_order>) constexpr T const & RANGES_FUNC(min)( T const & a, T const & b, C pred = C{}, P proj = P{}) // { @@ -46,10 +47,11 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires input_range AND // - indirect_strict_weak_order, P>> AND // - indirectly_copyable_storable, range_value_t *>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires input_range AND + indirect_strict_weak_order, P>> AND + indirectly_copyable_storable, range_value_t *>) constexpr range_value_t // RANGES_FUNC(min)(Rng && rng, C pred = C{}, P proj = P{}) // { @@ -67,9 +69,10 @@ namespace ranges } /// \overload - template(typename T, typename C = less, typename P = identity)( // + template(typename T, typename C = less, typename P = identity)( + /// \pre requires copyable AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) constexpr T RANGES_FUNC(min)( std::initializer_list const && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/min_element.hpp b/include/range/v3/algorithm/min_element.hpp index 1dcfa532b8..ad0d5fa976 100644 --- a/include/range/v3/algorithm/min_element.hpp +++ b/include/range/v3/algorithm/min_element.hpp @@ -36,9 +36,10 @@ namespace ranges RANGES_FUNC_BEGIN(min_element) /// \brief function template \c min_element - template(typename I, typename S, typename C = less, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - indirect_strict_weak_order>) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + indirect_strict_weak_order>) I RANGES_FUNC(min_element)(I first, S last, C pred = C{}, P proj = P{}) { if(first != last) @@ -49,9 +50,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires forward_range AND // - indirect_strict_weak_order, P>>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires forward_range AND + indirect_strict_weak_order, P>>) borrowed_iterator_t // RANGES_FUNC(min_element)(Rng && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/minmax.hpp b/include/range/v3/algorithm/minmax.hpp index e87ed41d4c..05306e4ea6 100644 --- a/include/range/v3/algorithm/minmax.hpp +++ b/include/range/v3/algorithm/minmax.hpp @@ -41,8 +41,9 @@ namespace ranges RANGES_FUNC_BEGIN(minmax) /// \brief function template \c minmax - template(typename T, typename C = less, typename P = identity)( // - requires indirect_strict_weak_order>) // + template(typename T, typename C = less, typename P = identity)( + /// \pre + requires indirect_strict_weak_order>) constexpr minmax_result RANGES_FUNC(minmax)( T const & a, T const & b, C pred = C{}, P proj = P{}) // { @@ -51,10 +52,11 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires input_range AND // - indirect_strict_weak_order, P>> AND // - indirectly_copyable_storable, range_value_t *>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires input_range AND + indirect_strict_weak_order, P>> AND + indirectly_copyable_storable, range_value_t *>) constexpr minmax_result> // RANGES_FUNC(minmax)(Rng && rng, C pred = C{}, P proj = P{}) // { @@ -106,9 +108,10 @@ namespace ranges } /// \overload - template(typename T, typename C = less, typename P = identity)( // + template(typename T, typename C = less, typename P = identity)( + /// \pre requires copyable AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) constexpr minmax_result RANGES_FUNC(minmax)( std::initializer_list const && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/minmax_element.hpp b/include/range/v3/algorithm/minmax_element.hpp index 7d227b1e24..58f955e96c 100644 --- a/include/range/v3/algorithm/minmax_element.hpp +++ b/include/range/v3/algorithm/minmax_element.hpp @@ -42,9 +42,10 @@ namespace ranges RANGES_FUNC_BEGIN(minmax_element) /// \brief function template \c minmax_element - template(typename I, typename S, typename C = less, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - indirect_strict_weak_order>) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + indirect_strict_weak_order>) minmax_element_result // RANGES_FUNC(minmax_element)(I first, S last, C pred = C{}, P proj = P{}) // { @@ -88,9 +89,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires forward_range AND // - indirect_strict_weak_order, P>>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires forward_range AND + indirect_strict_weak_order, P>>) minmax_element_result> // RANGES_FUNC(minmax_element)(Rng && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/mismatch.hpp b/include/range/v3/algorithm/mismatch.hpp index 0447e7a729..4d6785c955 100644 --- a/include/range/v3/algorithm/mismatch.hpp +++ b/include/range/v3/algorithm/mismatch.hpp @@ -48,9 +48,10 @@ namespace ranges typename I2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // - requires input_iterator AND sentinel_for AND // - input_iterator AND // + typename P2 = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + input_iterator AND indirect_relation, projected>) RANGES_DEPRECATED( "Use the variant of ranges::mismatch that takes an upper bound for " @@ -75,10 +76,11 @@ namespace ranges typename S2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND sentinel_for AND - indirect_relation, projected>) // + indirect_relation, projected>) mismatch_result RANGES_FUNC(mismatch)(I1 begin1, S1 end1, I2 begin2, @@ -129,11 +131,12 @@ namespace ranges typename Rng2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires input_range AND input_range AND indirect_relation, P1>, - projected, P2>>) // + projected, P2>>) mismatch_result, borrowed_iterator_t> // RANGES_FUNC(mismatch)(Rng1 && rng1, Rng2 && rng2, diff --git a/include/range/v3/algorithm/move.hpp b/include/range/v3/algorithm/move.hpp index eebe0d86a5..97e06f9ef3 100644 --- a/include/range/v3/algorithm/move.hpp +++ b/include/range/v3/algorithm/move.hpp @@ -40,9 +40,10 @@ namespace ranges RANGES_FUNC_BEGIN(move) /// \brief function template \c move - template(typename I, typename S, typename O)( // - requires input_iterator AND sentinel_for AND // - weakly_incrementable AND indirectly_movable) // + template(typename I, typename S, typename O)( + /// \pre + requires input_iterator AND sentinel_for AND + weakly_incrementable AND indirectly_movable) move_result RANGES_FUNC(move)(I first, S last, O out) // { for(; first != last; ++first, ++out) @@ -51,9 +52,10 @@ namespace ranges } /// \overload - template(typename Rng, typename O)( // - requires input_range AND weakly_incrementable AND // - indirectly_movable, O>) // + template(typename Rng, typename O)( + /// \pre + requires input_range AND weakly_incrementable AND + indirectly_movable, O>) move_result, O> // RANGES_FUNC(move)(Rng && rng, O out) // { diff --git a/include/range/v3/algorithm/move_backward.hpp b/include/range/v3/algorithm/move_backward.hpp index 93b49daeba..04c610bdef 100644 --- a/include/range/v3/algorithm/move_backward.hpp +++ b/include/range/v3/algorithm/move_backward.hpp @@ -39,9 +39,10 @@ namespace ranges RANGES_FUNC_BEGIN(move_backward) /// \brief function template \c move_backward - template(typename I, typename S, typename O)( // - requires bidirectional_iterator AND sentinel_for AND // - bidirectional_iterator AND indirectly_movable) // + template(typename I, typename S, typename O)( + /// \pre + requires bidirectional_iterator AND sentinel_for AND + bidirectional_iterator AND indirectly_movable) move_backward_result RANGES_FUNC(move_backward)(I first, S end_, O out) // { I i = ranges::next(first, end_), last = i; @@ -51,9 +52,10 @@ namespace ranges } /// \overload - template(typename Rng, typename O)( // - requires bidirectional_range AND bidirectional_iterator AND // - indirectly_movable, O>) // + template(typename Rng, typename O)( + /// \pre + requires bidirectional_range AND bidirectional_iterator AND + indirectly_movable, O>) move_backward_result, O> // RANGES_FUNC(move_backward)(Rng && rng, O out) // { diff --git a/include/range/v3/algorithm/none_of.hpp b/include/range/v3/algorithm/none_of.hpp index a860005b19..ff433c638d 100644 --- a/include/range/v3/algorithm/none_of.hpp +++ b/include/range/v3/algorithm/none_of.hpp @@ -36,9 +36,10 @@ namespace ranges RANGES_FUNC_BEGIN(none_of) /// \brief function template \c none_of - template(typename I, typename S, typename F, typename P = identity)( // - requires input_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename F, typename P = identity)( + /// \pre + requires input_iterator AND sentinel_for AND + indirect_unary_predicate>) bool RANGES_FUNC(none_of)(I first, S last, F pred, P proj = P{}) // { for(; first != last; ++first) @@ -48,9 +49,10 @@ namespace ranges } /// \overload - template(typename Rng, typename F, typename P = identity)( // - requires input_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename F, typename P = identity)( + /// \pre + requires input_range AND + indirect_unary_predicate, P>>) bool RANGES_FUNC(none_of)(Rng && rng, F pred, P proj = P{}) // { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); diff --git a/include/range/v3/algorithm/nth_element.hpp b/include/range/v3/algorithm/nth_element.hpp index 5c8d530185..f70f8f3051 100644 --- a/include/range/v3/algorithm/nth_element.hpp +++ b/include/range/v3/algorithm/nth_element.hpp @@ -50,8 +50,9 @@ namespace ranges { // stable, 2-3 compares, 0-2 swaps - template(typename I, typename C, typename P)( // - requires forward_iterator AND indirect_relation>) // + template(typename I, typename C, typename P)( + /// \pre + requires forward_iterator AND indirect_relation>) unsigned sort3(I x, I y, I z, C & pred, P & proj) { unsigned r = 0; @@ -85,7 +86,8 @@ namespace ranges return r; } // x <= y && y <= z - template(typename I, typename C, typename P)( // + template(typename I, typename C, typename P)( + /// \pre requires bidirectional_iterator AND indirect_relation>) void selection_sort(I first, I last, C & pred, P & proj) { @@ -105,8 +107,9 @@ namespace ranges RANGES_FUNC_BEGIN(nth_element) /// \brief function template \c nth_element - template(typename I, typename S, typename C = less, typename P = identity)( // - requires random_access_iterator AND sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires random_access_iterator AND sortable) I RANGES_FUNC(nth_element)( I first, I nth, S end_, C pred = C{}, P proj = P{}) // { @@ -308,8 +311,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires random_access_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires random_access_range AND sortable, C, P>) borrowed_iterator_t RANGES_FUNC(nth_element)( Rng && rng, iterator_t nth, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/partial_sort.hpp b/include/range/v3/algorithm/partial_sort.hpp index 887ab44216..c5a829cab4 100644 --- a/include/range/v3/algorithm/partial_sort.hpp +++ b/include/range/v3/algorithm/partial_sort.hpp @@ -38,9 +38,10 @@ namespace ranges RANGES_FUNC_BEGIN(partial_sort) /// \brief function template \c partial_sort - template(typename I, typename S, typename C = less, typename P = identity)( // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre requires sortable AND random_access_iterator AND - sentinel_for) // + sentinel_for) I RANGES_FUNC(partial_sort)( I first, I middle, S last, C pred = C{}, P proj = P{}) // { @@ -61,8 +62,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires sortable, C, P> AND random_access_range) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires sortable, C, P> AND random_access_range) borrowed_iterator_t RANGES_FUNC(partial_sort)( Rng && rng, iterator_t middle, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/partial_sort_copy.hpp b/include/range/v3/algorithm/partial_sort_copy.hpp index b679d7e431..db96ad31c8 100644 --- a/include/range/v3/algorithm/partial_sort_copy.hpp +++ b/include/range/v3/algorithm/partial_sort_copy.hpp @@ -44,11 +44,12 @@ namespace ranges typename SO, typename C = less, typename PI = identity, - typename PO = identity)( // + typename PO = identity)( + /// \pre requires input_iterator AND sentinel_for AND random_access_iterator AND sentinel_for AND indirectly_copyable AND sortable AND - indirect_strict_weak_order, projected>) // + indirect_strict_weak_order, projected>) O RANGES_FUNC(partial_sort_copy)(I first, SI last, O out_begin, @@ -87,13 +88,14 @@ namespace ranges typename OutRng, typename C = less, typename PI = identity, - typename PO = identity)( // + typename PO = identity)( + /// \pre requires input_range AND random_access_range AND indirectly_copyable, iterator_t> AND sortable, C, PO> AND indirect_strict_weak_order, PI>, - projected, PO>>) // + projected, PO>>) borrowed_iterator_t RANGES_FUNC(partial_sort_copy)(InRng && in_rng, OutRng && out_rng, C pred = C{}, diff --git a/include/range/v3/algorithm/partition.hpp b/include/range/v3/algorithm/partition.hpp index aa6e34769f..61fc9f87b6 100644 --- a/include/range/v3/algorithm/partition.hpp +++ b/include/range/v3/algorithm/partition.hpp @@ -98,9 +98,10 @@ namespace ranges RANGES_FUNC_BEGIN(partition) /// \brief function template \c partition - template(typename I, typename S, typename C, typename P = identity)( // - requires permutable AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename C, typename P = identity)( + /// \pre + requires permutable AND sentinel_for AND + indirect_unary_predicate>) I RANGES_FUNC(partition)(I first, S last, C pred, P proj = P{}) { return detail::partition_impl(std::move(first), @@ -111,9 +112,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C, typename P = identity)( // - requires forward_range AND permutable> AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename C, typename P = identity)( + /// \pre + requires forward_range AND permutable> AND + indirect_unary_predicate, P>>) borrowed_iterator_t RANGES_FUNC(partition)(Rng && rng, C pred, P proj = P{}) { return detail::partition_impl(begin(rng), diff --git a/include/range/v3/algorithm/partition_copy.hpp b/include/range/v3/algorithm/partition_copy.hpp index 497069618c..00f3306ccb 100644 --- a/include/range/v3/algorithm/partition_copy.hpp +++ b/include/range/v3/algorithm/partition_copy.hpp @@ -48,11 +48,12 @@ namespace ranges typename O0, typename O1, typename C, - typename P = identity)( // + typename P = identity)( + /// \pre requires input_iterator AND sentinel_for AND weakly_incrementable AND weakly_incrementable AND indirectly_copyable AND indirectly_copyable AND - indirect_unary_predicate>) // + indirect_unary_predicate>) partition_copy_result RANGES_FUNC(partition_copy)( I first, S last, O0 o0, O1 o1, C pred, P proj = P{}) { @@ -78,11 +79,12 @@ namespace ranges typename O0, typename O1, typename C, - typename P = identity)( // + typename P = identity)( + /// \pre requires input_range AND weakly_incrementable AND weakly_incrementable AND indirectly_copyable, O0> AND indirectly_copyable, O1> AND - indirect_unary_predicate, P>>) // + indirect_unary_predicate, P>>) partition_copy_result, O0, O1> // RANGES_FUNC(partition_copy)(Rng && rng, O0 o0, O1 o1, C pred, P proj = P{}) { diff --git a/include/range/v3/algorithm/partition_point.hpp b/include/range/v3/algorithm/partition_point.hpp index 7e77287728..b987fa9cf8 100644 --- a/include/range/v3/algorithm/partition_point.hpp +++ b/include/range/v3/algorithm/partition_point.hpp @@ -48,9 +48,10 @@ namespace ranges RANGES_FUNC_BEGIN(partition_point) /// \brief function template \c partition_point - template(typename I, typename S, typename C, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename C, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + indirect_unary_predicate>) I RANGES_FUNC(partition_point)(I first, S last, C pred, P proj = P{}) { if(RANGES_CONSTEXPR_IF(sized_sentinel_for)) @@ -79,9 +80,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C, typename P = identity)( // - requires forward_range AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename C, typename P = identity)( + /// \pre + requires forward_range AND + indirect_unary_predicate, P>>) borrowed_iterator_t // RANGES_FUNC(partition_point)(Rng && rng, C pred, P proj = P{}) // { diff --git a/include/range/v3/algorithm/permutation.hpp b/include/range/v3/algorithm/permutation.hpp index 7a234b0768..88e0c1eb56 100644 --- a/include/range/v3/algorithm/permutation.hpp +++ b/include/range/v3/algorithm/permutation.hpp @@ -104,7 +104,8 @@ namespace ranges typename I2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires forward_iterator AND sentinel_for AND forward_iterator AND indirectly_comparable) RANGES_DEPRECATED( @@ -164,10 +165,11 @@ namespace ranges typename S2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires forward_iterator AND sentinel_for AND forward_iterator AND sentinel_for AND - indirectly_comparable) // + indirectly_comparable) bool RANGES_FUNC(is_permutation)(I1 begin1, S1 end1, I2 begin2, @@ -204,7 +206,8 @@ namespace ranges typename I2Ref, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires forward_range AND forward_iterator> AND indirectly_comparable, uncvref_t, C, P1, P2>) RANGES_DEPRECATED( @@ -232,9 +235,10 @@ namespace ranges typename Rng2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires forward_range AND forward_range AND - indirectly_comparable, iterator_t, C, P1, P2>) // + indirectly_comparable, iterator_t, C, P1, P2>) bool RANGES_FUNC(is_permutation)( Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{}, P2 proj2 = P2{}) // { @@ -264,9 +268,10 @@ namespace ranges RANGES_FUNC_BEGIN(next_permutation) /// \brief function template \c next_permutation - template(typename I, typename S, typename C = less, typename P = identity)( // - requires bidirectional_iterator AND sentinel_for AND // - sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_iterator AND sentinel_for AND + sortable) bool RANGES_FUNC(next_permutation)(I first, S end_, C pred = C{}, P proj = P{}) // { if(first == end_) @@ -295,8 +300,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires bidirectional_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_range AND sortable, C, P>) bool RANGES_FUNC(next_permutation)(Rng && rng, C pred = C{}, P proj = P{}) // { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); @@ -307,9 +313,10 @@ namespace ranges RANGES_FUNC_BEGIN(prev_permutation) /// \brief function template \c prev_permutation - template(typename I, typename S, typename C = less, typename P = identity)( // - requires bidirectional_iterator AND sentinel_for AND // - sortable) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_iterator AND sentinel_for AND + sortable) bool RANGES_FUNC(prev_permutation)(I first, S end_, C pred = C{}, P proj = P{}) // { if(first == end_) @@ -338,8 +345,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires bidirectional_range AND sortable, C, P>) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires bidirectional_range AND sortable, C, P>) bool RANGES_FUNC(prev_permutation)(Rng && rng, C pred = C{}, P proj = P{}) // { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); diff --git a/include/range/v3/algorithm/remove.hpp b/include/range/v3/algorithm/remove.hpp index 88223d18a8..7cad286b4b 100644 --- a/include/range/v3/algorithm/remove.hpp +++ b/include/range/v3/algorithm/remove.hpp @@ -38,9 +38,10 @@ namespace ranges RANGES_FUNC_BEGIN(remove) /// \brief function template \c remove - template(typename I, typename S, typename T, typename P = identity)( // - requires permutable AND sentinel_for AND // - indirect_relation, T const *>) // + template(typename I, typename S, typename T, typename P = identity)( + /// \pre + requires permutable AND sentinel_for AND + indirect_relation, T const *>) I RANGES_FUNC(remove)(I first, S last, T const & val, P proj = P{}) { first = find(std::move(first), last, val, std::ref(proj)); @@ -59,9 +60,10 @@ namespace ranges } /// \overload - template(typename Rng, typename T, typename P = identity)( // - requires forward_range AND permutable> AND // - indirect_relation, P>, T const *>) // + template(typename Rng, typename T, typename P = identity)( + /// \pre + requires forward_range AND permutable> AND + indirect_relation, P>, T const *>) borrowed_iterator_t // RANGES_FUNC(remove)(Rng && rng, T const & val, P proj = P{}) { diff --git a/include/range/v3/algorithm/remove_copy.hpp b/include/range/v3/algorithm/remove_copy.hpp index 33f73618a8..ad76b8c3b0 100644 --- a/include/range/v3/algorithm/remove_copy.hpp +++ b/include/range/v3/algorithm/remove_copy.hpp @@ -41,10 +41,11 @@ namespace ranges /// \brief function template \c remove_copy template(typename I, typename S, typename O, typename T, typename P = identity)( + /// \pre requires input_iterator AND sentinel_for AND weakly_incrementable AND indirect_relation, T const *> AND - indirectly_copyable) // + indirectly_copyable) remove_copy_result RANGES_FUNC(remove_copy)( I first, S last, O out, T const & val, P proj = P{}) // { @@ -61,10 +62,11 @@ namespace ranges } /// \overload - template(typename Rng, typename O, typename T, typename P = identity)( // - requires input_range AND weakly_incrementable AND // - indirect_relation, P>, T const *> AND // - indirectly_copyable, O>) // + template(typename Rng, typename O, typename T, typename P = identity)( + /// \pre + requires input_range AND weakly_incrementable AND + indirect_relation, P>, T const *> AND + indirectly_copyable, O>) remove_copy_result, O> // RANGES_FUNC(remove_copy)(Rng && rng, O out, T const & val, P proj = P{}) // { diff --git a/include/range/v3/algorithm/remove_copy_if.hpp b/include/range/v3/algorithm/remove_copy_if.hpp index 47e010b539..3e5b157472 100644 --- a/include/range/v3/algorithm/remove_copy_if.hpp +++ b/include/range/v3/algorithm/remove_copy_if.hpp @@ -41,9 +41,10 @@ namespace ranges /// \brief function template \c remove_copy_if template(typename I, typename S, typename O, typename C, typename P = identity)( - requires input_iterator AND sentinel_for AND // + /// \pre + requires input_iterator AND sentinel_for AND weakly_incrementable AND indirect_unary_predicate> AND - indirectly_copyable) // + indirectly_copyable) remove_copy_if_result // RANGES_FUNC(remove_copy_if)(I first, S last, O out, C pred, P proj = P{}) // { @@ -60,10 +61,11 @@ namespace ranges } /// \overload - template(typename Rng, typename O, typename C, typename P = identity)( // - requires input_range AND weakly_incrementable AND // - indirect_unary_predicate, P>> AND // - indirectly_copyable, O>) // + template(typename Rng, typename O, typename C, typename P = identity)( + /// \pre + requires input_range AND weakly_incrementable AND + indirect_unary_predicate, P>> AND + indirectly_copyable, O>) remove_copy_if_result, O> // RANGES_FUNC(remove_copy_if)(Rng && rng, O out, C pred, P proj = P{}) // { diff --git a/include/range/v3/algorithm/remove_if.hpp b/include/range/v3/algorithm/remove_if.hpp index b263d0afc3..77682f13a0 100644 --- a/include/range/v3/algorithm/remove_if.hpp +++ b/include/range/v3/algorithm/remove_if.hpp @@ -38,9 +38,10 @@ namespace ranges RANGES_FUNC_BEGIN(remove_if) /// \brief function template \c remove_if - template(typename I, typename S, typename C, typename P = identity)( // - requires permutable AND sentinel_for AND // - indirect_unary_predicate>) // + template(typename I, typename S, typename C, typename P = identity)( + /// \pre + requires permutable AND sentinel_for AND + indirect_unary_predicate>) I RANGES_FUNC(remove_if)(I first, S last, C pred, P proj = P{}) { first = find_if(std::move(first), last, std::ref(pred), std::ref(proj)); @@ -59,9 +60,10 @@ namespace ranges } /// \overload - template(typename Rng, typename C, typename P = identity)( // - requires forward_range AND permutable> AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename C, typename P = identity)( + /// \pre + requires forward_range AND permutable> AND + indirect_unary_predicate, P>>) borrowed_iterator_t RANGES_FUNC(remove_if)(Rng && rng, C pred, P proj = P{}) { return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); diff --git a/include/range/v3/algorithm/replace.hpp b/include/range/v3/algorithm/replace.hpp index d99b4ad80f..a206de6c2b 100644 --- a/include/range/v3/algorithm/replace.hpp +++ b/include/range/v3/algorithm/replace.hpp @@ -37,9 +37,10 @@ namespace ranges /// \brief function template \c replace template(typename I, typename S, typename T1, typename T2, typename P = identity)( + /// \pre requires input_iterator AND sentinel_for AND indirectly_writable AND - indirect_relation, T1 const *>) // + indirect_relation, T1 const *>) I RANGES_FUNC(replace)( I first, S last, T1 const & old_value, T2 const & new_value, P proj = {}) // { @@ -50,10 +51,11 @@ namespace ranges } /// \overload - template(typename Rng, typename T1, typename T2, typename P = identity)( // + template(typename Rng, typename T1, typename T2, typename P = identity)( + /// \pre requires input_range AND indirectly_writable, T2 const &> AND - indirect_relation, P>, T1 const *>) // + indirect_relation, P>, T1 const *>) borrowed_iterator_t RANGES_FUNC(replace)( Rng && rng, T1 const & old_value, T2 const & new_value, P proj = {}) // { diff --git a/include/range/v3/algorithm/replace_copy.hpp b/include/range/v3/algorithm/replace_copy.hpp index 47d513e035..d4709b3941 100644 --- a/include/range/v3/algorithm/replace_copy.hpp +++ b/include/range/v3/algorithm/replace_copy.hpp @@ -45,10 +45,11 @@ namespace ranges typename O, typename T1, typename T2, - typename P = identity)( // + typename P = identity)( + /// \pre requires input_iterator AND sentinel_for AND output_iterator AND indirectly_copyable AND - indirect_relation, T1 const *>) // + indirect_relation, T1 const *>) replace_copy_result RANGES_FUNC(replace_copy)(I first, S last, O out, @@ -72,10 +73,11 @@ namespace ranges typename O, typename T1, typename T2, - typename P = identity)( // + typename P = identity)( + /// \pre requires input_range AND output_iterator AND indirectly_copyable, O> AND - indirect_relation, P>, T1 const *>) // + indirect_relation, P>, T1 const *>) replace_copy_result, O> RANGES_FUNC(replace_copy)( Rng && rng, O out, T1 const & old_value, T2 const & new_value, P proj = {}) // { diff --git a/include/range/v3/algorithm/replace_copy_if.hpp b/include/range/v3/algorithm/replace_copy_if.hpp index c8097aee8e..080b51dc8b 100644 --- a/include/range/v3/algorithm/replace_copy_if.hpp +++ b/include/range/v3/algorithm/replace_copy_if.hpp @@ -45,11 +45,12 @@ namespace ranges typename O, typename C, typename T, - typename P = identity)( // + typename P = identity)( + /// \pre requires input_iterator AND sentinel_for AND output_iterator AND indirect_unary_predicate> AND - indirectly_copyable) // + indirectly_copyable) replace_copy_if_result RANGES_FUNC(replace_copy_if)( I first, S last, O out, C pred, T const & new_value, P proj = {}) // { @@ -66,9 +67,10 @@ namespace ranges /// \overload template(typename Rng, typename O, typename C, typename T, typename P = identity)( + /// \pre requires input_range AND output_iterator AND indirect_unary_predicate, P>> AND - indirectly_copyable, O>) // + indirectly_copyable, O>) replace_copy_if_result, O> RANGES_FUNC(replace_copy_if)( Rng && rng, O out, C pred, T const & new_value, P proj = {}) // { diff --git a/include/range/v3/algorithm/replace_if.hpp b/include/range/v3/algorithm/replace_if.hpp index 4b117d7984..c820c8ac27 100644 --- a/include/range/v3/algorithm/replace_if.hpp +++ b/include/range/v3/algorithm/replace_if.hpp @@ -37,9 +37,10 @@ namespace ranges /// \brief function template \c replace_if template(typename I, typename S, typename C, typename T, typename P = identity)( + /// \pre requires input_iterator AND sentinel_for AND indirect_unary_predicate> AND - indirectly_writable) // + indirectly_writable) I RANGES_FUNC(replace_if)( I first, S last, C pred, T const & new_value, P proj = P{}) // { @@ -50,10 +51,11 @@ namespace ranges } /// \overload - template(typename Rng, typename C, typename T, typename P = identity)( // + template(typename Rng, typename C, typename T, typename P = identity)( + /// \pre requires input_range AND indirect_unary_predicate, P>> AND - indirectly_writable, T const &>) // + indirectly_writable, T const &>) borrowed_iterator_t RANGES_FUNC(replace_if)( Rng && rng, C pred, T const & new_value, P proj = P{}) // { diff --git a/include/range/v3/algorithm/reverse.hpp b/include/range/v3/algorithm/reverse.hpp index 7e8cb9c746..8443be5c89 100644 --- a/include/range/v3/algorithm/reverse.hpp +++ b/include/range/v3/algorithm/reverse.hpp @@ -60,7 +60,8 @@ namespace ranges RANGES_FUNC_BEGIN(reverse) /// \brief function template \c reverse - template(typename I, typename S)( // + template(typename I, typename S)( + /// \pre requires bidirectional_iterator AND sentinel_for AND permutable) I RANGES_FUNC(reverse)(I first, S end_) { @@ -70,8 +71,9 @@ namespace ranges } /// \overload - template(typename Rng, typename I = iterator_t)( // - requires bidirectional_range AND permutable) // + template(typename Rng, typename I = iterator_t)( + /// \pre + requires bidirectional_range AND permutable) borrowed_iterator_t RANGES_FUNC(reverse)(Rng && rng) // { return (*this)(begin(rng), end(rng)); diff --git a/include/range/v3/algorithm/reverse_copy.hpp b/include/range/v3/algorithm/reverse_copy.hpp index 353f9dd32d..89cd82fe4f 100644 --- a/include/range/v3/algorithm/reverse_copy.hpp +++ b/include/range/v3/algorithm/reverse_copy.hpp @@ -39,9 +39,10 @@ namespace ranges RANGES_FUNC_BEGIN(reverse_copy) /// \brief function template \c reverse_copy - template(typename I, typename S, typename O)( // - requires bidirectional_iterator AND sentinel_for AND // - weakly_incrementable AND indirectly_copyable) // + template(typename I, typename S, typename O)( + /// \pre + requires bidirectional_iterator AND sentinel_for AND + weakly_incrementable AND indirectly_copyable) reverse_copy_result RANGES_FUNC(reverse_copy)(I first, S end_, O out) // { I last = ranges::next(first, end_), res = last; @@ -51,9 +52,10 @@ namespace ranges } /// \overload - template(typename Rng, typename O)( // - requires bidirectional_range AND weakly_incrementable AND // - indirectly_copyable, O>) // + template(typename Rng, typename O)( + /// \pre + requires bidirectional_range AND weakly_incrementable AND + indirectly_copyable, O>) reverse_copy_result, O> // RANGES_FUNC(reverse_copy)(Rng && rng, O out) // { diff --git a/include/range/v3/algorithm/rotate.hpp b/include/range/v3/algorithm/rotate.hpp index 2cf54389e2..4e8713e24e 100644 --- a/include/range/v3/algorithm/rotate.hpp +++ b/include/range/v3/algorithm/rotate.hpp @@ -196,8 +196,9 @@ namespace ranges RANGES_FUNC_BEGIN(rotate) /// \brief function template \c rotate - template(typename I, typename S)( // - requires permutable AND sentinel_for) // + template(typename I, typename S)( + /// \pre + requires permutable AND sentinel_for) subrange RANGES_FUNC(rotate)(I first, I middle, S last) // { if(first == middle) @@ -213,8 +214,9 @@ namespace ranges } /// \overload - template(typename Rng, typename I = iterator_t)( // - requires range AND permutable) // + template(typename Rng, typename I = iterator_t)( + /// \pre + requires range AND permutable) safe_subrange_t RANGES_FUNC(rotate)(Rng && rng, I middle) // { return (*this)(begin(rng), std::move(middle), end(rng)); diff --git a/include/range/v3/algorithm/rotate_copy.hpp b/include/range/v3/algorithm/rotate_copy.hpp index 3655ab9bd5..16817b3048 100644 --- a/include/range/v3/algorithm/rotate_copy.hpp +++ b/include/range/v3/algorithm/rotate_copy.hpp @@ -40,9 +40,10 @@ namespace ranges RANGES_FUNC_BEGIN(rotate_copy) /// \brief function template \c rotate_copy - template(typename I, typename S, typename O, typename P = identity)( // - requires forward_iterator AND sentinel_for AND // - weakly_incrementable AND indirectly_copyable) // + template(typename I, typename S, typename O, typename P = identity)( + /// \pre + requires forward_iterator AND sentinel_for AND + weakly_incrementable AND indirectly_copyable) rotate_copy_result // RANGES_FUNC(rotate_copy)(I first, I middle, S last, O out) // { @@ -52,9 +53,10 @@ namespace ranges } /// \overload - template(typename Rng, typename O, typename P = identity)( // - requires range AND weakly_incrementable AND // - indirectly_copyable, O>) // + template(typename Rng, typename O, typename P = identity)( + /// \pre + requires range AND weakly_incrementable AND + indirectly_copyable, O>) rotate_copy_result, O> // RANGES_FUNC(rotate_copy)(Rng && rng, iterator_t middle, O out) // { diff --git a/include/range/v3/algorithm/sample.hpp b/include/range/v3/algorithm/sample.hpp index 40147e47e3..7b37b931e8 100644 --- a/include/range/v3/algorithm/sample.hpp +++ b/include/range/v3/algorithm/sample.hpp @@ -79,7 +79,8 @@ namespace ranges template(typename I, typename S, typename O, - typename Gen = detail::default_random_engine &)( // + typename Gen = detail::default_random_engine &)( + /// \pre requires input_iterator AND sentinel_for AND weakly_incrementable AND indirectly_copyable AND uniform_random_bit_generator> AND @@ -137,7 +138,8 @@ namespace ranges template(typename I, typename S, typename ORng, - typename Gen = detail::default_random_engine &)( // + typename Gen = detail::default_random_engine &)( + /// \pre requires input_iterator AND sentinel_for AND weakly_incrementable> AND indirectly_copyable> AND @@ -175,6 +177,7 @@ namespace ranges template(typename Rng, typename O, typename Gen = detail::default_random_engine &)( + /// \pre requires input_range AND weakly_incrementable AND indirectly_copyable, O> AND uniform_random_bit_generator> AND @@ -204,7 +207,8 @@ namespace ranges /// \overload template(typename IRng, typename ORng, - typename Gen = detail::default_random_engine &)( // + typename Gen = detail::default_random_engine &)( + /// \pre requires input_range AND range AND indirectly_copyable, iterator_t> AND uniform_random_bit_generator> AND diff --git a/include/range/v3/algorithm/search.hpp b/include/range/v3/algorithm/search.hpp index 3aaef99ead..ecf1b54099 100644 --- a/include/range/v3/algorithm/search.hpp +++ b/include/range/v3/algorithm/search.hpp @@ -152,10 +152,11 @@ namespace ranges typename S2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires forward_iterator AND sentinel_for AND forward_iterator AND sentinel_for AND - indirectly_comparable) // + indirectly_comparable) subrange RANGES_FUNC(search)(I1 begin1, S1 end1, I2 begin2, @@ -192,9 +193,10 @@ namespace ranges typename Rng2, typename C = equal_to, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires forward_range AND forward_range AND - indirectly_comparable, iterator_t, C, P1, P2>) // + indirectly_comparable, iterator_t, C, P1, P2>) safe_subrange_t RANGES_FUNC(search)( Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{}, P2 proj2 = P2{}) // { diff --git a/include/range/v3/algorithm/search_n.hpp b/include/range/v3/algorithm/search_n.hpp index 3169536fd8..9fa827448a 100644 --- a/include/range/v3/algorithm/search_n.hpp +++ b/include/range/v3/algorithm/search_n.hpp @@ -139,9 +139,10 @@ namespace ranges typename S, typename V, typename C = equal_to, - typename P = identity)( // + typename P = identity)( + /// \pre requires forward_iterator AND sentinel_for AND - indirectly_comparable) // + indirectly_comparable) subrange RANGES_FUNC(search_n)(I first, S last, iter_difference_t cnt, @@ -166,8 +167,9 @@ namespace ranges /// \overload template(typename Rng, typename V, typename C = equal_to, typename P = identity)( + /// \pre requires forward_range AND - indirectly_comparable, V const *, C, P>) // + indirectly_comparable, V const *, C, P>) safe_subrange_t RANGES_FUNC(search_n)(Rng && rng, iter_difference_t> cnt, V const & val, diff --git a/include/range/v3/algorithm/set_algorithm.hpp b/include/range/v3/algorithm/set_algorithm.hpp index c1149597ab..0d0406e13a 100644 --- a/include/range/v3/algorithm/set_algorithm.hpp +++ b/include/range/v3/algorithm/set_algorithm.hpp @@ -53,10 +53,11 @@ namespace ranges typename S2, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND sentinel_for AND - indirect_strict_weak_order, projected>) // + indirect_strict_weak_order, projected>) bool RANGES_FUNC(includes)(I1 begin1, S1 end1, I2 begin2, @@ -81,11 +82,12 @@ namespace ranges typename Rng2, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires input_range AND input_range AND indirect_strict_weak_order, P1>, - projected, P2>>) // + projected, P2>>) bool RANGES_FUNC(includes)( Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{}, P2 proj2 = P2{}) // { @@ -118,9 +120,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - mergeable) // + mergeable) set_union_result RANGES_FUNC(set_union)(I1 begin1, S1 end1, I2 begin2, @@ -160,9 +163,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires range AND range AND - mergeable, iterator_t, O, C, P1, P2>) // + mergeable, iterator_t, O, C, P1, P2>) set_union_result, borrowed_iterator_t, O> // RANGES_FUNC(set_union)(Rng1 && rng1, Rng2 && rng2, @@ -199,9 +203,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - mergeable) // + mergeable) O RANGES_FUNC(set_intersection)(I1 begin1, S1 end1, I2 begin2, @@ -235,9 +240,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires range AND range AND - mergeable, iterator_t, O, C, P1, P2>) // + mergeable, iterator_t, O, C, P1, P2>) O RANGES_FUNC(set_intersection)(Rng1 && rng1, Rng2 && rng2, O out, @@ -275,9 +281,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - mergeable) // + mergeable) set_difference_result RANGES_FUNC(set_difference)(I1 begin1, S1 end1, I2 begin2, @@ -316,9 +323,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires range AND range AND - mergeable, iterator_t, O, C, P1, P2>) // + mergeable, iterator_t, O, C, P1, P2>) set_difference_result, O> // RANGES_FUNC(set_difference)(Rng1 && rng1, Rng2 && rng2, @@ -358,9 +366,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - mergeable) // + mergeable) set_symmetric_difference_result // RANGES_FUNC(set_symmetric_difference)(I1 begin1, S1 end1, @@ -406,9 +415,10 @@ namespace ranges typename O, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires range AND range AND - mergeable, iterator_t, O, C, P1, P2>) // + mergeable, iterator_t, O, C, P1, P2>) set_symmetric_difference_result, borrowed_iterator_t, O> diff --git a/include/range/v3/algorithm/shuffle.hpp b/include/range/v3/algorithm/shuffle.hpp index c7db4d8a7e..1e944d9c05 100644 --- a/include/range/v3/algorithm/shuffle.hpp +++ b/include/range/v3/algorithm/shuffle.hpp @@ -39,10 +39,11 @@ namespace ranges /// \brief function template \c shuffle template(typename I, typename S, typename Gen = detail::default_random_engine &)( + /// \pre requires random_access_iterator AND sentinel_for AND permutable AND uniform_random_bit_generator> AND - convertible_to, iter_difference_t>) // + convertible_to, iter_difference_t>) I RANGES_FUNC(shuffle)(I const first, S const last, Gen && gen = detail::get_random_engine()) // @@ -65,11 +66,12 @@ namespace ranges } /// \overload - template(typename Rng, typename Gen = detail::default_random_engine &)( // + template(typename Rng, typename Gen = detail::default_random_engine &)( + /// \pre requires random_access_range AND permutable> AND uniform_random_bit_generator> AND convertible_to, - iter_difference_t>>) // + iter_difference_t>>) borrowed_iterator_t // RANGES_FUNC(shuffle)(Rng && rng, Gen && rand = detail::get_random_engine()) // { diff --git a/include/range/v3/algorithm/sort.hpp b/include/range/v3/algorithm/sort.hpp index c22551f683..9255d2dbe7 100644 --- a/include/range/v3/algorithm/sort.hpp +++ b/include/range/v3/algorithm/sort.hpp @@ -194,9 +194,10 @@ namespace ranges RANGES_FUNC_BEGIN(sort) /// \brief function template \c sort - template(typename I, typename S, typename C = less, typename P = identity)( // - requires sortable AND random_access_iterator AND // - sentinel_for) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires sortable AND random_access_iterator AND + sentinel_for) I RANGES_FUNC(sort)(I first, S end_, C pred = C{}, P proj = P{}) { I last = ranges::next(first, std::move(end_)); @@ -210,8 +211,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires sortable, C, P> AND random_access_range) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires sortable, C, P> AND random_access_range) borrowed_iterator_t // RANGES_FUNC(sort)(Rng && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/stable_partition.hpp b/include/range/v3/algorithm/stable_partition.hpp index 6ebbdaf7c1..607e055529 100644 --- a/include/range/v3/algorithm/stable_partition.hpp +++ b/include/range/v3/algorithm/stable_partition.hpp @@ -293,9 +293,10 @@ namespace ranges RANGES_FUNC_BEGIN(stable_partition) /// \brief function template \c stable_partition - template(typename I, typename S, typename C, typename P = identity)( // - requires bidirectional_iterator AND sentinel_for AND // - indirect_unary_predicate> AND permutable) // + template(typename I, typename S, typename C, typename P = identity)( + /// \pre + requires bidirectional_iterator AND sentinel_for AND + indirect_unary_predicate> AND permutable) I RANGES_FUNC(stable_partition)(I first, S last, C pred, P proj = P{}) { return detail::stable_partition_impl(std::move(first), @@ -307,10 +308,11 @@ namespace ranges // BUGBUG Can this be optimized if Rng has O1 size? /// \overload - template(typename Rng, typename C, typename P = identity)( // - requires bidirectional_range AND // - indirect_unary_predicate, P>> AND // - permutable>) // + template(typename Rng, typename C, typename P = identity)( + /// \pre + requires bidirectional_range AND + indirect_unary_predicate, P>> AND + permutable>) borrowed_iterator_t // RANGES_FUNC(stable_partition)(Rng && rng, C pred, P proj = P{}) // { diff --git a/include/range/v3/algorithm/stable_sort.hpp b/include/range/v3/algorithm/stable_sort.hpp index 4888302afd..6de064ea86 100644 --- a/include/range/v3/algorithm/stable_sort.hpp +++ b/include/range/v3/algorithm/stable_sort.hpp @@ -193,9 +193,10 @@ namespace ranges RANGES_FUNC_BEGIN(stable_sort) /// \brief function template \c stable_sort - template(typename I, typename S, typename C = less, typename P = identity)( // - requires sortable AND random_access_iterator AND // - sentinel_for) // + template(typename I, typename S, typename C = less, typename P = identity)( + /// \pre + requires sortable AND random_access_iterator AND + sentinel_for) I RANGES_FUNC(stable_sort)(I first, S end_, C pred = C{}, P proj = P{}) { I last = ranges::next(first, end_); @@ -214,8 +215,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = less, typename P = identity)( // - requires sortable, C, P> AND random_access_range) // + template(typename Rng, typename C = less, typename P = identity)( + /// \pre + requires sortable, C, P> AND random_access_range) borrowed_iterator_t // RANGES_FUNC(stable_sort)(Rng && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/starts_with.hpp b/include/range/v3/algorithm/starts_with.hpp index bf5c53730d..2fa6af6446 100644 --- a/include/range/v3/algorithm/starts_with.hpp +++ b/include/range/v3/algorithm/starts_with.hpp @@ -48,10 +48,11 @@ namespace ranges typename S2, typename Comp = equal_to, typename Proj1 = identity, - typename Proj2 = identity)( // + typename Proj2 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND sentinel_for AND - indirectly_comparable) // + indirectly_comparable) constexpr bool RANGES_FUNC(starts_with)(I1 first1, S1 last1, I2 first2, @@ -75,7 +76,8 @@ namespace ranges typename R2, typename Comp = equal_to, typename Proj1 = identity, - typename Proj2 = identity)( // + typename Proj2 = identity)( + /// \pre requires input_range AND input_range AND indirectly_comparable, iterator_t, Comp, Proj1, Proj2>) constexpr bool RANGES_FUNC(starts_with)( diff --git a/include/range/v3/algorithm/swap_ranges.hpp b/include/range/v3/algorithm/swap_ranges.hpp index a57c26cd10..13c6b4c29f 100644 --- a/include/range/v3/algorithm/swap_ranges.hpp +++ b/include/range/v3/algorithm/swap_ranges.hpp @@ -36,9 +36,10 @@ namespace ranges RANGES_FUNC_BEGIN(swap_ranges) /// \brief function template \c swap_ranges - template(typename I1, typename S1, typename I2)( // - requires input_iterator AND sentinel_for AND // - input_iterator AND indirectly_swappable) // + template(typename I1, typename S1, typename I2)( + /// \pre + requires input_iterator AND sentinel_for AND + input_iterator AND indirectly_swappable) swap_ranges_result // RANGES_FUNC(swap_ranges)(I1 begin1, S1 end1, I2 begin2) // { @@ -48,10 +49,11 @@ namespace ranges } /// \overload - template(typename I1, typename S1, typename I2, typename S2)( // + template(typename I1, typename S1, typename I2, typename S2)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND sentinel_for AND - indirectly_swappable) // + indirectly_swappable) swap_ranges_result RANGES_FUNC(swap_ranges)(I1 begin1, S1 end1, I2 begin2, @@ -62,18 +64,20 @@ namespace ranges return {begin1, begin2}; } - template(typename Rng1, typename I2_)( // - requires input_range AND input_iterator> AND // - indirectly_swappable, uncvref_t>) // + template(typename Rng1, typename I2_)( + /// \pre + requires input_range AND input_iterator> AND + indirectly_swappable, uncvref_t>) swap_ranges_result, uncvref_t> // RANGES_FUNC(swap_ranges)(Rng1 && rng1, I2_ && begin2) // { return (*this)(begin(rng1), end(rng1), (I2_ &&) begin2); } - template(typename Rng1, typename Rng2)( // + template(typename Rng1, typename Rng2)( + /// \pre requires input_range AND input_range AND - indirectly_swappable, iterator_t>) // + indirectly_swappable, iterator_t>) swap_ranges_result, borrowed_iterator_t> // RANGES_FUNC(swap_ranges)(Rng1 && rng1, Rng2 && rng2) // { diff --git a/include/range/v3/algorithm/transform.hpp b/include/range/v3/algorithm/transform.hpp index 1495e3b481..7e16fa75cd 100644 --- a/include/range/v3/algorithm/transform.hpp +++ b/include/range/v3/algorithm/transform.hpp @@ -48,9 +48,10 @@ namespace ranges // Single-range variant /// \brief function template \c transform template(typename I, typename S, typename O, typename F, typename P = identity)( - requires input_iterator AND sentinel_for AND // - weakly_incrementable AND copy_constructible AND // - indirectly_writable>>) // + /// \pre + requires input_iterator AND sentinel_for AND + weakly_incrementable AND copy_constructible AND + indirectly_writable>>) unary_transform_result // RANGES_FUNC(transform)(I first, S last, O out, F fun, P proj = P{}) // { @@ -60,9 +61,10 @@ namespace ranges } /// \overload - template(typename Rng, typename O, typename F, typename P = identity)( // - requires input_range AND weakly_incrementable AND // - copy_constructible AND // + template(typename Rng, typename O, typename F, typename P = identity)( + /// \pre + requires input_range AND weakly_incrementable AND + copy_constructible AND indirectly_writable, P>>>) unary_transform_result, O> // RANGES_FUNC(transform)(Rng && rng, O out, F fun, P proj = P{}) // @@ -80,13 +82,14 @@ namespace ranges typename O, typename F, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND sentinel_for AND weakly_incrementable AND copy_constructible AND indirectly_writable< O, - indirect_result_t, projected>>) // + indirect_result_t, projected>>) binary_transform_result // RANGES_FUNC(transform)(I0 begin0, S0 end0, @@ -108,14 +111,15 @@ namespace ranges typename O, typename F, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_range AND input_range AND weakly_incrementable AND copy_constructible AND indirectly_writable< O, indirect_result_t, P0>, - projected, P1>>>) // + projected, P1>>>) binary_transform_result, borrowed_iterator_t, O> // @@ -140,10 +144,11 @@ namespace ranges typename O, typename F, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_iterator AND sentinel_for AND input_iterator AND weakly_incrementable AND - copy_constructible AND // + copy_constructible AND indirectly_writable< O, indirect_result_t, projected>>) @@ -175,7 +180,8 @@ namespace ranges typename O, typename F, typename P0 = identity, - typename P1 = identity)( // + typename P1 = identity)( + /// \pre requires input_range AND input_iterator> AND weakly_incrementable AND copy_constructible AND indirectly_writable< diff --git a/include/range/v3/algorithm/unique.hpp b/include/range/v3/algorithm/unique.hpp index a78b9ca7e6..aa7e032ddf 100644 --- a/include/range/v3/algorithm/unique.hpp +++ b/include/range/v3/algorithm/unique.hpp @@ -47,8 +47,9 @@ namespace ranges /// \pre `S` is a model of the `sentinel_for` concept /// \pre `C` is a model of the `relation` concept /// - template(typename I, typename S, typename C = equal_to, typename P = identity)( // - requires sortable AND sentinel_for) // + template(typename I, typename S, typename C = equal_to, typename P = identity)( + /// \pre + requires sortable AND sentinel_for) I RANGES_FUNC(unique)(I first, S last, C pred = C{}, P proj = P{}) { first = adjacent_find(std::move(first), last, std::ref(pred), std::ref(proj)); @@ -64,8 +65,9 @@ namespace ranges } /// \overload - template(typename Rng, typename C = equal_to, typename P = identity)( // - requires sortable, C, P> AND range) // + template(typename Rng, typename C = equal_to, typename P = identity)( + /// \pre + requires sortable, C, P> AND range) borrowed_iterator_t // RANGES_FUNC(unique)(Rng && rng, C pred = C{}, P proj = P{}) // { diff --git a/include/range/v3/algorithm/unique_copy.hpp b/include/range/v3/algorithm/unique_copy.hpp index 7cb3e3c84e..361b90bc3f 100644 --- a/include/range/v3/algorithm/unique_copy.hpp +++ b/include/range/v3/algorithm/unique_copy.hpp @@ -126,7 +126,8 @@ namespace ranges typename S, typename O, typename C = equal_to, - typename P = identity)( // + typename P = identity)( + /// \pre requires input_iterator AND sentinel_for AND indirect_relation> AND weakly_incrementable AND indirectly_copyable AND @@ -146,6 +147,7 @@ namespace ranges /// \overload template(typename Rng, typename O, typename C = equal_to, typename P = identity)( + /// \pre requires input_range AND indirect_relation, P>> AND weakly_incrementable AND indirectly_copyable, O> AND diff --git a/include/range/v3/algorithm/unstable_remove_if.hpp b/include/range/v3/algorithm/unstable_remove_if.hpp index 3cf4cbfcad..e07cdd4882 100644 --- a/include/range/v3/algorithm/unstable_remove_if.hpp +++ b/include/range/v3/algorithm/unstable_remove_if.hpp @@ -44,9 +44,10 @@ namespace ranges RANGES_FUNC_BEGIN(unstable_remove_if) /// \brief function template \c unstable_remove_if - template(typename I, typename C, typename P = identity)( // - requires bidirectional_iterator AND permutable AND // - indirect_unary_predicate>) // + template(typename I, typename C, typename P = identity)( + /// \pre + requires bidirectional_iterator AND permutable AND + indirect_unary_predicate>) I RANGES_FUNC(unstable_remove_if)(I first, I last, C pred, P proj = {}) { while(true) @@ -67,10 +68,11 @@ namespace ranges } /// \overload - template(typename Rng, typename C, typename P = identity)( // - requires bidirectional_range AND common_range AND // - permutable> AND // - indirect_unary_predicate, P>>) // + template(typename Rng, typename C, typename P = identity)( + /// \pre + requires bidirectional_range AND common_range AND + permutable> AND + indirect_unary_predicate, P>>) borrowed_iterator_t // RANGES_FUNC(unstable_remove_if)(Rng && rng, C pred, P proj = P{}) // { diff --git a/include/range/v3/algorithm/upper_bound.hpp b/include/range/v3/algorithm/upper_bound.hpp index e7eaffb42a..da644a3c84 100644 --- a/include/range/v3/algorithm/upper_bound.hpp +++ b/include/range/v3/algorithm/upper_bound.hpp @@ -39,9 +39,10 @@ namespace ranges typename S, typename V, typename C = less, - typename P = identity)( // + typename P = identity)( + /// \pre requires forward_iterator AND sentinel_for AND - indirect_strict_weak_order>) // + indirect_strict_weak_order>) I RANGES_FUNC(upper_bound)( I first, S last, V const & val, C pred = C{}, P proj = P{}) // { @@ -52,7 +53,8 @@ namespace ranges } /// \overload - template(typename Rng, typename V, typename C = less, typename P = identity)( // + template(typename Rng, typename V, typename C = less, typename P = identity)( + /// \pre requires forward_range AND indirect_strict_weak_order, P>>) borrowed_iterator_t RANGES_FUNC(upper_bound)( diff --git a/include/range/v3/detail/adl_get.hpp b/include/range/v3/detail/adl_get.hpp index ed227da1ee..c1d99530ac 100644 --- a/include/range/v3/detail/adl_get.hpp +++ b/include/range/v3/detail/adl_get.hpp @@ -70,14 +70,16 @@ namespace ranges // Clang 3.x have a problem with inheriting constructors // that causes the declarations in the preceeding PP block to get // instantiated too early. - template(typename B = TupleLike)( // - requires move_constructible) // + template(typename B = TupleLike)( + /// \pre + requires move_constructible) constexpr forward_tuple_interface(TupleLike && base) noexcept( std::is_nothrow_move_constructible::value) : TupleLike(static_cast(base)) {} - template(typename B = TupleLike)( // - requires copy_constructible) // + template(typename B = TupleLike)( + /// \pre + requires copy_constructible) constexpr forward_tuple_interface(TupleLike const & base) noexcept( std::is_nothrow_copy_constructible::value) : TupleLike(base) diff --git a/include/range/v3/detail/prologue.hpp b/include/range/v3/detail/prologue.hpp index 2561f3ebf7..d4c0187c0e 100644 --- a/include/range/v3/detail/prologue.hpp +++ b/include/range/v3/detail/prologue.hpp @@ -33,6 +33,5 @@ RANGES_DIAGNOSTIC_KEYWORD_MACRO #define template(...) \ CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ template<__VA_ARGS__ CPP_TEMPLATE_AUX_ \ - /**/ #define AND CPP_and diff --git a/include/range/v3/detail/range_access.hpp b/include/range/v3/detail/range_access.hpp index 2d64ea7580..34ff4865b6 100644 --- a/include/range/v3/detail/range_access.hpp +++ b/include/range/v3/detail/range_access.hpp @@ -338,7 +338,8 @@ namespace ranges sized_sentinel_for_cursor && // CPP_requires_ref(detail::random_access_cursor_, T); - template(class T)( // + template(class T)( + /// \pre requires std::is_lvalue_reference::value) void is_lvalue_reference(T&&); diff --git a/include/range/v3/detail/variant.hpp b/include/range/v3/detail/variant.hpp index 35ae863f62..fef94d3f06 100644 --- a/include/range/v3/detail/variant.hpp +++ b/include/range/v3/detail/variant.hpp @@ -108,7 +108,8 @@ namespace ranges { struct indexed_element_fn; - template(typename I, typename S, typename O)( // + template(typename I, typename S, typename O)( + /// \pre requires (!sized_sentinel_for)) // O uninitialized_copy(I first, S last, O out) { @@ -117,8 +118,9 @@ namespace ranges return out; } - template(typename I, typename S, typename O)( // - requires sized_sentinel_for) // + template(typename I, typename S, typename O)( + /// \pre + requires sized_sentinel_for) O uninitialized_copy(I first, S last, O out) { return std::uninitialized_copy_n(first, (last - first), out); @@ -145,14 +147,16 @@ namespace ranges requires default_constructible) : datum_{} {} - template(typename... Ts)( // + template(typename... Ts)( + /// \pre requires constructible_from AND (sizeof...(Ts) != 0)) // constexpr indexed_datum(Ts &&... ts) noexcept( std::is_nothrow_constructible::value) : datum_(static_cast(ts)...) {} - template(typename U)( // - requires (!same_as) AND convertible_to) // + template(typename U)( + /// \pre + requires (!same_as) AND convertible_to) constexpr indexed_datum(indexed_datum that) // noexcept(std::is_nothrow_constructible::value) // : datum_(std::move(that.datum_)) @@ -664,7 +668,8 @@ namespace ranges : detail::variant_data{} , index_((std::size_t)-1) {} - template(typename... Args)( // + template(typename... Args)( + /// \pre requires (sizeof...(Args) == sizeof...(Ts))) // static constexpr bool all_convertible_to(int) noexcept { @@ -683,16 +688,18 @@ namespace ranges requires default_constructible>) : variant{emplaced_index<0>} {} - template(std::size_t N, typename... Args)( // - requires constructible_from, Args...>) // + template(std::size_t N, typename... Args)( + /// \pre + requires constructible_from, Args...>) constexpr variant(emplaced_index_t, Args &&... args) noexcept( std::is_nothrow_constructible, Args...>::value) : detail::variant_data{meta::size_t{}, static_cast(args)...} , index_(N) {} - template(std::size_t N, typename T, typename... Args)( // + template(std::size_t N, typename T, typename... Args)( + /// \pre requires constructible_from, std::initializer_list &, - Args...>) // + Args...>) constexpr variant( emplaced_index_t, std::initializer_list il, Args &&... args) noexcept(std:: @@ -704,8 +711,9 @@ namespace ranges static_cast(args)...} , index_(N) {} - template(std::size_t N)( // - requires constructible_from, meta::nil_>) // + template(std::size_t N)( + /// \pre + requires constructible_from, meta::nil_>) constexpr variant(emplaced_index_t, meta::nil_) noexcept(std::is_nothrow_constructible, meta::nil_>::value) : detail::variant_data{meta::size_t{}, meta::nil_{}} @@ -720,8 +728,9 @@ namespace ranges : detail::variant_data{} , index_(detail::variant_move_copy_(that.index(), data_(), that.data_())) {} - template(typename... Args)( // - requires (!same_as, variant>) AND // + template(typename... Args)( + /// \pre + requires (!same_as, variant>) AND (all_convertible_to(0))) // variant(variant that) : detail::variant_data{} @@ -742,7 +751,8 @@ namespace ranges this->assign_(that); return *this; } - template(typename... Args)( // + template(typename... Args)( + /// \pre requires (!same_as, variant>) AND (all_convertible_to(0))) variant & operator=(variant that) @@ -756,8 +766,9 @@ namespace ranges { return sizeof...(Ts); } - template(std::size_t N, typename... Args)( // - requires constructible_from, Args...>) // + template(std::size_t N, typename... Args)( + /// \pre + requires constructible_from, Args...>) void emplace(Args &&... args) { this->clear_(); @@ -815,8 +826,9 @@ namespace ranges } }; - template(typename... Ts, typename... Us)( // - requires and_v...>) // + template(typename... Ts, typename... Us)( + /// \pre + requires and_v...>) bool operator==(variant const & lhs, variant const & rhs) { return (!lhs.valid() && !rhs.valid()) || @@ -826,8 +838,9 @@ namespace ranges detail::variant_core_access::data(rhs))); } - template(typename... Ts, typename... Us)( // - requires and_v...>) // + template(typename... Ts, typename... Us)( + /// \pre + requires and_v...>) bool operator!=(variant const & lhs, variant const & rhs) { return !(lhs == rhs); @@ -835,8 +848,9 @@ namespace ranges ////////////////////////////////////////////////////////////////////////////////////// // emplace - template(std::size_t N, typename... Ts, typename... Args)( // - requires constructible_from, Args...>) // + template(std::size_t N, typename... Ts, typename... Args)( + /// \pre + requires constructible_from, Args...>) void emplace(variant & var, Args &&... args) { var.template emplace(static_cast(args)...); diff --git a/include/range/v3/experimental/utility/generator.hpp b/include/range/v3/experimental/utility/generator.hpp index 16a1569e75..4d798a9076 100644 --- a/include/range/v3/experimental/utility/generator.hpp +++ b/include/range/v3/experimental/utility/generator.hpp @@ -210,7 +210,8 @@ namespace ranges except_ = std::current_exception(); RANGES_EXPECT(except_); } - template(typename Arg)( // + template(typename Arg)( + /// \pre requires convertible_to AND std::is_assignable &, Arg>::value) // RANGES_COROUTINES_NS::suspend_always yield_value(Arg && arg) noexcept( diff --git a/include/range/v3/experimental/view/shared.hpp b/include/range/v3/experimental/view/shared.hpp index 058ab7692b..0f185bc324 100644 --- a/include/range/v3/experimental/view/shared.hpp +++ b/include/range/v3/experimental/view/shared.hpp @@ -59,7 +59,9 @@ namespace ranges } CPP_member - auto CPP_fun(size)()(const requires sized_range) + auto CPP_fun(size)()(const + /// \pre + requires sized_range) { return ranges::size(*rng_ptr_); } @@ -71,9 +73,10 @@ namespace ranges struct RANGES_STRUCT_WITH_ADL_BARRIER(shared_closure_base) { // Piping requires viewable_ranges. - template(typename Rng, typename SharedFn)( // - requires range AND (!viewable_range) AND // - constructible_from, Rng>) // + template(typename Rng, typename SharedFn)( + /// \pre + requires range AND (!viewable_range) AND + constructible_from, Rng>) friend constexpr auto operator|(Rng && rng, shared_closure vw) { return static_cast(vw)(static_cast(rng)); @@ -82,6 +85,7 @@ namespace ranges template friend constexpr auto operator|(shared_closure sh, Pipeable pipe) -> CPP_broken_friend_ret(shared_closure>)( + /// \pre requires (is_pipeable_v)) { return shared_closure>{compose( @@ -104,9 +108,10 @@ namespace ranges { struct shared_fn { - template(typename Rng)( // - requires range AND (!viewable_range)AND // - constructible_from, Rng>) // + template(typename Rng)( + /// \pre + requires range AND (!viewable_range)AND + constructible_from, Rng>) shared_view> operator()(Rng && rng) const { return shared_view>{static_cast(rng)}; diff --git a/include/range/v3/functional/bind.hpp b/include/range/v3/functional/bind.hpp index 27cad30103..1ceccd4388 100644 --- a/include/range/v3/functional/bind.hpp +++ b/include/range/v3/functional/bind.hpp @@ -97,14 +97,16 @@ namespace ranges struct protect_fn { - template(typename F)( // + template(typename F)( + /// \pre requires std::is_bind_expression>::value) // protector> operator()(F && f) const { return {static_cast(f)}; } /// \overload - template(typename F)( // + template(typename F)( + /// \pre requires (!std::is_bind_expression>::value)) // F operator()(F && f) const { diff --git a/include/range/v3/functional/comparisons.hpp b/include/range/v3/functional/comparisons.hpp index 4d5a0b7c31..e43cb30b85 100644 --- a/include/range/v3/functional/comparisons.hpp +++ b/include/range/v3/functional/comparisons.hpp @@ -26,8 +26,9 @@ namespace ranges /// @{ struct equal_to { - template(typename T, typename U)( // - requires equality_comparable_with) // + template(typename T, typename U)( + /// \pre + requires equality_comparable_with) constexpr bool operator()(T && t, U && u) const { return (T &&) t == (U &&) u; @@ -37,8 +38,9 @@ namespace ranges struct not_equal_to { - template(typename T, typename U)( // - requires equality_comparable_with) // + template(typename T, typename U)( + /// \pre + requires equality_comparable_with) constexpr bool operator()(T && t, U && u) const { return !equal_to{}((T &&) t, (U &&) u); @@ -48,8 +50,9 @@ namespace ranges struct less { - template(typename T, typename U)( // - requires totally_ordered_with) // + template(typename T, typename U)( + /// \pre + requires totally_ordered_with) constexpr bool operator()(T && t, U && u) const { return (T &&) t < (U &&) u; @@ -59,8 +62,9 @@ namespace ranges struct less_equal { - template(typename T, typename U)( // - requires totally_ordered_with) // + template(typename T, typename U)( + /// \pre + requires totally_ordered_with) constexpr bool operator()(T && t, U && u) const { return !less{}((U &&) u, (T &&) t); @@ -70,8 +74,9 @@ namespace ranges struct greater_equal { - template(typename T, typename U)( // - requires totally_ordered_with) // + template(typename T, typename U)( + /// \pre + requires totally_ordered_with) constexpr bool operator()(T && t, U && u) const { return !less{}((T &&) t, (U &&) u); @@ -81,8 +86,9 @@ namespace ranges struct greater { - template(typename T, typename U)( // - requires totally_ordered_with) // + template(typename T, typename U)( + /// \pre + requires totally_ordered_with) constexpr bool operator()(T && t, U && u) const { return less{}((U &&) u, (T &&) t); @@ -97,7 +103,8 @@ namespace ranges __has_include() struct compare_three_way { - template(typename T, typename U)( // + template(typename T, typename U)( + /// \pre requires three_way_comparable_with) constexpr auto operator()(T && t, U && u) const -> decltype((T &&) t <=> (U &&) u) diff --git a/include/range/v3/functional/invoke.hpp b/include/range/v3/functional/invoke.hpp index d8255eee96..d613e06c6a 100644 --- a/include/range/v3/functional/invoke.hpp +++ b/include/range/v3/functional/invoke.hpp @@ -90,23 +90,26 @@ namespace ranges struct invoke_fn { private: - template(typename, typename T1)( // - requires detail::dereferenceable_) // + template(typename, typename T1)( + /// \pre + requires detail::dereferenceable_) static constexpr decltype(auto) coerce(T1 && t1, long) noexcept(noexcept(*static_cast(t1))) { return *static_cast(t1); } - template(typename T, typename T1)( // - requires derived_from, T>) // + template(typename T, typename T1)( + /// \pre + requires derived_from, T>) static constexpr T1 && coerce(T1 && t1, int) noexcept { return static_cast(t1); } - template(typename, typename T1)( // - requires detail::is_reference_wrapper_v>) // + template(typename, typename T1)( + /// \pre + requires detail::is_reference_wrapper_v>) static constexpr decltype(auto) coerce(T1 && t1, int) noexcept { return static_cast(t1).get(); diff --git a/include/range/v3/functional/not_fn.hpp b/include/range/v3/functional/not_fn.hpp index f3888e9748..a7a5918d7c 100644 --- a/include/range/v3/functional/not_fn.hpp +++ b/include/range/v3/functional/not_fn.hpp @@ -42,29 +42,33 @@ namespace ranges noexcept(std::is_nothrow_default_constructible::value) // requires default_constructible) {} - template(typename T)( // - requires (!same_as, logical_negate>) AND // - constructible_from) // + template(typename T)( + /// \pre + requires (!same_as, logical_negate>) AND + constructible_from) constexpr explicit logical_negate(T && pred) : pred_(static_cast(pred)) {} - template(typename... Args)( // - requires predicate) // + template(typename... Args)( + /// \pre + requires predicate) constexpr bool operator()(Args &&... args) & { return !invoke(pred_, static_cast(args)...); } /// \overload - template(typename... Args)( // - requires predicate) // + template(typename... Args)( + /// \pre + requires predicate) constexpr bool operator()(Args &&... args) const & { return !invoke(pred_, static_cast(args)...); } /// \overload - template(typename... Args)( // - requires predicate) // + template(typename... Args)( + /// \pre + requires predicate) constexpr bool operator()(Args &&... args) && { return !invoke(static_cast(pred_), static_cast(args)...); @@ -73,9 +77,10 @@ namespace ranges struct not_fn_fn { - template(typename Pred)( // - requires move_constructible> AND // - constructible_from, Pred>) // + template(typename Pred)( + /// \pre + requires move_constructible> AND + constructible_from, Pred>) constexpr logical_negate> operator()(Pred && pred) const { return logical_negate>{(Pred &&) pred}; diff --git a/include/range/v3/functional/overload.hpp b/include/range/v3/functional/overload.hpp index a37cce572f..60616103ae 100644 --- a/include/range/v3/functional/overload.hpp +++ b/include/range/v3/functional/overload.hpp @@ -108,12 +108,14 @@ namespace ranges {} template(typename... Args)( + /// \pre requires invocable) constexpr _result_t operator()(Args &&... args) && { return invoke((First &&) first_, (Args &&) args...); } template(typename... Args)( + /// \pre requires (!invocable) AND invocable, Args...>) constexpr _result_t operator()(Args &&... args) && @@ -122,12 +124,14 @@ namespace ranges } template(typename... Args)( + /// \pre requires invocable) constexpr _result_t operator()(Args &&... args) & { return invoke(first_, (Args &&) args...); } template(typename... Args)( + /// \pre requires (!invocable) AND invocable &, Args...>) constexpr _result_t operator()(Args &&... args) & @@ -136,12 +140,14 @@ namespace ranges } template(typename... Args)( + /// \pre requires invocable) constexpr _result_t operator()(Args &&... args) const & { return invoke(first_, (Args &&) args...); } template(typename... Args)( + /// \pre requires (!invocable) AND invocable const &, Args...>) constexpr _result_t operator()(Args &&... args) const & diff --git a/include/range/v3/functional/pipeable.hpp b/include/range/v3/functional/pipeable.hpp index 7d25949d1c..729efb6f92 100644 --- a/include/range/v3/functional/pipeable.hpp +++ b/include/range/v3/functional/pipeable.hpp @@ -78,7 +78,8 @@ namespace ranges friend pipeable_access; // Evaluate the pipe with an argument - template(typename Arg, typename Pipe)( // + template(typename Arg, typename Pipe)( + /// \pre requires (!is_pipeable_v) AND is_pipeable_v AND invocable) // clang-format off friend constexpr auto operator|(Arg &&arg, Pipe pipe) // clang-format off @@ -87,7 +88,8 @@ namespace ranges } // Compose two pipes - template(typename Pipe0, typename Pipe1)( // + template(typename Pipe0, typename Pipe1)( + /// \pre requires is_pipeable_v AND is_pipeable_v) // clang-format off friend constexpr auto operator|(Pipe0 pipe0, Pipe1 pipe1) // clang-format on { @@ -96,7 +98,8 @@ namespace ranges template friend auto operator|=(Arg & arg, Pipe pipe) // - -> CPP_broken_friend_ret(Arg &)( // + -> CPP_broken_friend_ret(Arg &)( + /// \pre requires (is_pipeable_v) && (!is_pipeable_v)&&invocable) { diff --git a/include/range/v3/functional/reference_wrapper.hpp b/include/range/v3/functional/reference_wrapper.hpp index 01a9ad4aad..57f87e9619 100644 --- a/include/range/v3/functional/reference_wrapper.hpp +++ b/include/range/v3/functional/reference_wrapper.hpp @@ -83,9 +83,10 @@ namespace ranges using reference = meta::if_, T, T &>; constexpr reference_wrapper() = default; - template(typename U)( // - requires (!same_as, reference_wrapper>) AND // - constructible_from) // + template(typename U)( + /// \pre + requires (!same_as, reference_wrapper>) AND + constructible_from) constexpr reference_wrapper(U && u) noexcept( std::is_nothrow_constructible::value) : detail::reference_wrapper_{static_cast(u)} @@ -98,7 +99,8 @@ namespace ranges { return get(); } - template(typename...)( // + template(typename...)( + /// \pre requires (!std::is_rvalue_reference::value)) // operator std::reference_wrapper() const noexcept { @@ -115,7 +117,8 @@ namespace ranges struct ref_fn { - template(typename T)( // + template(typename T)( + /// \pre requires (!is_reference_wrapper_v)) // reference_wrapper operator()(T & t) const { diff --git a/include/range/v3/iterator/basic_iterator.hpp b/include/range/v3/iterator/basic_iterator.hpp index 5dd49bd347..6988937859 100644 --- a/include/range/v3/iterator/basic_iterator.hpp +++ b/include/range/v3/iterator/basic_iterator.hpp @@ -187,8 +187,9 @@ namespace ranges // public: basic_proxy_reference_() = default; basic_proxy_reference_(basic_proxy_reference_ const &) = default; - template(typename OtherCur)( // - requires convertible_to) // + template(typename OtherCur)( + /// \pre + requires convertible_to) constexpr basic_proxy_reference_( basic_proxy_reference const & that) noexcept : cur_(that.cur_) @@ -198,14 +199,16 @@ namespace ranges {} CPP_member constexpr auto operator=(basic_proxy_reference_ && that) - -> CPP_ret(basic_proxy_reference_ &)( // + -> CPP_ret(basic_proxy_reference_ &)( + /// \pre requires readable_cursor) { return *this = that; } CPP_member constexpr auto operator=(basic_proxy_reference_ const & that) - -> CPP_ret(basic_proxy_reference_ &)( // + -> CPP_ret(basic_proxy_reference_ &)( + /// \pre requires readable_cursor) { this->write_(that.read_()); @@ -213,62 +216,70 @@ namespace ranges } CPP_member constexpr auto operator=(basic_proxy_reference_ && that) const - -> CPP_ret(basic_proxy_reference_ const &)( // + -> CPP_ret(basic_proxy_reference_ const &)( + /// \pre requires readable_cursor) { return *this = that; } CPP_member constexpr auto operator=(basic_proxy_reference_ const & that) const - -> CPP_ret(basic_proxy_reference_ const &)( // + -> CPP_ret(basic_proxy_reference_ const &)( + /// \pre requires readable_cursor) { this->write_(that.read_()); return *this; } - template(typename OtherCur)( // - requires readable_cursor AND // - writable_cursor>) // + template(typename OtherCur)( + /// \pre + requires readable_cursor AND + writable_cursor>) constexpr basic_proxy_reference_ & // operator=(basic_proxy_reference && that) { return *this = that; } - template(typename OtherCur)( // - requires readable_cursor AND // - writable_cursor>) // + template(typename OtherCur)( + /// \pre + requires readable_cursor AND + writable_cursor>) constexpr basic_proxy_reference_ & // operator=(basic_proxy_reference const & that) { this->write_(that.read_()); return *this; } - template(typename OtherCur)( // - requires readable_cursor AND // - writable_cursor>) // + template(typename OtherCur)( + /// \pre + requires readable_cursor AND + writable_cursor>) constexpr basic_proxy_reference_ const & // operator=(basic_proxy_reference && that) const { return *this = that; } - template(typename OtherCur)( // - requires readable_cursor AND // - writable_cursor>) // + template(typename OtherCur)( + /// \pre + requires readable_cursor AND + writable_cursor>) constexpr basic_proxy_reference_ const & // operator=(basic_proxy_reference const & that) const { this->write_(that.read_()); return *this; } - template(typename T)( // - requires writable_cursor) // + template(typename T)( + /// \pre + requires writable_cursor) constexpr basic_proxy_reference_ & operator=(T && t) // { this->write_((T &&) t); return *this; } - template(typename T)( // - requires writable_cursor) // + template(typename T)( + /// \pre + requires writable_cursor) constexpr basic_proxy_reference_ const & operator=(T && t) const { this->write_((T &&) t); @@ -276,43 +287,49 @@ namespace ranges } }; - template(typename Cur, bool IsReadable)( // - requires readable_cursor AND equality_comparable>) // + template(typename Cur, bool IsReadable)( + /// \pre + requires readable_cursor AND equality_comparable>) constexpr bool operator==(basic_proxy_reference_ const & x, cursor_value_t const & y) { return x.read_() == y; } - template(typename Cur, bool IsReadable)( // - requires readable_cursor AND equality_comparable>) // + template(typename Cur, bool IsReadable)( + /// \pre + requires readable_cursor AND equality_comparable>) constexpr bool operator!=(basic_proxy_reference_ const & x, cursor_value_t const & y) { return !(x == y); } - template(typename Cur, bool IsReadable)( // - requires readable_cursor AND equality_comparable>) // + template(typename Cur, bool IsReadable)( + /// \pre + requires readable_cursor AND equality_comparable>) constexpr bool operator==(cursor_value_t const & x, basic_proxy_reference_ const & y) { return x == y.read_(); } - template(typename Cur, bool IsReadable)( // - requires readable_cursor AND equality_comparable>) // + template(typename Cur, bool IsReadable)( + /// \pre + requires readable_cursor AND equality_comparable>) constexpr bool operator!=(cursor_value_t const & x, basic_proxy_reference_ const & y) { return !(x == y); } - template(typename Cur, bool IsReadable)( // - requires readable_cursor AND equality_comparable>) // + template(typename Cur, bool IsReadable)( + /// \pre + requires readable_cursor AND equality_comparable>) constexpr bool operator==(basic_proxy_reference_ const & x, basic_proxy_reference_ const & y) { return x.read_() == y.read_(); } - template(typename Cur, bool IsReadable)( // - requires readable_cursor AND equality_comparable>) // + template(typename Cur, bool IsReadable)( + /// \pre + requires readable_cursor AND equality_comparable>) constexpr bool operator!=(basic_proxy_reference_ const & x, basic_proxy_reference_ const & y) { @@ -544,9 +561,10 @@ namespace ranges public: using typename assoc_types_::difference_type; constexpr basic_iterator() = default; - template(typename OtherCur)( // - requires (!same_as) AND convertible_to AND // - constructible_from) // + template(typename OtherCur)( + /// \pre + requires (!same_as) AND convertible_to AND + constructible_from) constexpr basic_iterator(basic_iterator that) : base_t{std::move(that.pos())} {} @@ -561,8 +579,9 @@ namespace ranges : base_t(cur) {} - template(typename OtherCur)( // - requires (!same_as) AND convertible_to) // + template(typename OtherCur)( + /// \pre + requires (!same_as) AND convertible_to) constexpr basic_iterator & operator=(basic_iterator that) { pos() = std::move(that.pos()); @@ -572,7 +591,8 @@ namespace ranges CPP_member constexpr auto operator*() const noexcept(noexcept(range_access::read(std::declval()))) - -> CPP_ret(const_reference_t)( // + -> CPP_ret(const_reference_t)( + /// \pre requires detail::readable_cursor && (!detail::is_writable_cursor_v)) { @@ -581,7 +601,8 @@ namespace ranges CPP_member constexpr auto operator*() // noexcept(noexcept(iter_reference_t{std::declval()})) // - -> CPP_ret(iter_reference_t)( // + -> CPP_ret(iter_reference_t)( + /// \pre requires detail::has_cursor_next && detail::is_writable_cursor_v) { @@ -590,7 +611,8 @@ namespace ranges CPP_member constexpr auto operator*() const noexcept(noexcept(const_reference_t{std::declval()})) - -> CPP_ret(const_reference_t)( // + -> CPP_ret(const_reference_t)( + /// \pre requires detail::has_cursor_next && detail::is_writable_cursor_v) { @@ -598,14 +620,16 @@ namespace ranges } CPP_member constexpr auto operator*() noexcept // - -> CPP_ret(basic_iterator &)( // + -> CPP_ret(basic_iterator &)( + /// \pre requires (!detail::has_cursor_next)) { return *this; } // Use cursor's arrow() member, if any. - template(typename C = Cur)( // + template(typename C = Cur)( + /// \pre requires detail::has_cursor_arrow) constexpr detail::cursor_arrow_t operator-> () const noexcept(noexcept(range_access::arrow(std::declval()))) @@ -614,7 +638,8 @@ namespace ranges } // Otherwise, if iter_reference_t is an lvalue reference to cv-qualified // iter_value_t, return the address of **this. - template(typename C = Cur)( // + template(typename C = Cur)( + /// \pre requires (!detail::has_cursor_arrow) AND detail::readable_cursor AND std::is_lvalue_reference::value AND same_as::value_type, @@ -627,7 +652,8 @@ namespace ranges CPP_member constexpr auto operator++() // - -> CPP_ret(basic_iterator &)( // + -> CPP_ret(basic_iterator &)( + /// \pre requires detail::has_cursor_next) { range_access::next(pos()); @@ -635,7 +661,8 @@ namespace ranges } CPP_member constexpr auto operator++() noexcept // - -> CPP_ret(basic_iterator &)( // + -> CPP_ret(basic_iterator &)( + /// \pre requires (!detail::has_cursor_next)) { return *this; @@ -650,9 +677,10 @@ namespace ranges } // Attempt to satisfy the C++17 iterator requirements by returning a // proxy from postfix increment: - template(typename A = assoc_types_, typename V = typename A::value_type)( // - requires constructible_from AND // - move_constructible) // + template(typename A = assoc_types_, typename V = typename A::value_type)( + /// \pre + requires constructible_from AND + move_constructible) constexpr auto post_increment_(std::true_type, int) // -> detail::postfix_increment_proxy { @@ -676,7 +704,8 @@ namespace ranges CPP_member constexpr auto operator--() - -> CPP_ret(basic_iterator &)( // + -> CPP_ret(basic_iterator &)( + /// \pre requires detail::bidirectional_cursor) { range_access::prev(pos()); @@ -684,7 +713,8 @@ namespace ranges } CPP_member constexpr auto operator--(int) // - -> CPP_ret(basic_iterator)( // + -> CPP_ret(basic_iterator)( + /// \pre requires detail::bidirectional_cursor) { basic_iterator tmp(*this); @@ -693,7 +723,8 @@ namespace ranges } CPP_member constexpr auto operator+=(difference_type n) // - -> CPP_ret(basic_iterator &)( // + -> CPP_ret(basic_iterator &)( + /// \pre requires detail::random_access_cursor) { range_access::advance(pos(), n); @@ -701,7 +732,8 @@ namespace ranges } CPP_member constexpr auto operator-=(difference_type n) // - -> CPP_ret(basic_iterator &)( // + -> CPP_ret(basic_iterator &)( + /// \pre requires detail::random_access_cursor) { range_access::advance(pos(), (difference_type)-n); @@ -709,7 +741,8 @@ namespace ranges } CPP_member constexpr auto operator[](difference_type n) const // - -> CPP_ret(const_reference_t)( // + -> CPP_ret(const_reference_t)( + /// \pre requires detail::random_access_cursor) { return *(*this + n); @@ -722,7 +755,8 @@ namespace ranges friend constexpr auto iter_move(basic_iterator const & it) noexcept( noexcept(range_access::move(std::declval()))) -> CPP_broken_friend_ret( - decltype(range_access::move(std::declval())))( // + decltype(range_access::move(std::declval())))( + /// \pre requires same_as && detail::input_cursor) { return range_access::move(it.pos()); @@ -730,66 +764,75 @@ namespace ranges #endif }; - template(typename Cur, typename Cur2)( // - requires detail::sentinel_for_cursor) // + template(typename Cur, typename Cur2)( + /// \pre + requires detail::sentinel_for_cursor) constexpr bool operator==(basic_iterator const & left, basic_iterator const & right) { return range_access::equal(range_access::pos(left), range_access::pos(right)); } - template(typename Cur, typename Cur2)( // - requires detail::sentinel_for_cursor) // + template(typename Cur, typename Cur2)( + /// \pre + requires detail::sentinel_for_cursor) constexpr bool operator!=(basic_iterator const & left, basic_iterator const & right) { return !(left == right); } - template(typename Cur, typename S)( // - requires detail::sentinel_for_cursor) // + template(typename Cur, typename S)( + /// \pre + requires detail::sentinel_for_cursor) constexpr bool operator==(basic_iterator const & left, S const & right) { return range_access::equal(range_access::pos(left), right); } - template(typename Cur, typename S)( // - requires detail::sentinel_for_cursor) // + template(typename Cur, typename S)( + /// \pre + requires detail::sentinel_for_cursor) constexpr bool operator!=(basic_iterator const & left, S const & right) { return !(left == right); } - template(typename S, typename Cur)( // - requires detail::sentinel_for_cursor) // + template(typename S, typename Cur)( + /// \pre + requires detail::sentinel_for_cursor) constexpr bool operator==(S const & left, basic_iterator const & right) { return right == left; } - template(typename S, typename Cur)( // - requires detail::sentinel_for_cursor) // + template(typename S, typename Cur)( + /// \pre + requires detail::sentinel_for_cursor) constexpr bool operator!=(S const & left, basic_iterator const & right) { return right != left; } - template(typename Cur)( // - requires detail::random_access_cursor) // + template(typename Cur)( + /// \pre + requires detail::random_access_cursor) constexpr basic_iterator // operator+(basic_iterator left, typename basic_iterator::difference_type n) { left += n; return left; } - template(typename Cur)( // - requires detail::random_access_cursor) // + template(typename Cur)( + /// \pre + requires detail::random_access_cursor) constexpr basic_iterator // operator+(typename basic_iterator::difference_type n, basic_iterator right) { right += n; return right; } - template(typename Cur)( // + template(typename Cur)( + /// \pre requires detail::random_access_cursor) constexpr basic_iterator // operator-(basic_iterator left, typename basic_iterator::difference_type n) @@ -797,7 +840,8 @@ namespace ranges left -= n; return left; } - template(typename Cur2, typename Cur)( // + template(typename Cur2, typename Cur)( + /// \pre requires detail::sized_sentinel_for_cursor) constexpr typename basic_iterator::difference_type // operator-(basic_iterator const & left, basic_iterator const & right) @@ -805,44 +849,50 @@ namespace ranges return range_access::distance_to(range_access::pos(right), range_access::pos(left)); } - template(typename S, typename Cur)( // - requires detail::sized_sentinel_for_cursor) // + template(typename S, typename Cur)( + /// \pre + requires detail::sized_sentinel_for_cursor) constexpr typename basic_iterator::difference_type // operator-(S const & left, basic_iterator const & right) { return range_access::distance_to(range_access::pos(right), left); } - template(typename Cur, typename S)( // - requires detail::sized_sentinel_for_cursor) // + template(typename Cur, typename S)( + /// \pre + requires detail::sized_sentinel_for_cursor) constexpr typename basic_iterator::difference_type // operator-(basic_iterator const & left, S const & right) { return -(right - left); } // Asymmetric comparisons - template(typename Left, typename Right)( // - requires detail::sized_sentinel_for_cursor) // + template(typename Left, typename Right)( + /// \pre + requires detail::sized_sentinel_for_cursor) constexpr bool operator<(basic_iterator const & left, basic_iterator const & right) { return 0 < (right - left); } - template(typename Left, typename Right)( // - requires detail::sized_sentinel_for_cursor) // + template(typename Left, typename Right)( + /// \pre + requires detail::sized_sentinel_for_cursor) constexpr bool operator<=(basic_iterator const & left, basic_iterator const & right) { return 0 <= (right - left); } - template(typename Left, typename Right)( // - requires detail::sized_sentinel_for_cursor) // + template(typename Left, typename Right)( + /// \pre + requires detail::sized_sentinel_for_cursor) constexpr bool operator>(basic_iterator const & left, basic_iterator const & right) { return (right - left) < 0; } - template(typename Left, typename Right)( // - requires detail::sized_sentinel_for_cursor) // + template(typename Left, typename Right)( + /// \pre + requires detail::sized_sentinel_for_cursor) constexpr bool operator>=(basic_iterator const & left, basic_iterator const & right) { @@ -858,7 +908,8 @@ namespace ranges constexpr auto iter_move(basic_iterator const & it) noexcept( noexcept(range_access::move(std::declval()))) -> CPP_broken_friend_ret( - decltype(range_access::move(std::declval())))( // + decltype(range_access::move(std::declval())))( + /// \pre requires detail::input_cursor) { return range_access::move(range_access::pos(it)); diff --git a/include/range/v3/iterator/common_iterator.hpp b/include/range/v3/iterator/common_iterator.hpp index 3e9cb0e9bc..e89a44c61b 100644 --- a/include/range/v3/iterator/common_iterator.hpp +++ b/include/range/v3/iterator/common_iterator.hpp @@ -109,15 +109,17 @@ namespace ranges { return j; } - template(typename J, typename R = iter_reference_t)( // + template(typename J, typename R = iter_reference_t)( + /// \pre requires std::is_reference::value) // static meta::_t> operator_arrow_(J const & j, long) noexcept { auto && r = *j; return std::addressof(r); } - template(typename J, typename V = iter_value_t)( // - requires constructible_from>) // + template(typename J, typename V = iter_value_t)( + /// \pre + requires constructible_from>) static arrow_proxy_ operator_arrow_(J const & j, ...) noexcept(noexcept(V(V(*j)))) { return arrow_proxy_(*j); @@ -133,15 +135,17 @@ namespace ranges common_iterator(S s) : data_(emplaced_index<1>, std::move(s)) {} - template(typename I2, typename S2)( // - requires convertible_to AND convertible_to) // + template(typename I2, typename S2)( + /// \pre + requires convertible_to AND convertible_to) common_iterator(common_iterator const & that) : data_(detail::variant_core_access::make_empty()) { detail::cidata(that).visit_i(emplace_fn{&data_}); } - template(typename I2, typename S2)( // - requires convertible_to AND convertible_to) // + template(typename I2, typename S2)( + /// \pre + requires convertible_to AND convertible_to) common_iterator & operator=(common_iterator const & that) { detail::cidata(that).visit_i(emplace_fn{&data_}); @@ -155,12 +159,14 @@ namespace ranges CPP_member auto operator*() const // noexcept(noexcept(iter_reference_t(*std::declval()))) - -> CPP_ret(iter_reference_t)( // + -> CPP_ret(iter_reference_t)( + /// \pre requires indirectly_readable) { return *ranges::get<0>(data_); } - template(typename J = I)( // + template(typename J = I)( + /// \pre requires indirectly_readable) auto operator->() const // noexcept( @@ -175,7 +181,8 @@ namespace ranges return *this; } #ifdef RANGES_WORKAROUND_MSVC_677925 - template(typename I2 = I)( // + template(typename I2 = I)( + /// \pre requires (!forward_iterator)) // auto operator++(int) // -> decltype(std::declval()++) @@ -185,7 +192,8 @@ namespace ranges #else // ^^^ workaround ^^^ / vvv no workaround vvv CPP_member auto operator++(int) // - -> CPP_ret(decltype(std::declval()++))( // + -> CPP_ret(decltype(std::declval()++))( + /// \pre requires (!forward_iterator)) { return ranges::get<0>(data_)++; @@ -193,7 +201,8 @@ namespace ranges #endif // RANGES_WORKAROUND_MSVC_677925 CPP_member auto operator++(int) // - -> CPP_ret(common_iterator)( // + -> CPP_ret(common_iterator)( + /// \pre requires forward_iterator) { return common_iterator(ranges::get<0>(data_)++); @@ -203,7 +212,8 @@ namespace ranges template friend constexpr auto iter_move(common_iterator const & i) // noexcept(detail::has_nothrow_iter_move_v) - -> CPP_broken_friend_ret(iter_rvalue_reference_t)( // + -> CPP_broken_friend_ret(iter_rvalue_reference_t)( + /// \pre requires input_iterator) { return ranges::iter_move(ranges::get<0>(detail::cidata(i))); @@ -213,7 +223,8 @@ namespace ranges common_iterator const & x, common_iterator const & y) noexcept(is_nothrow_indirectly_swappable::value) - -> CPP_broken_friend_ret(void)( // + -> CPP_broken_friend_ret(void)( + /// \pre requires indirectly_swappable) { return ranges::iter_swap(ranges::get<0>(detail::cidata(x)), @@ -229,7 +240,8 @@ namespace ranges template constexpr auto iter_move(common_iterator const & i) noexcept( detail::has_nothrow_iter_move_v) - -> CPP_broken_friend_ret(iter_rvalue_reference_t)( // + -> CPP_broken_friend_ret(iter_rvalue_reference_t)( + /// \pre requires input_iterator) { return ranges::iter_move(ranges::get<0>(detail::cidata(i))); @@ -238,7 +250,8 @@ namespace ranges auto iter_swap(common_iterator const & x, common_iterator const & y) // noexcept(is_nothrow_indirectly_swappable::value) - -> CPP_broken_friend_ret(void)( // + -> CPP_broken_friend_ret(void)( + /// \pre requires indirectly_swappable) { return ranges::iter_swap(ranges::get<0>(detail::cidata(x)), @@ -248,8 +261,9 @@ namespace ranges #endif /// \endcond - template(typename I1, typename I2, typename S1, typename S2)( // - requires sentinel_for AND sentinel_for AND // + template(typename I1, typename I2, typename S1, typename S2)( + /// \pre + requires sentinel_for AND sentinel_for AND (!equality_comparable_with)) // bool operator==(common_iterator const & x, common_iterator const & y) { @@ -261,9 +275,10 @@ namespace ranges ranges::get<1>(detail::cidata(y))); } - template(typename I1, typename I2, typename S1, typename S2)( // - requires sentinel_for AND sentinel_for AND // - equality_comparable_with) // + template(typename I1, typename I2, typename S1, typename S2)( + /// \pre + requires sentinel_for AND sentinel_for AND + equality_comparable_with) bool operator==(common_iterator const & x, common_iterator const & y) { return detail::cidata(x).index() == 1u @@ -277,16 +292,18 @@ namespace ranges ranges::get<0>(detail::cidata(y))); } - template(typename I1, typename I2, typename S1, typename S2)( // - requires sentinel_for AND sentinel_for) // + template(typename I1, typename I2, typename S1, typename S2)( + /// \pre + requires sentinel_for AND sentinel_for) bool operator!=(common_iterator const & x, common_iterator const & y) { return !(x == y); } - template(typename I1, typename I2, typename S1, typename S2)( // - requires sized_sentinel_for AND sized_sentinel_for AND // - sized_sentinel_for) // + template(typename I1, typename I2, typename S1, typename S2)( + /// \pre + requires sized_sentinel_for AND sized_sentinel_for AND + sized_sentinel_for) iter_difference_t operator-(common_iterator const & x, common_iterator const & y) { @@ -318,7 +335,8 @@ namespace ranges template auto demote_common_iter_cat(long) -> with_iterator_category; - template(typename I)( // + template(typename I)( + /// \pre requires derived_from::iterator_category, std::forward_iterator_tag>) auto demote_common_iter_cat(int) @@ -410,21 +428,24 @@ namespace ranges } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_iterator) { --it_; } CPP_member auto advance(std::ptrdiff_t n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires random_access_iterator) { it_ += static_cast>(n); } CPP_member auto distance_to(cpp17_iterator_cursor const & that) // - -> CPP_ret(std::ptrdiff_t)( // + -> CPP_ret(std::ptrdiff_t)( + /// \pre requires random_access_iterator) { auto d = that.it_ - it_; diff --git a/include/range/v3/iterator/concepts.hpp b/include/range/v3/iterator/concepts.hpp index 87431103e2..de9363edeb 100644 --- a/include/range/v3/iterator/concepts.hpp +++ b/include/range/v3/iterator/concepts.hpp @@ -49,55 +49,66 @@ namespace ranges std::iterator_traits, I>; #if defined(_GLIBCXX_DEBUG) - template(typename I, typename T, typename Seq)( // - requires same_as>) // + template(typename I, typename T, typename Seq)( + /// \pre + requires same_as>) auto iter_concept_(__gnu_debug::_Safe_iterator, priority_tag<3>) -> ranges::contiguous_iterator_tag #endif #if defined(__GLIBCXX__) - template(typename I, typename T, typename Seq)( // - requires same_as>) // + template(typename I, typename T, typename Seq)( + /// \pre + requires same_as>) auto iter_concept_(__gnu_cxx::__normal_iterator, priority_tag<3>) -> ranges::contiguous_iterator_tag; #endif #if defined(_LIBCPP_VERSION) - template(typename I, typename T)( // - requires same_as>) // + template(typename I, typename T)( + /// \pre + requires same_as>) auto iter_concept_(std::__wrap_iter, priority_tag<3>) -> ranges::contiguous_iterator_tag; #endif #if defined(_MSVC_STL_VERSION) || defined(_IS_WRS) - template(typename I)( // - requires same_as) // + template(typename I)( + /// \pre + requires same_as) auto iter_concept_(I, priority_tag<3>) -> ranges::contiguous_iterator_tag; - template(typename I)( // - requires same_as) // + template(typename I)( + /// \pre + requires same_as) auto iter_concept_(I, priority_tag<3>) -> ranges::contiguous_iterator_tag; - template(typename I)( // - requires same_as) // + template(typename I)( + /// \pre + requires same_as) auto iter_concept_(I, priority_tag<3>) -> ranges::contiguous_iterator_tag; - template(typename I)( // - requires same_as) // + template(typename I)( + /// \pre + requires same_as) auto iter_concept_(I, priority_tag<3>) -> ranges::contiguous_iterator_tag; - template(typename I)( // - requires same_as) // + template(typename I)( + /// \pre + requires same_as) auto iter_concept_(I, priority_tag<3>) -> ranges::contiguous_iterator_tag; - template(typename I)( // - requires same_as) // + template(typename I)( + /// \pre + requires same_as) auto iter_concept_(I, priority_tag<3>) -> ranges::contiguous_iterator_tag; - template(typename I)( // - requires same_as) // + template(typename I)( + /// \pre + requires same_as) auto iter_concept_(I, priority_tag<3>) -> ranges::contiguous_iterator_tag; #endif - template(typename I, typename T)( // - requires same_as) // + template(typename I, typename T)( + /// \pre + requires same_as) auto iter_concept_(T *, priority_tag<3>) -> ranges::contiguous_iterator_tag; template @@ -827,12 +838,14 @@ namespace ranges // necessary operation. namespace __gnu_debug { - template(typename I1, typename I2, typename Seq)( // + template(typename I1, typename I2, typename Seq)( + /// \pre requires (!::ranges::sized_sentinel_for)) // void operator-(_Safe_iterator const &, _Safe_iterator const &) = delete; - template(typename I1, typename Seq)( // + template(typename I1, typename Seq)( + /// \pre requires (!::ranges::sized_sentinel_for)) // void operator-(_Safe_iterator const &, _Safe_iterator const &) = delete; diff --git a/include/range/v3/iterator/counted_iterator.hpp b/include/range/v3/iterator/counted_iterator.hpp index ba495df93c..eba9d09ef6 100644 --- a/include/range/v3/iterator/counted_iterator.hpp +++ b/include/range/v3/iterator/counted_iterator.hpp @@ -107,15 +107,17 @@ namespace ranges RANGES_EXPECT(n >= 0); } - template(typename I2)( // - requires convertible_to) // + template(typename I2)( + /// \pre + requires convertible_to) constexpr counted_iterator(counted_iterator const & i) : current_(_counted_iterator_::access::current(i)) , cnt_(i.count()) {} - template(typename I2)( // - requires convertible_to) // + template(typename I2)( + /// \pre + requires convertible_to) constexpr counted_iterator & operator=(counted_iterator const & i) { current_ = _counted_iterator_::access::current(i); @@ -138,8 +140,9 @@ namespace ranges RANGES_EXPECT(cnt_ > 0); return *current_; } - template(typename I2 = I)( // - requires indirectly_readable) // + template(typename I2 = I)( + /// \pre + requires indirectly_readable) constexpr iter_reference_t operator*() const // noexcept(noexcept(iter_reference_t(*current_))) { @@ -156,13 +159,15 @@ namespace ranges } #ifdef RANGES_WORKAROUND_MSVC_677925 - template(typename I2 = I)( // + template(typename I2 = I)( + /// \pre requires (!forward_iterator)) // constexpr auto operator++(int) -> decltype(std::declval()++) #else // ^^^ workaround ^^^ / vvv no workaround vvv CPP_member constexpr auto operator++(int) // - -> CPP_ret(decltype(std::declval()++))( // + -> CPP_ret(decltype(std::declval()++))( + /// \pre requires (!forward_iterator)) #endif // RANGES_WORKAROUND_MSVC_677925 { @@ -172,7 +177,8 @@ namespace ranges CPP_member constexpr auto operator++(int) // - -> CPP_ret(counted_iterator)( // + -> CPP_ret(counted_iterator)( + /// \pre requires forward_iterator) { auto tmp(*this); @@ -182,7 +188,8 @@ namespace ranges CPP_member constexpr auto operator--() // - -> CPP_ret(counted_iterator &)( // + -> CPP_ret(counted_iterator &)( + /// \pre requires bidirectional_iterator) { --current_; @@ -192,7 +199,8 @@ namespace ranges CPP_member constexpr auto operator--(int) // - -> CPP_ret(counted_iterator)( // + -> CPP_ret(counted_iterator)( + /// \pre requires bidirectional_iterator) { auto tmp(*this); @@ -202,7 +210,8 @@ namespace ranges CPP_member constexpr auto operator+=(difference_type n) // - -> CPP_ret(counted_iterator &)( // + -> CPP_ret(counted_iterator &)( + /// \pre requires random_access_iterator) { RANGES_EXPECT(cnt_ >= n); @@ -213,7 +222,8 @@ namespace ranges CPP_member constexpr auto operator+(difference_type n) const // - -> CPP_ret(counted_iterator)( // + -> CPP_ret(counted_iterator)( + /// \pre requires random_access_iterator) { auto tmp(*this); @@ -223,7 +233,8 @@ namespace ranges CPP_member constexpr auto operator-=(difference_type n) // - -> CPP_ret(counted_iterator &)( // + -> CPP_ret(counted_iterator &)( + /// \pre requires random_access_iterator) { RANGES_EXPECT(cnt_ >= -n); @@ -234,7 +245,8 @@ namespace ranges CPP_member constexpr auto operator-(difference_type n) const // - -> CPP_ret(counted_iterator)( // + -> CPP_ret(counted_iterator)( + /// \pre requires random_access_iterator) { auto tmp(*this); @@ -244,7 +256,8 @@ namespace ranges CPP_member constexpr auto operator[](difference_type n) const // - -> CPP_ret(iter_reference_t)( // + -> CPP_ret(iter_reference_t)( + /// \pre requires random_access_iterator) { RANGES_EXPECT(cnt_ >= n); @@ -254,8 +267,9 @@ namespace ranges #if !RANGES_BROKEN_CPO_LOOKUP CPP_broken_friend_member friend constexpr auto iter_move(counted_iterator const & i) // - noexcept(detail::has_nothrow_iter_move_v) // - -> CPP_broken_friend_ret(iter_rvalue_reference_t)( // + noexcept(detail::has_nothrow_iter_move_v) + -> CPP_broken_friend_ret(iter_rvalue_reference_t)( + /// \pre requires input_iterator) { return ranges::iter_move(i.current_); @@ -264,7 +278,8 @@ namespace ranges friend constexpr auto iter_swap(counted_iterator const & x, counted_iterator const & y) // noexcept(is_nothrow_indirectly_swappable::value) - -> CPP_broken_friend_ret(void)( // + -> CPP_broken_friend_ret(void)( + /// \pre requires indirectly_swappable) { return ranges::iter_swap(x.current_, _counted_iterator_::access::current(y)); @@ -279,7 +294,8 @@ namespace ranges template constexpr auto iter_move(counted_iterator const & i) noexcept( detail::has_nothrow_iter_move_v) - -> CPP_broken_friend_ret(iter_rvalue_reference_t)( // + -> CPP_broken_friend_ret(iter_rvalue_reference_t)( + /// \pre requires input_iterator) { return ranges::iter_move(_counted_iterator_::access::current(i)); @@ -289,7 +305,8 @@ namespace ranges counted_iterator const & x, counted_iterator const & y) noexcept(is_nothrow_indirectly_swappable::value) - -> CPP_broken_friend_ret(void)( // + -> CPP_broken_friend_ret(void)( + /// \pre requires indirectly_swappable) { return ranges::iter_swap(_counted_iterator_::access::current(x), @@ -299,8 +316,9 @@ namespace ranges #endif /// endcond - template(typename I1, typename I2)( // - requires common_with) // + template(typename I1, typename I2)( + /// \pre + requires common_with) constexpr bool operator==(counted_iterator const & x, counted_iterator const & y) { @@ -319,8 +337,9 @@ namespace ranges return x.count() == 0; } - template(typename I1, typename I2)( // - requires common_with) // + template(typename I1, typename I2)( + /// \pre + requires common_with) constexpr bool operator!=(counted_iterator const & x, counted_iterator const & y) { @@ -339,40 +358,45 @@ namespace ranges return !(x == y); } - template(typename I1, typename I2)( // - requires common_with) // + template(typename I1, typename I2)( + /// \pre + requires common_with) constexpr bool operator<(counted_iterator const & x, counted_iterator const & y) { return y.count() < x.count(); } - template(typename I1, typename I2)( // - requires common_with) // + template(typename I1, typename I2)( + /// \pre + requires common_with) constexpr bool operator<=(counted_iterator const & x, counted_iterator const & y) { return !(y < x); } - template(typename I1, typename I2)( // - requires common_with) // + template(typename I1, typename I2)( + /// \pre + requires common_with) constexpr bool operator>(counted_iterator const & x, counted_iterator const & y) { return y < x; } - template(typename I1, typename I2)( // - requires common_with) // + template(typename I1, typename I2)( + /// \pre + requires common_with) constexpr bool operator>=(counted_iterator const & x, counted_iterator const & y) { return !(x < y); } - template(typename I1, typename I2)( // - requires common_with) // + template(typename I1, typename I2)( + /// \pre + requires common_with) constexpr iter_difference_t operator-(counted_iterator const & x, counted_iterator const & y) { @@ -393,16 +417,18 @@ namespace ranges return y.count(); } - template(typename I)( // - requires random_access_iterator) // + template(typename I)( + /// \pre + requires random_access_iterator) constexpr counted_iterator operator+(iter_difference_t n, counted_iterator const & x) { return x + n; } - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) constexpr counted_iterator make_counted_iterator(I i, iter_difference_t n) { return {std::move(i), n}; @@ -416,8 +442,9 @@ namespace ranges meta::nil_> {}; - CPP_template_def(typename I)( // - requires input_or_output_iterator) // + CPP_template_def(typename I)( + /// \pre + requires input_or_output_iterator) constexpr void advance_fn::operator()(counted_iterator & i, iter_difference_t n) const { diff --git a/include/range/v3/iterator/diffmax_t.hpp b/include/range/v3/iterator/diffmax_t.hpp index e314eff3a5..334f4226c6 100644 --- a/include/range/v3/iterator/diffmax_t.hpp +++ b/include/range/v3/iterator/diffmax_t.hpp @@ -61,8 +61,9 @@ namespace ranges public: diffmax_t() = default; - template(typename T)( // - requires integral) // + template(typename T)( + /// \pre + requires integral) constexpr diffmax_t(T val) noexcept : neg_(0 > val) , val_(0 > val ? static_cast(-val) @@ -219,63 +220,72 @@ namespace ranges template friend constexpr auto operator+=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} + b)); } template friend constexpr auto operator-=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} - b)); } template friend constexpr auto operator*=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} * b)); } template friend constexpr auto operator/=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} / b)); } template friend constexpr auto operator%=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} % b)); } template friend constexpr auto operator&=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} & b)); } template friend constexpr auto operator|=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} | b)); } template friend constexpr auto operator^=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { return (a = static_cast(diffmax_t{a} ^ b)); } template friend constexpr auto operator<<=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { a = static_cast(diffmax_t{a} << b); @@ -283,7 +293,8 @@ namespace ranges } template friend constexpr auto operator>>=(T & a, diffmax_t b) noexcept - -> CPP_broken_friend_ret(T &)( // + -> CPP_broken_friend_ret(T &)( + /// \pre requires integral) { a = static_cast(diffmax_t{a} >> b); @@ -313,8 +324,9 @@ namespace ranges return tmp; } - template(typename T)( // - requires integral) // + template(typename T)( + /// \pre + requires integral) constexpr explicit operator T() const noexcept { @@ -331,7 +343,8 @@ namespace ranges template friend auto operator<<(Ostream & sout, diffmax_t a) - -> CPP_broken_friend_ret(std::ostream &)( // + -> CPP_broken_friend_ret(std::ostream &)( + /// \pre requires derived_from< Ostream, std::basic_ostream>) diff --git a/include/range/v3/iterator/move_iterators.hpp b/include/range/v3/iterator/move_iterators.hpp index 64ce31c323..0fedbf91f4 100644 --- a/include/range/v3/iterator/move_iterators.hpp +++ b/include/range/v3/iterator/move_iterators.hpp @@ -46,13 +46,15 @@ namespace ranges explicit move_iterator(I i) : current_(i) {} - template(typename O)( // - requires convertible_to) // + template(typename O)( + /// \pre + requires convertible_to) move_iterator(move_iterator const & i) : current_(i.base()) {} - template(typename O)( // - requires convertible_to) // + template(typename O)( + /// \pre + requires convertible_to) move_iterator & operator=(move_iterator const & i) { current_ = i.base(); @@ -76,21 +78,24 @@ namespace ranges } CPP_member auto operator++(int) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires (!forward_iterator)) { ++current_; } CPP_member auto operator++(int) // - -> CPP_ret(move_iterator)( // + -> CPP_ret(move_iterator)( + /// \pre requires forward_iterator) { return move_iterator(current_++); } CPP_member auto operator--() // - -> CPP_ret(move_iterator &)( // + -> CPP_ret(move_iterator &)( + /// \pre requires forward_iterator) { --current_; @@ -98,21 +103,24 @@ namespace ranges } CPP_member auto operator--(int) // - -> CPP_ret(move_iterator)( // + -> CPP_ret(move_iterator)( + /// \pre requires bidirectional_iterator) { return move_iterator(current_--); } CPP_member auto operator+(difference_type n) const // - -> CPP_ret(move_iterator)( // + -> CPP_ret(move_iterator)( + /// \pre requires random_access_iterator) { return move_iterator(current_ + n); } CPP_member auto operator+=(difference_type n) - -> CPP_ret(move_iterator &)( // + -> CPP_ret(move_iterator &)( + /// \pre requires random_access_iterator) { current_ += n; @@ -120,14 +128,16 @@ namespace ranges } CPP_member auto operator-(difference_type n) const // - -> CPP_ret(move_iterator)( // + -> CPP_ret(move_iterator)( + /// \pre requires random_access_iterator) { return move_iterator(current_ - n); } CPP_member auto operator-=(difference_type n) // - -> CPP_ret(move_iterator &)( // + -> CPP_ret(move_iterator &)( + /// \pre requires random_access_iterator) { current_ -= n; @@ -135,7 +145,8 @@ namespace ranges } CPP_member auto operator[](difference_type n) const // - -> CPP_ret(reference)( // + -> CPP_ret(reference)( + /// \pre requires random_access_iterator) { return iter_move(current_ + n); @@ -143,42 +154,48 @@ namespace ranges template friend auto operator==(move_iterator const & x, move_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires equality_comparable_with) { return x.base() == y.base(); } template friend auto operator!=(move_iterator const & x, move_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires equality_comparable_with) { return !(x == y); } template friend auto operator<(move_iterator const & x, move_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires totally_ordered_with) { return x.base() < y.base(); } template friend auto operator<=(move_iterator const & x, move_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires totally_ordered_with) { return !(y < x); } template friend auto operator>(move_iterator const & x, move_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires totally_ordered_with) { return y < x; } template friend auto operator>=(move_iterator const & x, move_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires totally_ordered_with) { return !(x < y); @@ -186,7 +203,8 @@ namespace ranges template friend auto operator-(move_iterator const & x, move_iterator const & y) - -> CPP_broken_friend_ret(iter_difference_t)( // + -> CPP_broken_friend_ret(iter_difference_t)( + /// \pre requires sized_sentinel_for) { return x.base() - y.base(); @@ -194,7 +212,8 @@ namespace ranges CPP_broken_friend_member friend auto operator+(iter_difference_t n, move_iterator const & x) - -> CPP_broken_friend_ret(move_iterator)( // + -> CPP_broken_friend_ret(move_iterator)( + /// \pre requires random_access_iterator) { return x + n; @@ -203,8 +222,9 @@ namespace ranges struct make_move_iterator_fn { - template(typename I)( // - requires input_iterator) // + template(typename I)( + /// \pre + requires input_iterator) constexpr move_iterator operator()(I it) const { return move_iterator{detail::move(it)}; @@ -226,13 +246,15 @@ namespace ranges constexpr explicit move_sentinel(S s) : sent_(detail::move(s)) {} - template(typename OS)( // - requires convertible_to) // + template(typename OS)( + /// \pre + requires convertible_to) constexpr explicit move_sentinel(move_sentinel const & that) : sent_(that.base()) {} - template(typename OS)( // - requires convertible_to) // + template(typename OS)( + /// \pre + requires convertible_to) move_sentinel & operator=(move_sentinel const & that) { sent_ = that.base(); @@ -245,28 +267,32 @@ namespace ranges template friend auto operator==(move_iterator const & i, move_sentinel const & s) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires sentinel_for) { return i.base() == s.base(); } template friend auto operator==(move_sentinel const & s, move_iterator const & i) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires sentinel_for) { return s.base() == i.base(); } template friend auto operator!=(move_iterator const & i, move_sentinel const & s) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires sentinel_for) { return i.base() != s.base(); } template friend auto operator!=(move_sentinel const & s, move_iterator const & i) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires sentinel_for) { return s.base() != i.base(); @@ -275,14 +301,16 @@ namespace ranges struct make_move_sentinel_fn { - template(typename I)( // - requires input_iterator) // + template(typename I)( + /// \pre + requires input_iterator) constexpr move_iterator operator()(I i) const { return move_iterator{detail::move(i)}; } - template(typename S)( // + template(typename S)( + /// \pre requires semiregular AND (!input_iterator)) // constexpr move_sentinel operator()(S s) const { @@ -346,55 +374,63 @@ namespace ranges { ++it_; } - template(typename T)( // - requires indirectly_writable>) // + template(typename T)( + /// \pre + requires indirectly_writable>) void write(T && t) noexcept(noexcept(*it_ = std::move(t))) { *it_ = std::move(t); } - template(typename T)( // - requires indirectly_writable>) // + template(typename T)( + /// \pre + requires indirectly_writable>) void write(T && t) const noexcept(noexcept(*it_ = std::move(t))) { *it_ = std::move(t); } CPP_member auto read() const noexcept(noexcept(*std::declval())) - -> CPP_ret(iter_reference_t)( // + -> CPP_ret(iter_reference_t)( + /// \pre requires indirectly_readable) { return *it_; } CPP_member auto equal(move_into_cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires input_iterator) { return it_ == that.it_; } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_iterator) { --it_; } CPP_member auto advance(iter_difference_t n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires random_access_iterator) { it_ += n; } CPP_member auto distance_to(move_into_cursor const & that) const // - -> CPP_ret(iter_difference_t)( // + -> CPP_ret(iter_difference_t)( + /// \pre requires sized_sentinel_for) { return that.it_ - it_; } - template(typename II = I const)( // - requires same_as AND indirectly_readable) // + template(typename II = I const)( + /// \pre + requires same_as AND indirectly_readable) constexpr iter_rvalue_reference_t move() const // noexcept(has_nothrow_iter_move_v) { diff --git a/include/range/v3/iterator/operations.hpp b/include/range/v3/iterator/operations.hpp index 0944856252..8ef8691f54 100644 --- a/include/range/v3/iterator/operations.hpp +++ b/include/range/v3/iterator/operations.hpp @@ -38,8 +38,9 @@ namespace ranges struct advance_fn { #if RANGES_CXX_IF_CONSTEXPR >= RANGES_CXX_IF_CONSTEXPR_17 - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) constexpr void operator()(I & i, iter_difference_t n) const // [[expects: n >= 0 || bidirectional_iterator]] { @@ -58,8 +59,9 @@ namespace ranges } } - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr void operator()(I & i, S bound) const // [[expects axiom: reachable(i, bound)]] { @@ -78,8 +80,9 @@ namespace ranges ++i; } - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr iter_difference_t // operator()(I & i, iter_difference_t n, S bound) const // [[expects axiom: 0 == n || @@ -169,23 +172,26 @@ namespace ranges public: // Advance a certain number of steps: - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) constexpr void operator()(I & i, iter_difference_t n) const { advance_fn::n_(i, n, iterator_tag_of{}); } // Advance to a certain position: - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr void operator()(I & i, S s) const { advance_fn::to_( i, static_cast(s), meta::bool_>()); } // Advance a certain number of times, with a bound: - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr iter_difference_t // operator()(I & it, iter_difference_t n, S bound) const { @@ -197,8 +203,9 @@ namespace ranges } #endif - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) constexpr void operator()(counted_iterator & i, iter_difference_t n) const; }; @@ -299,28 +306,32 @@ namespace ranges struct next_fn { - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) constexpr I operator()(I it) const { return ++it; } - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) constexpr I operator()(I it, iter_difference_t n) const { advance(it, n); return it; } - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr I operator()(I it, S s) const { advance(it, static_cast(s)); return it; } - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr I operator()(I it, iter_difference_t n, S bound) const { advance(it, n, static_cast(bound)); @@ -333,21 +344,24 @@ namespace ranges struct prev_fn { - template(typename I)( // - requires bidirectional_iterator) // + template(typename I)( + /// \pre + requires bidirectional_iterator) constexpr I operator()(I it) const { return --it; } - template(typename I)( // - requires bidirectional_iterator) // + template(typename I)( + /// \pre + requires bidirectional_iterator) constexpr I operator()(I it, iter_difference_t n) const { advance(it, -n); return it; } - template(typename I)( // - requires bidirectional_iterator) // + template(typename I)( + /// \pre + requires bidirectional_iterator) constexpr I operator()(I it, iter_difference_t n, I bound) const { advance(it, -n, static_cast(bound)); @@ -361,7 +375,8 @@ namespace ranges struct iter_enumerate_fn { private: - template(typename I, typename S)( // + template(typename I, typename S)( + /// \pre requires (!sized_sentinel_for)) // static constexpr std::pair, I> // impl_i(I first, S last, sentinel_tag) @@ -371,8 +386,9 @@ namespace ranges ++d; return {d, first}; } - template(typename I, typename S)( // - requires sized_sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sized_sentinel_for) static constexpr std::pair, I> // impl_i(I first, S end_, sentinel_tag) { @@ -391,8 +407,9 @@ namespace ranges } public: - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr std::pair, I> operator()(I first, S last) const { return iter_enumerate_fn::impl_i(static_cast(first), @@ -422,8 +439,9 @@ namespace ranges } public: - template(typename I, typename S)( // - requires input_or_output_iterator AND sentinel_for) // + template(typename I, typename S)( + /// \pre + requires input_or_output_iterator AND sentinel_for) constexpr iter_difference_t operator()(I first, S last) const { return iter_distance_fn::impl_i(static_cast(first), @@ -463,8 +481,9 @@ namespace ranges } public: - template(typename I, typename S)( // - requires input_iterator AND sentinel_for) // + template(typename I, typename S)( + /// \pre + requires input_iterator AND sentinel_for) constexpr int operator()(I first, S last, iter_difference_t n) const { return iter_distance_compare_fn::impl_i(static_cast(first), @@ -480,8 +499,9 @@ namespace ranges // Like distance(b,e), but guaranteed to be O(1) struct iter_size_fn { - template(typename I, typename S)( // - requires sized_sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sized_sentinel_for) constexpr meta::_t>> // operator()(I const & first, S last) const { @@ -554,8 +574,9 @@ namespace ranges public: using iter_enumerate_fn::operator(); - template(typename Rng)( // - requires range) // + template(typename Rng)( + /// \pre + requires range) std::pair, iterator_t> operator()(Rng && rng) const { // Better not be trying to compute the distance of an infinite range: @@ -585,8 +606,9 @@ namespace ranges public: using iter_distance_fn::operator(); - template(typename Rng)( // - requires range) // + template(typename Rng)( + /// \pre + requires range) constexpr range_difference_t operator()(Rng && rng) const { // Better not be trying to compute the distance of an infinite range: @@ -625,8 +647,9 @@ namespace ranges public: using iter_distance_compare_fn::operator(); - template(typename Rng)( // - requires range) // + template(typename Rng)( + /// \pre + requires range) int operator()(Rng && rng, range_difference_t n) const { return distance_compare_fn::impl_r(rng, n, sized_range_tag_of()); diff --git a/include/range/v3/iterator/reverse_iterator.hpp b/include/range/v3/iterator/reverse_iterator.hpp index 713ea5934f..5dda1efbdf 100644 --- a/include/range/v3/iterator/reverse_iterator.hpp +++ b/include/range/v3/iterator/reverse_iterator.hpp @@ -79,8 +79,9 @@ namespace ranges { return it_; } - template(typename J)( // - requires sentinel_for) // + template(typename J)( + /// \pre + requires sentinel_for) constexpr bool equal(reverse_cursor const & that) const { return it_ == that.it_; @@ -95,13 +96,15 @@ namespace ranges } CPP_member constexpr auto advance(iter_difference_t n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires random_access_iterator) { it_ -= n; } - template(typename J)( // - requires sized_sentinel_for) // + template(typename J)( + /// \pre + requires sized_sentinel_for) constexpr iter_difference_t distance_to(reverse_cursor const & that) // const { @@ -118,8 +121,9 @@ namespace ranges public: reverse_cursor() = default; - template(typename U)( // - requires convertible_to) // + template(typename U)( + /// \pre + requires convertible_to) constexpr reverse_cursor(reverse_cursor const & u) : it_(u.base()) {} @@ -129,8 +133,9 @@ namespace ranges struct make_reverse_iterator_fn { - template(typename I)( // - requires bidirectional_iterator) // + template(typename I)( + /// \pre + requires bidirectional_iterator) constexpr reverse_iterator operator()(I i) const { return reverse_iterator(i); diff --git a/include/range/v3/iterator/stream_iterators.hpp b/include/range/v3/iterator/stream_iterators.hpp index bfad71b2b5..f4f15db6c6 100644 --- a/include/range/v3/iterator/stream_iterators.hpp +++ b/include/range/v3/iterator/stream_iterators.hpp @@ -49,8 +49,9 @@ namespace ranges : sout_(&s) , delim_(d) {} - template(typename U)( // - requires convertible_to const &>) // + template(typename U)( + /// \pre + requires convertible_to const &>) ostream_iterator & operator=(U && value) { RANGES_EXPECT(sout_); @@ -129,8 +130,9 @@ namespace ranges struct make_ostream_joiner_fn { - template(typename Delim, typename Char, typename Traits)( // - requires semiregular>) // + template(typename Delim, typename Char, typename Traits)( + /// \pre + requires semiregular>) ostream_joiner, Char, Traits> // operator()(std::basic_ostream & s, Delim && d) const { diff --git a/include/range/v3/iterator/unreachable_sentinel.hpp b/include/range/v3/iterator/unreachable_sentinel.hpp index c54500cb4b..1d7595d818 100644 --- a/include/range/v3/iterator/unreachable_sentinel.hpp +++ b/include/range/v3/iterator/unreachable_sentinel.hpp @@ -27,28 +27,32 @@ namespace ranges { template friend constexpr auto operator==(I const &, unreachable_sentinel_t) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires weakly_incrementable) { return false; } template friend constexpr auto operator==(unreachable_sentinel_t, I const &) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires weakly_incrementable) { return false; } template friend constexpr auto operator!=(I const &, unreachable_sentinel_t) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires weakly_incrementable) { return true; } template friend constexpr auto operator!=(unreachable_sentinel_t, I const &) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires weakly_incrementable) { return true; diff --git a/include/range/v3/iterator_range.hpp b/include/range/v3/iterator_range.hpp index 4af5b735e3..12a19848f5 100644 --- a/include/range/v3/iterator_range.hpp +++ b/include/range/v3/iterator_range.hpp @@ -154,28 +154,31 @@ namespace ranges constexpr iterator_range(I first, S last) : compressed_pair{detail::move(first), detail::move(last)} {} - template(typename X, typename Y)( // - requires constructible_from AND constructible_from) // + template(typename X, typename Y)( + /// \pre + requires constructible_from AND constructible_from) constexpr iterator_range(iterator_range rng) : compressed_pair{detail::move(rng.begin()), detail::move(rng.end())} {} - template(typename X, typename Y)( // - requires constructible_from AND constructible_from) // + template(typename X, typename Y)( + /// \pre + requires constructible_from AND constructible_from) constexpr explicit iterator_range(std::pair rng) : compressed_pair{detail::move(rng.first), detail::move(rng.second)} {} - template(typename X, typename Y)( // - requires assignable_from AND assignable_from) // + template(typename X, typename Y)( + /// \pre + requires assignable_from AND assignable_from) iterator_range & operator=(iterator_range rng) { base().first() = std::move(rng.base()).first(); base().second() = std::move(rng.base()).second(); return *this; } - template(typename X, typename Y)( // - requires convertible_to AND convertible_to) // - constexpr - operator std::pair() const + template(typename X, typename Y)( + /// \pre + requires convertible_to AND convertible_to) + constexpr operator std::pair() const { return {base().first(), base().second()}; } @@ -220,28 +223,32 @@ namespace ranges static_cast(ranges::distance(rng_)) == size_); #endif } - template(typename X, typename Y)( // + template(typename X, typename Y)( + /// \pre requires constructible_from AND constructible_from) RANGES_NDEBUG_CONSTEXPR sized_iterator_range(std::pair rng, size_type size) : sized_iterator_range{detail::move(rng).first, detail::move(rng).second, size} {} - template(typename X, typename Y)( // - requires constructible_from AND constructible_from) // + template(typename X, typename Y)( + /// \pre + requires constructible_from AND constructible_from) RANGES_NDEBUG_CONSTEXPR sized_iterator_range(iterator_range rng, size_type size) : sized_iterator_range{detail::move(rng).first(), detail::move(rng).second, size} {} - template(typename X, typename Y)( // - requires constructible_from AND constructible_from) // + template(typename X, typename Y)( + /// \pre + requires constructible_from AND constructible_from) RANGES_NDEBUG_CONSTEXPR sized_iterator_range(sized_iterator_range rng) : sized_iterator_range{detail::move(rng).rng_.first(), detail::move(rng).rng_.second, rng.size_} {} - template(typename X, typename Y)( // - requires assignable_from AND assignable_from) // + template(typename X, typename Y)( + /// \pre + requires assignable_from AND assignable_from) sized_iterator_range & operator=(sized_iterator_range rng) { rng_ = detail::move(rng).rng_; @@ -260,14 +267,16 @@ namespace ranges { return size_; } - template(typename X, typename Y)( // - requires convertible_to AND convertible_to) // + template(typename X, typename Y)( + /// \pre + requires convertible_to AND convertible_to) constexpr operator std::pair() const { return rng_; } - template(typename X, typename Y)( // - requires convertible_to AND convertible_to) // + template(typename X, typename Y)( + /// \pre + requires convertible_to AND convertible_to) constexpr operator iterator_range() const { return rng_; @@ -278,7 +287,8 @@ namespace ranges } // clang-format off /// Tuple-like access for `sized_iterator_range` - template(std::size_t N)( // + template(std::size_t N)( + /// \pre requires (N < 2)) // friend constexpr auto CPP_auto_fun(get)(sized_iterator_range const &p) ( @@ -287,7 +297,8 @@ namespace ranges ) // clang-format on /// \overload - template(std::size_t N)( // + template(std::size_t N)( + /// \pre requires (N == 2)) // friend constexpr size_type get(sized_iterator_range const & p) noexcept { @@ -298,16 +309,18 @@ namespace ranges struct make_iterator_range_fn { /// \return `{first, last}` - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr iterator_range operator()(I first, S last) const { return {detail::move(first), detail::move(last)}; } /// \return `{first, last, size}` - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) constexpr sized_iterator_range // operator()(I first, S last, detail::iter_size_t sz) const { diff --git a/include/range/v3/numeric/accumulate.hpp b/include/range/v3/numeric/accumulate.hpp index e0db1e3634..e88cce375d 100644 --- a/include/range/v3/numeric/accumulate.hpp +++ b/include/range/v3/numeric/accumulate.hpp @@ -34,10 +34,11 @@ namespace ranges struct accumulate_fn { template(typename I, typename S, typename T, typename Op = plus, - typename P = identity)( // + typename P = identity)( + /// \pre requires sentinel_for AND input_iterator AND indirectly_binary_invocable_> AND - assignable_from>>) // + assignable_from>>) T operator()(I first, S last, T init, Op op = Op{}, P proj = P{}) const { @@ -46,11 +47,12 @@ namespace ranges return init; } - template(typename Rng, typename T, typename Op = plus, typename P = identity)( // + template(typename Rng, typename T, typename Op = plus, typename P = identity)( + /// \pre requires input_range AND indirectly_binary_invocable_, P>> AND assignable_from< - T &, indirect_result_t, P>>>) // + T &, indirect_result_t, P>>>) T operator()(Rng && rng, T init, Op op = Op{}, P proj = P{}) const { return (*this)( diff --git a/include/range/v3/numeric/adjacent_difference.hpp b/include/range/v3/numeric/adjacent_difference.hpp index 7611bcfc3a..1dd26abca2 100644 --- a/include/range/v3/numeric/adjacent_difference.hpp +++ b/include/range/v3/numeric/adjacent_difference.hpp @@ -70,9 +70,10 @@ namespace ranges struct adjacent_difference_fn { template(typename I, typename S, typename O, typename S2, typename BOp = minus, - typename P = identity)( // + typename P = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - differenceable) // + differenceable) adjacent_difference_result operator()(I first, S last, O result, @@ -102,8 +103,9 @@ namespace ranges } template(typename I, typename S, typename O, typename BOp = minus, - typename P = identity)( // - requires sentinel_for AND differenceable) // + typename P = identity)( + /// \pre + requires sentinel_for AND differenceable) adjacent_difference_result // operator()(I first, S last, O result, BOp bop = BOp{}, P proj = P{}) const { @@ -116,7 +118,8 @@ namespace ranges } template(typename Rng, typename ORef, typename BOp = minus, typename P = identity, - typename I = iterator_t, typename O = uncvref_t)( // + typename I = iterator_t, typename O = uncvref_t)( + /// \pre requires range AND differenceable) adjacent_difference_result, O> // operator()(Rng && rng, ORef && result, BOp bop = BOp{}, P proj = P{}) const @@ -129,7 +132,8 @@ namespace ranges } template(typename Rng, typename ORng, typename BOp = minus, typename P = identity, - typename I = iterator_t, typename O = iterator_t)( // + typename I = iterator_t, typename O = iterator_t)( + /// \pre requires range AND range AND differenceable) adjacent_difference_result, borrowed_iterator_t> operator()(Rng && rng, ORng && result, BOp bop = BOp{}, P proj = P{}) const diff --git a/include/range/v3/numeric/inner_product.hpp b/include/range/v3/numeric/inner_product.hpp index ff46f66f16..2aa5476813 100644 --- a/include/range/v3/numeric/inner_product.hpp +++ b/include/range/v3/numeric/inner_product.hpp @@ -73,9 +73,10 @@ namespace ranges { template(typename I1, typename S1, typename I2, typename S2, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - inner_product_constraints) // + inner_product_constraints) T operator()(I1 begin1, S1 end1, I2 begin2, S2 end2, T init, BOp1 bop1 = BOp1{}, BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const @@ -90,9 +91,10 @@ namespace ranges template(typename I1, typename S1, typename I2, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires sentinel_for AND - inner_product_constraints) // + inner_product_constraints) T operator()(I1 begin1, S1 end1, I2 begin2, T init, BOp1 bop1 = BOp1{}, BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const { @@ -110,7 +112,8 @@ namespace ranges template(typename Rng1, typename I2Ref, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity, typename I1 = iterator_t, - typename I2 = uncvref_t)( // + typename I2 = uncvref_t)( + /// \pre requires range AND inner_product_constraints) T operator()(Rng1 && rng1, I2Ref && begin2, T init, BOp1 bop1 = BOp1{}, @@ -129,7 +132,8 @@ namespace ranges template(typename Rng1, typename Rng2, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity, typename I1 = iterator_t, - typename I2 = iterator_t)( // + typename I2 = iterator_t)( + /// \pre requires range AND range AND inner_product_constraints) T operator()(Rng1 && rng1, Rng2 && rng2, T init, BOp1 bop1 = BOp1{}, diff --git a/include/range/v3/numeric/iota.hpp b/include/range/v3/numeric/iota.hpp index c796a8b66d..5ccc6ff9c8 100644 --- a/include/range/v3/numeric/iota.hpp +++ b/include/range/v3/numeric/iota.hpp @@ -28,9 +28,10 @@ namespace ranges /// @{ struct iota_fn { - template(typename O, typename S, typename T)( // + template(typename O, typename S, typename T)( + /// \pre requires output_iterator AND sentinel_for AND - weakly_incrementable) // + weakly_incrementable) O operator()(O first, S last, T val) const { for(; first != last; ++first, ++val) @@ -38,8 +39,9 @@ namespace ranges return first; } - template(typename Rng, typename T)( // - requires output_range AND weakly_incrementable) // + template(typename Rng, typename T)( + /// \pre + requires output_range AND weakly_incrementable) borrowed_iterator_t operator()(Rng && rng, T val) const // { return (*this)(begin(rng), end(rng), detail::move(val)); diff --git a/include/range/v3/numeric/partial_sum.hpp b/include/range/v3/numeric/partial_sum.hpp index fb3234d60a..4baff66d51 100644 --- a/include/range/v3/numeric/partial_sum.hpp +++ b/include/range/v3/numeric/partial_sum.hpp @@ -90,9 +90,10 @@ namespace ranges struct partial_sum_fn { template(typename I, typename S1, typename O, typename S2, typename BOp = plus, - typename P = identity)( // + typename P = identity)( + /// \pre requires sentinel_for AND sentinel_for AND - partial_sum_constraints) // + partial_sum_constraints) partial_sum_result operator()(I first, S1 last, O result, @@ -120,8 +121,9 @@ namespace ranges } template(typename I, typename S, typename O, typename BOp = plus, - typename P = identity)( // - requires sentinel_for AND partial_sum_constraints) // + typename P = identity)( + /// \pre + requires sentinel_for AND partial_sum_constraints) partial_sum_result // operator()(I first, S last, O result, BOp bop = BOp{}, P proj = P{}) const { @@ -134,7 +136,8 @@ namespace ranges } template(typename Rng, typename ORef, typename BOp = plus, typename P = identity, - typename I = iterator_t, typename O = uncvref_t)( // + typename I = iterator_t, typename O = uncvref_t)( + /// \pre requires range AND partial_sum_constraints) partial_sum_result, O> // operator()(Rng && rng, ORef && result, BOp bop = BOp{}, P proj = P{}) const @@ -147,7 +150,8 @@ namespace ranges } template(typename Rng, typename ORng, typename BOp = plus, typename P = identity, - typename I = iterator_t, typename O = iterator_t)( // + typename I = iterator_t, typename O = iterator_t)( + /// \pre requires range AND range AND partial_sum_constraints) partial_sum_result, borrowed_iterator_t> // operator()(Rng && rng, ORng && result, BOp bop = BOp{}, P proj = P{}) const diff --git a/include/range/v3/range/access.hpp b/include/range/v3/range/access.hpp index ba8ad36e9d..34cc949b95 100644 --- a/include/range/v3/range/access.hpp +++ b/include/range/v3/range/access.hpp @@ -76,8 +76,9 @@ namespace ranges template void begin(std::initializer_list) = delete; - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) void is_iterator(I); // clang-format off @@ -129,8 +130,9 @@ namespace ranges return array; } - template(typename R)( // - requires detail::_borrowed_range AND // + template(typename R)( + /// \pre + requires detail::_borrowed_range AND (has_member_begin || has_non_member_begin)) constexpr auto operator()(R && r) const // noexcept(noexcept(impl::invoke(r))) @@ -199,7 +201,8 @@ namespace ranges template void end(std::initializer_list) = delete; - template(typename I, typename S)( // + template(typename I, typename S)( + /// \pre requires sentinel_for) void _is_sentinel(S, I); @@ -258,8 +261,9 @@ namespace ranges return array + N; } - template(typename R)( // - requires detail::_borrowed_range AND // + template(typename R)( + /// \pre + requires detail::_borrowed_range AND (has_member_end || has_non_member_end)) constexpr auto operator()(R && r) const // noexcept(noexcept(impl::invoke(r))) // @@ -289,8 +293,9 @@ namespace ranges return Fn{}(ref.get()); } - template(typename Int)( // - requires detail::integer_like_) // + template(typename Int)( + /// \pre + requires detail::integer_like_) auto operator-(Int dist) const -> detail::from_end_> { @@ -437,8 +442,9 @@ namespace ranges impl_ ? 0 : has_non_member_rbegin ? 1 : 2>; public: - template(typename R)( // - requires detail::_borrowed_range AND // + template(typename R)( + /// \pre + requires detail::_borrowed_range AND (has_member_rbegin || has_non_member_rbegin || can_reverse_end)) // @@ -574,8 +580,9 @@ namespace ranges using impl = impl_ ? 0 : has_non_member_rend ? 1 : 2>; public: - template(typename R)( // - requires detail::_borrowed_range AND // + template(typename R)( + /// \pre + requires detail::_borrowed_range AND (has_member_rend || // has_non_member_rend || // can_reverse_begin)) // diff --git a/include/range/v3/range/conversion.hpp b/include/range/v3/range/conversion.hpp index 37bc367864..376504de09 100644 --- a/include/range/v3/range/conversion.hpp +++ b/include/range/v3/range/conversion.hpp @@ -48,7 +48,8 @@ namespace ranges template friend auto operator|(Rng && rng, closure> (*)(to_container)) - -> CPP_broken_friend_ret(container_t)( // + -> CPP_broken_friend_ret(container_t)( + /// \pre requires invocable, Rng>) { return fn{}(static_cast(rng)); @@ -58,7 +59,8 @@ namespace ranges friend auto operator|(closure> (*)(to_container), Pipeable pipe) -> CPP_broken_friend_ret( - closure>>)( // + closure>>)( + /// \pre requires (is_pipeable_v)) { return closure>>{ @@ -117,6 +119,7 @@ namespace ranges CPP_member auto operator--() // -> CPP_ret(to_container_iterator &)( + /// \pre requires derived_from) { @@ -126,6 +129,7 @@ namespace ranges CPP_member auto operator--(int) // -> CPP_ret(to_container_iterator &)( + /// \pre requires derived_from) { @@ -136,6 +140,7 @@ namespace ranges CPP_member auto operator+=(difference_type n) // -> CPP_ret(to_container_iterator &)( + /// \pre requires derived_from) { @@ -145,6 +150,7 @@ namespace ranges CPP_member auto operator-=(difference_type n) // -> CPP_ret(to_container_iterator &)( + /// \pre requires derived_from) { @@ -154,6 +160,7 @@ namespace ranges CPP_broken_friend_member friend auto operator+(to_container_iterator i, difference_type n) // -> CPP_broken_friend_ret(to_container_iterator)( + /// \pre requires derived_from) { @@ -162,6 +169,7 @@ namespace ranges CPP_broken_friend_member friend auto operator-(to_container_iterator i, difference_type n) // -> CPP_broken_friend_ret(to_container_iterator)( + /// \pre requires derived_from) { @@ -170,6 +178,7 @@ namespace ranges CPP_broken_friend_member friend auto operator-(difference_type n, to_container_iterator i) // -> CPP_broken_friend_ret(to_container_iterator)( + /// \pre requires derived_from) { @@ -179,6 +188,7 @@ namespace ranges friend auto operator-(to_container_iterator const & i, to_container_iterator const & j) // -> CPP_broken_friend_ret(difference_type)( + /// \pre requires derived_from) { @@ -187,6 +197,7 @@ namespace ranges CPP_member auto operator[](difference_type n) const // -> CPP_ret(reference)( + /// \pre requires derived_from) { @@ -253,19 +264,21 @@ namespace ranges struct RANGES_STRUCT_WITH_ADL_BARRIER(to_container_closure_base) { // clang-format off - template(typename Rng, typename MetaFn, typename Fn)( // - requires input_range AND // - convertible_to_cont>) // + template(typename Rng, typename MetaFn, typename Fn)( + /// \pre + requires input_range AND + convertible_to_cont>) friend constexpr auto operator|(Rng && rng, to_container::closure fn) { return static_cast(fn)(static_cast(rng)); } - template(typename Rng, typename MetaFn, typename Fn)( // - requires input_range AND // - (!convertible_to_cont>) AND // - convertible_to_cont_cont>) // + template(typename Rng, typename MetaFn, typename Fn)( + /// \pre + requires input_range AND + (!convertible_to_cont>) AND + convertible_to_cont_cont>) friend constexpr auto operator|(Rng && rng, to_container::closure fn) { @@ -276,7 +289,8 @@ namespace ranges friend constexpr auto operator|(to_container::closure sh, Pipeable pipe) -> CPP_broken_friend_ret( - to_container::closure>)( // + to_container::closure>)( + /// \pre requires is_pipeable_v) { return to_container::closure>{ @@ -318,9 +332,10 @@ namespace ranges } public: - template(typename Rng)( // - requires input_range AND // - convertible_to_cont>) // + template(typename Rng)( + /// \pre + requires input_range AND + convertible_to_cont>) container_t operator()(Rng && rng) const { static_assert(!is_infinite::value, @@ -331,10 +346,11 @@ namespace ranges meta::bool_<(bool)to_container_reserve>; return impl(static_cast(rng), use_reserve_t{}); } - template(typename Rng)( // - requires input_range AND // - (!convertible_to_cont>) AND // - convertible_to_cont_cont>) // + template(typename Rng)( + /// \pre + requires input_range AND + (!convertible_to_cont>) AND + convertible_to_cont_cont>) container_t operator()(Rng && rng) const { static_assert(!is_infinite::value, @@ -400,9 +416,10 @@ namespace ranges } /// \overload - template(template class ContT, typename Rng)( // + template(template class ContT, typename Rng)( + /// \pre requires range AND - detail::convertible_to_cont>>) // + detail::convertible_to_cont>>) auto to(Rng && rng) -> ContT> { return detail::to_container_fn>{}( @@ -418,8 +435,9 @@ namespace ranges } /// \overload - template(typename Cont, typename Rng)( // - requires range AND detail::convertible_to_cont) // + template(typename Cont, typename Rng)( + /// \pre + requires range AND detail::convertible_to_cont) auto to(Rng && rng) -> Cont { return detail::to_container_fn>{}(static_cast(rng)); @@ -427,14 +445,16 @@ namespace ranges /// \cond // Slightly odd initializer_list overloads, undocumented for now. - template(template class ContT, typename T)( // - requires detail::convertible_to_cont, ContT>) // + template(template class ContT, typename T)( + /// \pre + requires detail::convertible_to_cont, ContT>) auto to(std::initializer_list il) -> ContT { return detail::to_container_fn>{}(il); } - template(typename Cont, typename T)( // - requires detail::convertible_to_cont, Cont>) // + template(typename Cont, typename T)( + /// \pre + requires detail::convertible_to_cont, Cont>) auto to(std::initializer_list il) -> Cont { return detail::to_container_fn>{}(il); @@ -458,7 +478,8 @@ namespace ranges { return {}; } - template(template class ContT, typename Rng)( // + template(template class ContT, typename Rng)( + /// \pre requires range AND detail::convertible_to_cont>>) RANGES_DEPRECATED("Please use ranges::to (no underscore) instead.") @@ -466,7 +487,8 @@ namespace ranges { return static_cast(rng) | ranges::to_(); } - template(template class ContT, typename T)( // + template(template class ContT, typename T)( + /// \pre requires detail::convertible_to_cont, ContT>) RANGES_DEPRECATED("Please use ranges::to (no underscore) instead.") ContT to_(std::initializer_list il) @@ -479,14 +501,16 @@ namespace ranges { return {}; } - template(typename Cont, typename Rng)( // + template(typename Cont, typename Rng)( + /// \pre requires range AND detail::convertible_to_cont) RANGES_DEPRECATED("Please use ranges::to (no underscore) instead.") Cont to_(Rng && rng) { return static_cast(rng) | ranges::to_(); } - template(typename Cont, typename T)( // + template(typename Cont, typename T)( + /// \pre requires detail::convertible_to_cont, Cont>) RANGES_DEPRECATED("Please use ranges::to (no underscore) instead.") Cont to_(std::initializer_list list) diff --git a/include/range/v3/range/dangling.hpp b/include/range/v3/range/dangling.hpp index 0c5b0d3803..0f04774136 100644 --- a/include/range/v3/range/dangling.hpp +++ b/include/range/v3/range/dangling.hpp @@ -35,8 +35,9 @@ namespace ranges { dangling() = default; /// Implicit converting constructor; ignores argument - template(typename T)( // - requires not_same_as_) // + template(typename T)( + /// \pre + requires not_same_as_) constexpr dangling(T &&) {} }; @@ -44,8 +45,9 @@ namespace ranges /// \cond namespace detail { - template(class R, class U)( // - requires range) // + template(class R, class U)( + /// \pre + requires range) using maybe_dangling_ = // meta::conditional_t, U, dangling>; } diff --git a/include/range/v3/range/operations.hpp b/include/range/v3/range/operations.hpp index c233ae8435..4665657b58 100644 --- a/include/range/v3/range/operations.hpp +++ b/include/range/v3/range/operations.hpp @@ -35,9 +35,10 @@ namespace ranges struct at_fn { /// \return `begin(rng)[n]` - template(typename Rng)( // - requires random_access_range AND sized_range AND // - borrowed_range) // + template(typename Rng)( + /// \pre + requires random_access_range AND sized_range AND + borrowed_range) constexpr range_reference_t // operator()(Rng && rng, range_difference_t n) const { @@ -67,7 +68,8 @@ namespace ranges struct index_fn { /// \return `begin(rng)[n]` - template(typename Rng, typename Int)( // + template(typename Rng, typename Int)( + /// \pre requires random_access_range AND integral AND borrowed_range) constexpr range_reference_t operator()(Rng && rng, Int n) const // { @@ -89,9 +91,10 @@ namespace ranges struct back_fn { /// \return `*prev(end(rng))` - template(typename Rng)( // - requires common_range AND bidirectional_range AND // - borrowed_range) // + template(typename Rng)( + /// \pre + requires common_range AND bidirectional_range AND + borrowed_range) constexpr range_reference_t operator()(Rng && rng) const { return *prev(end(rng)); @@ -106,8 +109,9 @@ namespace ranges struct front_fn { /// \return `*begin(rng)` - template(typename Rng)( // - requires forward_range AND borrowed_range) // + template(typename Rng)( + /// \pre + requires forward_range AND borrowed_range) constexpr range_reference_t operator()(Rng && rng) const { return *begin(rng); diff --git a/include/range/v3/range/primitives.hpp b/include/range/v3/range/primitives.hpp index e92c096001..b5bea0978a 100644 --- a/include/range/v3/range/primitives.hpp +++ b/include/range/v3/range/primitives.hpp @@ -63,8 +63,9 @@ namespace ranges } // Prefer member if it returns integral. - template(typename R)( // - requires integral> AND // + template(typename R)( + /// \pre + requires integral> AND (!disable_sized_range>)) // static constexpr member_size_t impl_(R && r, int) // noexcept(noexcept(((R &&) r).size())) @@ -73,8 +74,9 @@ namespace ranges } // Use ADL if it returns integral. - template(typename R)( // - requires integral> AND // + template(typename R)( + /// \pre + requires integral> AND (!disable_sized_range>)) // static constexpr non_member_size_t impl_(R && r, long) // noexcept(noexcept(size((R &&) r))) @@ -82,9 +84,10 @@ namespace ranges return size((R &&) r); } - template(typename R)( // - requires forward_iterator<_begin_::_t> AND // - sized_sentinel_for<_end_::_t, _begin_::_t>) // + template(typename R)( + /// \pre + requires forward_iterator<_begin_::_t> AND + sized_sentinel_for<_end_::_t, _begin_::_t>) static constexpr auto impl_(R && r, ...) -> detail::iter_size_t<_begin_::_t> { @@ -161,22 +164,25 @@ namespace ranges template using member_data_t = detail::decay_t().data())>; - template(typename R)( // + template(typename R)( + /// \pre requires std::is_pointer>::value) // static constexpr member_data_t impl_(R & r, detail::priority_tag<2>) noexcept(noexcept(r.data())) { return r.data(); } - template(typename R)( // + template(typename R)( + /// \pre requires std::is_pointer<_begin_::_t>::value) // static constexpr _begin_::_t impl_(R && r, detail::priority_tag<1>) noexcept(noexcept(ranges::begin((R &&) r))) { return ranges::begin((R &&) r); } - template(typename R)( // - requires contiguous_iterator<_begin_::_t>) // + template(typename R)( + /// \pre + requires contiguous_iterator<_begin_::_t>) static constexpr auto impl_(R && r, detail::priority_tag<0>) noexcept( noexcept(ranges::begin((R &&) r) == ranges::end((R &&) r) ? nullptr @@ -264,8 +270,9 @@ namespace ranges } // Fall further back to begin == end. - template(typename R)( // - requires forward_iterator<_begin_::_t>) // + template(typename R)( + /// \pre + requires forward_iterator<_begin_::_t>) static constexpr auto impl_(R && r, detail::priority_tag<0>) noexcept( noexcept(bool(ranges::begin((R &&) r) == ranges::end((R &&) r)))) -> decltype(bool(ranges::begin((R &&) r) == diff --git a/include/range/v3/utility/addressof.hpp b/include/range/v3/utility/addressof.hpp index 43566f1a94..4fcb58e791 100644 --- a/include/range/v3/utility/addressof.hpp +++ b/include/range/v3/utility/addressof.hpp @@ -52,14 +52,16 @@ namespace ranges ignore_t); } - template(typename T)( // + template(typename T)( + /// \pre requires(has_bad_addressof())) T * addressof(T & arg) noexcept { return std::addressof(arg); } - template(typename T)( // + template(typename T)( + /// \pre requires (!has_bad_addressof())) constexpr T * addressof(T & arg) noexcept { diff --git a/include/range/v3/utility/any.hpp b/include/range/v3/utility/any.hpp index 111ed99698..1d63eb8e23 100644 --- a/include/range/v3/utility/any.hpp +++ b/include/range/v3/utility/any.hpp @@ -122,7 +122,8 @@ namespace ranges public: any() noexcept = default; - template(typename TRef, typename T = detail::decay_t)( // + template(typename TRef, typename T = detail::decay_t)( + /// \pre requires copyable AND (!same_as)) // any(TRef && t) : ptr_(new impl(static_cast(t))) @@ -137,7 +138,8 @@ namespace ranges ptr_.reset(that.ptr_ ? that.ptr_->clone() : nullptr); return *this; } - template(typename TRef, typename T = detail::decay_t)( // + template(typename TRef, typename T = detail::decay_t)( + /// \pre requires copyable AND (!same_as)) // any & operator=(TRef && t) { diff --git a/include/range/v3/utility/box.hpp b/include/range/v3/utility/box.hpp index 510671d9e7..f7d521c704 100644 --- a/include/range/v3/utility/box.hpp +++ b/include/range/v3/utility/box.hpp @@ -45,7 +45,8 @@ namespace ranges mutable T value; CPP_member - constexpr CPP_ctor(mutable_)()( // + constexpr CPP_ctor(mutable_)()( + /// \pre requires std::is_default_constructible::value) : value{} {} @@ -171,7 +172,8 @@ namespace ranges : value{} {} #if defined(__cpp_conditional_explicit) && __cpp_conditional_explicit > 0 - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from) constexpr explicit(!convertible_to) box(E && e) @@ -179,7 +181,8 @@ namespace ranges : value(static_cast(e)) {} #else - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from AND convertible_to) @@ -187,7 +190,8 @@ namespace ranges noexcept(std::is_nothrow_constructible::value) : value(static_cast(e)) {} - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from AND (!convertible_to)) @@ -226,7 +230,8 @@ namespace ranges : Element{} {} #if defined(__cpp_conditional_explicit) && __cpp_conditional_explicit > 0 - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from) constexpr explicit(!convertible_to) box(E && e) @@ -234,7 +239,8 @@ namespace ranges : Element(static_cast(e)) {} #else - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from AND convertible_to) @@ -242,7 +248,8 @@ namespace ranges noexcept(std::is_nothrow_constructible::value) // : Element(static_cast(e)) {} - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from AND (!convertible_to)) @@ -279,19 +286,22 @@ namespace ranges constexpr box() noexcept = default; #if defined(__cpp_conditional_explicit) && __cpp_conditional_explicit > 0 - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from) constexpr explicit(!convertible_to) box(E &&) noexcept {} #else - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from AND convertible_to) constexpr box(E &&) noexcept {} - template(typename E)( // + template(typename E)( + /// \pre requires (!same_as>) AND constructible_from AND (!convertible_to)) diff --git a/include/range/v3/utility/common_tuple.hpp b/include/range/v3/utility/common_tuple.hpp index 3d1f45a6f2..eb45c7b185 100644 --- a/include/range/v3/utility/common_tuple.hpp +++ b/include/range/v3/utility/common_tuple.hpp @@ -119,48 +119,55 @@ namespace ranges requires default_constructible>) : common_tuple::forward_tuple_interface{} {} - template(typename... Us)( // - requires constructible_from, detail::args>) // + template(typename... Us)( + /// \pre + requires constructible_from, detail::args>) explicit common_tuple(Us &&... us) // noexcept(meta::and_c::value...>::value) : common_tuple::forward_tuple_interface{static_cast(us)...} {} - template(typename... Us)( // - requires constructible_from, detail::rargs>) // + template(typename... Us)( + /// \pre + requires constructible_from, detail::rargs>) common_tuple(std::tuple & that) // noexcept( meta::and_c::value...>::value) // : common_tuple(that, meta::make_index_sequence{}) {} - template(typename... Us)( // + template(typename... Us)( + /// \pre requires constructible_from, detail::rargs>) common_tuple(std::tuple const & that) // noexcept(meta::and_c< std::is_nothrow_constructible::value...>::value) // : common_tuple(that, meta::make_index_sequence{}) {} - template(typename... Us)( // - requires constructible_from, detail::args>) // + template(typename... Us)( + /// \pre + requires constructible_from, detail::args>) common_tuple(std::tuple && that) // noexcept( meta::and_c::value...>::value) // : common_tuple(std::move(that), meta::make_index_sequence{}) {} - template(typename... Us)( // - requires constructible_from, detail::rargs>) // + template(typename... Us)( + /// \pre + requires constructible_from, detail::rargs>) common_tuple(common_tuple & that) // noexcept( meta::and_c::value...>::value) // : common_tuple(that, meta::make_index_sequence{}) {} - template(typename... Us)( // + template(typename... Us)( + /// \pre requires constructible_from, detail::rargs>) common_tuple(common_tuple const & that) // noexcept(meta::and_c< std::is_nothrow_constructible::value...>::value) // : common_tuple(that, meta::make_index_sequence{}) {} - template(typename... Us)( // + template(typename... Us)( + /// \pre requires constructible_from, detail::args>) common_tuple(common_tuple && that) // noexcept( @@ -178,7 +185,8 @@ namespace ranges } // Assignment - template(typename... Us)( // + template(typename... Us)( + /// \pre requires std::is_assignable &, detail::rargs>::value) // common_tuple & operator=(std::tuple & that) noexcept( @@ -187,7 +195,8 @@ namespace ranges (void)tuple_transform(base(), that, element_assign_{}); return *this; } - template(typename... Us)( // + template(typename... Us)( + /// \pre requires std::is_assignable &, detail::rargs>::value) // common_tuple & operator=(std::tuple const & that) noexcept( @@ -196,7 +205,8 @@ namespace ranges (void)tuple_transform(base(), that, element_assign_{}); return *this; } - template(typename... Us)( // + template(typename... Us)( + /// \pre requires std::is_assignable &, detail::args>::value) // common_tuple & operator=(std::tuple && that) noexcept( @@ -206,7 +216,8 @@ namespace ranges return *this; } - template(typename... Us)( // + template(typename... Us)( + /// \pre requires std::is_assignable &, detail::rargs>::value) common_tuple const & operator=(std::tuple & that) const noexcept( @@ -215,7 +226,8 @@ namespace ranges (void)tuple_transform(base(), that, element_assign_{}); return *this; } - template(typename... Us)( // + template(typename... Us)( + /// \pre requires std::is_assignable &, detail::rargs>::value) common_tuple const & operator=(std::tuple const & that) const @@ -225,7 +237,8 @@ namespace ranges (void)tuple_transform(base(), that, element_assign_{}); return *this; } - template(typename... Us)( // + template(typename... Us)( + /// \pre requires std::is_assignable &, detail::args>::value) common_tuple const & operator=(std::tuple && that) const noexcept( @@ -236,25 +249,28 @@ namespace ranges } // Conversion - template(typename... Us)( // - requires constructible_from, detail::rargs>) // + template(typename... Us)( + /// \pre + requires constructible_from, detail::rargs>) operator std::tuple() & noexcept( meta::and_c::value...>::value) { return detail::to_std_tuple( *this, meta::make_index_sequence{}); } - template(typename... Us)( // + template(typename... Us)( + /// \pre requires constructible_from, - detail::rargs>) // + detail::rargs>) operator std::tuple() const & noexcept( meta::and_c::value...>::value) { return detail::to_std_tuple( *this, meta::make_index_sequence{}); } - template(typename... Us)( // - requires constructible_from, detail::args>) // + template(typename... Us)( + /// \pre + requires constructible_from, detail::args>) operator std::tuple() && noexcept(meta::and_c::value...>::value) { @@ -326,29 +342,33 @@ namespace ranges requires default_constructible && default_constructible) : std::pair{} {} - template(typename F2, typename S2)( // - requires constructible_from AND constructible_from) // + template(typename F2, typename S2)( + /// \pre + requires constructible_from AND constructible_from) common_pair(F2 && f2, S2 && s2) // noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) // : std::pair{static_cast(f2), static_cast(s2)} {} - template(typename F2, typename S2)( // + template(typename F2, typename S2)( + /// \pre requires constructible_from AND constructible_from) common_pair(std::pair & that) // noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) // : std::pair{that.first, that.second} {} - template(typename F2, typename S2)( // + template(typename F2, typename S2)( + /// \pre requires constructible_from AND - constructible_from) // + constructible_from) common_pair(std::pair const & that) // noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) // : std::pair{that.first, that.second} {} - template(typename F2, typename S2)( // + template(typename F2, typename S2)( + /// \pre requires constructible_from AND constructible_from) common_pair(std::pair && that) // noexcept(std::is_nothrow_constructible::value && @@ -357,25 +377,28 @@ namespace ranges {} // Conversion - template(typename F2, typename S2)( // - requires constructible_from AND constructible_from) // + template(typename F2, typename S2)( + /// \pre + requires constructible_from AND constructible_from) operator std::pair() & // noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) { return {this->first, this->second}; } - template(typename F2, typename S2)( // + template(typename F2, typename S2)( + /// \pre requires constructible_from AND - constructible_from) // + constructible_from) operator std::pair() const & // noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) { return {this->first, this->second}; } - template(typename F2, typename S2)( // - requires constructible_from AND constructible_from) // + template(typename F2, typename S2)( + /// \pre + requires constructible_from AND constructible_from) operator std::pair() && noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) @@ -384,8 +407,9 @@ namespace ranges } // Assignment - template(typename F2, typename S2)( // - requires assignable_from AND assignable_from) // + template(typename F2, typename S2)( + /// \pre + requires assignable_from AND assignable_from) common_pair & operator=(std::pair & that) // noexcept(std::is_nothrow_assignable::value && std::is_nothrow_assignable::value) @@ -394,9 +418,10 @@ namespace ranges this->second = that.second; return *this; } - template(typename F2, typename S2)( // + template(typename F2, typename S2)( + /// \pre requires assignable_from AND - assignable_from) // + assignable_from) common_pair & operator=(std::pair const & that) // noexcept(std::is_nothrow_assignable::value && std::is_nothrow_assignable::value) @@ -405,8 +430,9 @@ namespace ranges this->second = that.second; return *this; } - template(typename F2, typename S2)( // - requires assignable_from AND assignable_from) // + template(typename F2, typename S2)( + /// \pre + requires assignable_from AND assignable_from) common_pair & operator=(std::pair && that) // noexcept(std::is_nothrow_assignable::value && std::is_nothrow_assignable::value) @@ -416,9 +442,10 @@ namespace ranges return *this; } - template(typename F2, typename S2)( // + template(typename F2, typename S2)( + /// \pre requires assignable_from AND - assignable_from) // + assignable_from) common_pair const & operator=(std::pair & that) const // noexcept(std::is_nothrow_assignable::value && std::is_nothrow_assignable::value) @@ -427,9 +454,10 @@ namespace ranges this->second = that.second; return *this; } - template(typename F2, typename S2)( // + template(typename F2, typename S2)( + /// \pre requires assignable_from AND - assignable_from) // + assignable_from) common_pair const & operator=(std::pair const & that) const // noexcept(std::is_nothrow_assignable::value && std::is_nothrow_assignable::value) @@ -438,8 +466,9 @@ namespace ranges this->second = that.second; return *this; } - template(typename F2, typename S2)( // - requires assignable_from AND assignable_from) // + template(typename F2, typename S2)( + /// \pre + requires assignable_from AND assignable_from) common_pair const & operator=(std::pair && that) const // noexcept(std::is_nothrow_assignable::value && std::is_nothrow_assignable::value) @@ -451,38 +480,44 @@ namespace ranges }; // Logical operators - template(typename F1, typename S1, typename F2, typename S2)( // - requires equality_comparable_with AND equality_comparable_with) // + template(typename F1, typename S1, typename F2, typename S2)( + /// \pre + requires equality_comparable_with AND equality_comparable_with) bool operator==(common_pair const & a, common_pair const & b) { return a.first == b.first && a.second == b.second; } - template(typename F1, typename S1, typename F2, typename S2)( // - requires equality_comparable_with AND equality_comparable_with) // + template(typename F1, typename S1, typename F2, typename S2)( + /// \pre + requires equality_comparable_with AND equality_comparable_with) bool operator==(common_pair const & a, std::pair const & b) { return a.first == b.first && a.second == b.second; } - template(typename F1, typename S1, typename F2, typename S2)( // - requires equality_comparable_with AND equality_comparable_with) // + template(typename F1, typename S1, typename F2, typename S2)( + /// \pre + requires equality_comparable_with AND equality_comparable_with) bool operator==(std::pair const & a, common_pair const & b) { return a.first == b.first && a.second == b.second; } - template(typename F1, typename S1, typename F2, typename S2)( // - requires totally_ordered_with AND totally_ordered_with) // + template(typename F1, typename S1, typename F2, typename S2)( + /// \pre + requires totally_ordered_with AND totally_ordered_with) bool operator<(common_pair const & a, common_pair const & b) { return a.first < b.first || (!(b.first < a.first) && a.second < b.second); } - template(typename F1, typename S1, typename F2, typename S2)( // - requires totally_ordered_with AND totally_ordered_with) // + template(typename F1, typename S1, typename F2, typename S2)( + /// \pre + requires totally_ordered_with AND totally_ordered_with) bool operator<(std::pair const & a, common_pair const & b) { return a.first < b.first || (!(b.first < a.first) && a.second < b.second); } - template(typename F1, typename S1, typename F2, typename S2)( // - requires totally_ordered_with AND totally_ordered_with) // + template(typename F1, typename S1, typename F2, typename S2)( + /// \pre + requires totally_ordered_with AND totally_ordered_with) bool operator<(common_pair const & a, std::pair const & b) { return a.first < b.first || (!(b.first < a.first) && a.second < b.second); diff --git a/include/range/v3/utility/compressed_pair.hpp b/include/range/v3/utility/compressed_pair.hpp index 1da3eeaa0c..759c26d23c 100644 --- a/include/range/v3/utility/compressed_pair.hpp +++ b/include/range/v3/utility/compressed_pair.hpp @@ -127,8 +127,9 @@ namespace ranges compressed_pair() = default; - template(typename U, typename V)( // - requires constructible_from AND constructible_from) // + template(typename U, typename V)( + /// \pre + requires constructible_from AND constructible_from) constexpr compressed_pair(U && u, V && v) // noexcept(noexcept(First((U &&) u)) && noexcept(Second((V &&) v))) : box>{(U &&) u} @@ -161,9 +162,10 @@ namespace ranges return static_cast(this->box>::get()); } - template(typename F, typename S)( // + template(typename F, typename S)( + /// \pre requires convertible_to AND - convertible_to) // + convertible_to) constexpr operator std::pair() const { diff --git a/include/range/v3/utility/copy.hpp b/include/range/v3/utility/copy.hpp index abe45d9698..18d7b0cafd 100644 --- a/include/range/v3/utility/copy.hpp +++ b/include/range/v3/utility/copy.hpp @@ -30,8 +30,9 @@ namespace ranges { struct copy_fn : copy_tag { - template(typename T)( // - requires constructible_from, T>) // + template(typename T)( + /// \pre + requires constructible_from, T>) constexpr auto operator()(T && t) const -> detail::decay_t { return static_cast(t); @@ -41,7 +42,8 @@ namespace ranges /// \sa `copy_fn` template friend constexpr auto operator|(T && t, copy_fn) - -> CPP_broken_friend_ret(detail::decay_t)( // + -> CPP_broken_friend_ret(detail::decay_t)( + /// \pre requires constructible_from, T>) { return static_cast(t); diff --git a/include/range/v3/utility/infinity.hpp b/include/range/v3/utility/infinity.hpp index 162ad8c2c8..1d7ada9897 100644 --- a/include/range/v3/utility/infinity.hpp +++ b/include/range/v3/utility/infinity.hpp @@ -36,28 +36,32 @@ namespace ranges } template friend constexpr auto operator==(Integer, infinity) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires integral) { return false; } template friend constexpr auto operator==(infinity, Integer) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires integral) { return false; } template friend constexpr auto operator!=(Integer, infinity) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires integral) { return true; } template friend constexpr auto operator!=(infinity, Integer) noexcept - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires integral) { return true; diff --git a/include/range/v3/utility/memory.hpp b/include/range/v3/utility/memory.hpp index e6df9e88f5..4bb826cb9d 100644 --- a/include/range/v3/utility/memory.hpp +++ b/include/range/v3/utility/memory.hpp @@ -88,7 +88,8 @@ namespace ranges } }; - template(typename T, typename... Args)( // + template(typename T, typename... Args)( + /// \pre requires (!std::is_array::value)) // std::unique_ptr make_unique(Args &&... args) { @@ -119,7 +120,8 @@ namespace ranges } CPP_member auto operator=(Val const & val) // - -> CPP_ret(raw_storage_iterator &)( // + -> CPP_ret(raw_storage_iterator &)( + /// \pre requires copy_constructible) { ::new((void *)std::addressof(*out_)) Val(val); @@ -127,7 +129,8 @@ namespace ranges } CPP_member auto operator=(Val && val) // - -> CPP_ret(raw_storage_iterator &)( // + -> CPP_ret(raw_storage_iterator &)( + /// \pre requires move_constructible) { ::new((void *)std::addressof(*out_)) Val(std::move(val)); @@ -140,14 +143,16 @@ namespace ranges } CPP_member auto operator++(int) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires (!forward_iterator)) { ++out_; } CPP_member auto operator++(int) // - -> CPP_ret(raw_storage_iterator)( // + -> CPP_ret(raw_storage_iterator)( + /// \pre requires forward_iterator) { auto tmp = *this; @@ -206,8 +211,9 @@ namespace ranges } }; - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) iterator_wrapper iter_ref(I & i) { return i; diff --git a/include/range/v3/utility/optional.hpp b/include/range/v3/utility/optional.hpp index 3ed74bf8d8..9f15504001 100644 --- a/include/range/v3/utility/optional.hpp +++ b/include/range/v3/utility/optional.hpp @@ -97,8 +97,9 @@ namespace ranges meta::bool_ && detail::is_trivially_copyable_v>{}) {} - template(typename... Args)( // - requires constructible_from) // + template(typename... Args)( + /// \pre + requires constructible_from) constexpr explicit optional_storage(in_place_t, Args &&... args) // noexcept(std::is_nothrow_constructible::value) @@ -142,8 +143,9 @@ namespace ranges : dummy_{} , engaged_{false} {} - template(typename... Args)( // - requires constructible_from) // + template(typename... Args)( + /// \pre + requires constructible_from) constexpr explicit optional_storage(in_place_t, Args &&... args) // noexcept(std::is_nothrow_constructible::value) @@ -203,7 +205,8 @@ namespace ranges constexpr auto swap(optional_base & that) // noexcept(std::is_nothrow_move_constructible::value && is_nothrow_swappable::value) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires move_constructible && swappable) { constexpr bool can_swap_trivially = @@ -215,8 +218,9 @@ namespace ranges } protected: - template(typename... Args)( // - requires constructible_from) // + template(typename... Args)( + /// \pre + requires constructible_from) T & construct_from(Args &&... args) noexcept(std::is_nothrow_constructible::value) { @@ -277,7 +281,8 @@ namespace ranges struct optional_base { optional_base() = default; - template(typename Arg)( // + template(typename Arg)( + /// \pre requires constructible_from) constexpr explicit optional_base(in_place_t, Arg && arg) noexcept // : ptr_(detail::addressof(arg)) @@ -301,7 +306,8 @@ namespace ranges CPP_member constexpr auto swap(optional_base & that) // noexcept(is_nothrow_swappable::value) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires swappable) { if(ptr_ && that.ptr_) @@ -311,8 +317,9 @@ namespace ranges } protected: - template(typename U)( // - requires convertible_to) // + template(typename U)( + /// \pre + requires convertible_to) constexpr T & construct_from(U && ref) noexcept { RANGES_EXPECT(!ptr_); @@ -505,8 +512,9 @@ namespace ranges using base_t::base_t; - template(typename E, typename... Args)( // - requires constructible_from &, Args...>) // + template(typename E, typename... Args)( + /// \pre + requires constructible_from &, Args...>) constexpr explicit optional(in_place_t, std::initializer_list il, Args &&... args) // noexcept(std::is_nothrow_constructible &, @@ -515,7 +523,8 @@ namespace ranges {} #if defined(__cpp_conditional_explicit) && __cpp_conditional_explicit > 0 - template(typename U = T)( // + template(typename U = T)( + /// \pre requires (!same_as, in_place_t>) AND (!same_as, optional>) AND constructible_from) @@ -523,7 +532,8 @@ namespace ranges : base_t(in_place, static_cast(v)) {} - template(typename U)( // + template(typename U)( + /// \pre requires optional_should_convert AND constructible_from) explicit(!convertible_to) optional(optional const & that) @@ -532,7 +542,8 @@ namespace ranges base_t::construct_from(*that); } #else - template(typename U = T)( // + template(typename U = T)( + /// \pre requires (!same_as, in_place_t>) AND (!same_as, optional>) AND constructible_from AND @@ -540,7 +551,8 @@ namespace ranges constexpr optional(U && v) : base_t(in_place, static_cast(v)) {} - template(typename U = T)( // + template(typename U = T)( + /// \pre requires (!same_as, in_place_t>) AND (!same_as, optional>) AND constructible_from AND @@ -549,7 +561,8 @@ namespace ranges : base_t(in_place, static_cast(v)) {} - template(typename U)( // + template(typename U)( + /// \pre requires optional_should_convert AND constructible_from AND convertible_to) @@ -558,7 +571,8 @@ namespace ranges if(that.has_value()) base_t::construct_from(*that); } - template(typename U)( // + template(typename U)( + /// \pre requires optional_should_convert AND constructible_from AND (!convertible_to)) @@ -569,16 +583,18 @@ namespace ranges } #endif - template(typename U)( // - requires optional_should_convert AND constructible_from AND // - convertible_to) // + template(typename U)( + /// \pre + requires optional_should_convert AND constructible_from AND + convertible_to) optional(optional && that) { if(that.has_value()) base_t::construct_from(detail::move(*that)); } - template(typename U)( // - requires optional_should_convert AND constructible_from AND // + template(typename U)( + /// \pre + requires optional_should_convert AND constructible_from AND (!convertible_to)) // explicit optional(optional && that) { @@ -595,11 +611,12 @@ namespace ranges optional & operator=(optional const &) = default; optional & operator=(optional &&) = default; - template(typename U = T)( // - requires (!same_as>) AND // - (!(satisfies && same_as>)) AND // - constructible_from AND // - assignable_from) // + template(typename U = T)( + /// \pre + requires (!same_as>) AND + (!(satisfies && same_as>)) AND + constructible_from AND + assignable_from) constexpr optional & operator=(U && u) noexcept( std::is_nothrow_constructible::value && std::is_nothrow_assignable::value) @@ -611,36 +628,40 @@ namespace ranges return *this; } - template(typename U)( // - requires optional_should_convert_assign AND // - constructible_from AND // - assignable_from) // + template(typename U)( + /// \pre + requires optional_should_convert_assign AND + constructible_from AND + assignable_from) constexpr optional & operator=(optional const & that) { base_t::assign_from(that); return *this; } - template(typename U)( // - requires optional_should_convert_assign AND // - constructible_from AND // - assignable_from) // + template(typename U)( + /// \pre + requires optional_should_convert_assign AND + constructible_from AND + assignable_from) constexpr optional & operator=(optional && that) { base_t::assign_from(std::move(that)); return *this; } - template(typename... Args)( // - requires constructible_from) // + template(typename... Args)( + /// \pre + requires constructible_from) T & emplace(Args &&... args) noexcept( std::is_nothrow_constructible::value) { reset(); return base_t::construct_from(static_cast(args)...); } - template(typename E, typename... Args)( // - requires constructible_from &, Args...>) // + template(typename E, typename... Args)( + /// \pre + requires constructible_from &, Args...>) T & emplace(std::initializer_list il, Args &&... args) noexcept( std::is_nothrow_constructible &, Args...>::value) { @@ -677,14 +698,16 @@ namespace ranges detail::move(**this); } - template(typename U)( // - requires copy_constructible AND convertible_to) // + template(typename U)( + /// \pre + requires copy_constructible AND convertible_to) constexpr T value_or(U && u) const & { return has_value() ? **this : static_cast((U &&) u); } - template(typename U)( // - requires move_constructible AND convertible_to) // + template(typename U)( + /// \pre + requires move_constructible AND convertible_to) constexpr T value_or(U && u) && { return has_value() ? detail::move(**this) : static_cast((U &&) u); diff --git a/include/range/v3/utility/random.hpp b/include/range/v3/utility/random.hpp index 1464bfb3e8..3196756f52 100644 --- a/include/range/v3/utility/random.hpp +++ b/include/range/v3/utility/random.hpp @@ -118,8 +118,9 @@ namespace ranges return seeds; } - template(typename I)( // - requires unsigned_integral) // + template(typename I)( + /// \pre + requires unsigned_integral) constexpr I fast_exp(I x, I power, I result = I{1}) { return power == I{0} @@ -218,9 +219,10 @@ namespace ranges std::array mixer_; - template(typename I, typename S)( // + template(typename I, typename S)( + /// \pre requires input_iterator AND sentinel_for AND - convertible_to, IntRep>) // + convertible_to, IntRep>) void mix_entropy(I first, S last) { auto hash_const = INIT_A; @@ -260,23 +262,26 @@ namespace ranges seed_seq_fe(const seed_seq_fe &) = delete; void operator=(const seed_seq_fe &) = delete; - template(typename T)( // - requires convertible_to) // + template(typename T)( + /// \pre + requires convertible_to) seed_seq_fe(std::initializer_list init) { seed(init.begin(), init.end()); } - template(typename I, typename S)( // - requires input_iterator AND sentinel_for AND // - convertible_to, IntRep>) // + template(typename I, typename S)( + /// \pre + requires input_iterator AND sentinel_for AND + convertible_to, IntRep>) seed_seq_fe(I first, S last) { seed(first, last); } // generating functions - template(typename I, typename S)( // + template(typename I, typename S)( + /// \pre requires random_access_iterator AND sentinel_for) RANGES_INTENDED_MODULAR_ARITHMETIC // void generate(I first, S const last) const @@ -303,9 +308,10 @@ namespace ranges return count; } - template(typename O)( // - requires weakly_incrementable AND // - indirectly_copyable) // + template(typename O)( + /// \pre + requires weakly_incrementable AND + indirectly_copyable) RANGES_INTENDED_MODULAR_ARITHMETIC void param(O dest) const { constexpr IntRep INV_A = randutils::fast_exp(MULT_A, IntRep(-1)); @@ -352,9 +358,10 @@ namespace ranges ranges::copy(mixer_copy, dest); } - template(typename I, typename S)( // + template(typename I, typename S)( + /// \pre requires input_iterator AND sentinel_for AND - convertible_to, IntRep>) // + convertible_to, IntRep>) void seed(I first, S last) { mix_entropy(first, last); diff --git a/include/range/v3/utility/semiregular_box.hpp b/include/range/v3/utility/semiregular_box.hpp index 62483ae352..65e0e59d86 100644 --- a/include/range/v3/utility/semiregular_box.hpp +++ b/include/range/v3/utility/semiregular_box.hpp @@ -135,31 +135,35 @@ namespace ranges this->construct_from(that.data_); } #if defined(__cpp_conditional_explicit) && 0 < __cpp_conditional_explicit - template(typename U)( // - requires (!same_as, semiregular_box>) AND // - constructible_from) // + template(typename U)( + /// \pre + requires (!same_as, semiregular_box>) AND + constructible_from) explicit(!convertible_to) constexpr semiregular_box(U && u) noexcept(std::is_nothrow_constructible::value) : semiregular_box(in_place, static_cast(u)) {} #else - template(typename U)( // - requires (!same_as, semiregular_box>) AND // + template(typename U)( + /// \pre + requires (!same_as, semiregular_box>) AND constructible_from AND (!convertible_to)) // constexpr explicit semiregular_box(U && u) noexcept(std::is_nothrow_constructible::value) : semiregular_box(in_place, static_cast(u)) {} - template(typename U)( // - requires (!same_as, semiregular_box>) AND // - constructible_from AND convertible_to) // + template(typename U)( + /// \pre + requires (!same_as, semiregular_box>) AND + constructible_from AND convertible_to) constexpr semiregular_box(U && u) noexcept(std::is_nothrow_constructible::value) : semiregular_box(in_place, static_cast(u)) {} #endif - template(typename... Args)( // - requires constructible_from) // + template(typename... Args)( + /// \pre + requires constructible_from) constexpr semiregular_box(in_place_t, Args &&... args) // noexcept(std::is_nothrow_constructible::value) : data_(static_cast(args)...) @@ -222,22 +226,25 @@ namespace ranges } operator T const &&() const && = delete; // clang-format off - template(typename... Args)( // - requires invocable) // + template(typename... Args)( + /// \pre + requires invocable) constexpr decltype(auto) operator()(Args &&... args) & noexcept(is_nothrow_invocable_v) { return invoke(data_, static_cast(args)...); } - template(typename... Args)( // - requires invocable) // + template(typename... Args)( + /// \pre + requires invocable) constexpr decltype(auto) operator()(Args &&... args) const & noexcept(is_nothrow_invocable_v) { return invoke(data_, static_cast(args)...); } - template(typename... Args)( // - requires invocable) // + template(typename... Args)( + /// \pre + requires invocable) constexpr decltype(auto) operator()(Args &&... args) && noexcept(is_nothrow_invocable_v) { @@ -254,7 +261,8 @@ namespace ranges , private detail::semiregular_get { semiregular_box() = default; - template(typename Arg)( // + template(typename Arg)( + /// \pre requires constructible_from, Arg &>) semiregular_box(in_place_t, Arg & arg) noexcept // : ranges::reference_wrapper(arg) @@ -264,9 +272,10 @@ namespace ranges using ranges::reference_wrapper::operator(); #if defined(_MSC_VER) - template(typename U)( // + template(typename U)( + /// \pre requires (!same_as, semiregular_box>) AND - constructible_from, U>) // + constructible_from, U>) constexpr semiregular_box(U && u) noexcept( std::is_nothrow_constructible, U>::value) : ranges::reference_wrapper{static_cast(u)} @@ -282,7 +291,8 @@ namespace ranges , private detail::semiregular_get { semiregular_box() = default; - template(typename Arg)( // + template(typename Arg)( + /// \pre requires constructible_from, Arg>) semiregular_box(in_place_t, Arg && arg) noexcept // : ranges::reference_wrapper(static_cast(arg)) @@ -292,9 +302,10 @@ namespace ranges using ranges::reference_wrapper::operator(); #if defined(_MSC_VER) - template(typename U)( // + template(typename U)( + /// \pre requires (!same_as, semiregular_box>) AND - constructible_from, U>) // + constructible_from, U>) constexpr semiregular_box(U && u) noexcept( std::is_nothrow_constructible, U>::value) : ranges::reference_wrapper{static_cast(u)} diff --git a/include/range/v3/utility/tagged_pair.hpp b/include/range/v3/utility/tagged_pair.hpp index 0748625522..f967f7785d 100644 --- a/include/range/v3/utility/tagged_pair.hpp +++ b/include/range/v3/utility/tagged_pair.hpp @@ -83,19 +83,22 @@ namespace ranges public: tagged() = default; using base_t::base_t; - template(typename Other)( // + template(typename Other)( + /// \pre requires can_convert::value) // constexpr tagged(tagged && that) // noexcept(std::is_nothrow_constructible::value) : base_t(static_cast(that)) {} - template(typename Other)( // + template(typename Other)( + /// \pre requires can_convert::value) // constexpr tagged(tagged const & that) // noexcept(std::is_nothrow_constructible::value) : base_t(static_cast(that)) {} - template(typename Other)( // + template(typename Other)( + /// \pre requires can_convert::value) // constexpr tagged & operator=(tagged && that) // noexcept( @@ -104,7 +107,8 @@ namespace ranges static_cast(*this) = static_cast(that); return *this; } - template(typename Other)( // + template(typename Other)( + /// \pre requires can_convert::value) // constexpr tagged & operator=(tagged const & that) // noexcept( @@ -113,16 +117,18 @@ namespace ranges static_cast(*this) = static_cast(that); return *this; } - template(typename U)( // + template(typename U)( + /// \pre requires (!same_as>) AND - satisfies) // + satisfies) constexpr tagged & operator=(U && u) // noexcept(noexcept(std::declval() = static_cast(u))) { static_cast(*this) = static_cast(u); return *this; } - template(typename B = Base)( // + template(typename B = Base)( + /// \pre requires is_swappable::value) // constexpr void swap(tagged & that) noexcept(is_nothrow_swappable::value) { @@ -132,7 +138,8 @@ namespace ranges template friend constexpr auto swap(tagged & x, tagged & y) // noexcept(is_nothrow_swappable::value) - -> CPP_broken_friend_ret(void)( // + -> CPP_broken_friend_ret(void)( + /// \pre requires is_swappable::value) { x.swap(y); @@ -143,7 +150,8 @@ namespace ranges #if RANGES_BROKEN_CPO_LOOKUP namespace _tagged_ { - template(typename Base, typename... Tags)( // + template(typename Base, typename... Tags)( + /// \pre requires is_swappable::value) // constexpr void swap(tagged & x, tagged & y) // noexcept(is_nothrow_swappable::value) diff --git a/include/range/v3/utility/variant.hpp b/include/range/v3/utility/variant.hpp index 31fa9fac22..03911c0c00 100644 --- a/include/range/v3/utility/variant.hpp +++ b/include/range/v3/utility/variant.hpp @@ -51,27 +51,31 @@ namespace ranges public: CPP_member - constexpr CPP_ctor(indexed_datum)(meta::nil_ = {})( // + constexpr CPP_ctor(indexed_datum)(meta::nil_ = {})( + /// \pre requires default_constructible) : data_{} {} CPP_member - CPP_ctor(indexed_datum)(indexed_datum && that)( // + CPP_ctor(indexed_datum)(indexed_datum && that)( + /// \pre requires move_constructible) { std::uninitialized_copy_n(make_move_iterator(that.data_), N, data_); } CPP_member - CPP_ctor(indexed_datum)(indexed_datum const & that)( // + CPP_ctor(indexed_datum)(indexed_datum const & that)( + /// \pre requires copy_constructible) { std::uninitialized_copy_n(that.data_, N, data_); } // \pre Requires distance(first, last) <= N // \pre Requires default_constructible || distance(first, last) == N - template(typename I, typename S)( // - requires sentinel_for AND input_iterator AND // - constructible_from>) // + template(typename I, typename S)( + /// \pre + requires sentinel_for AND input_iterator AND + constructible_from>) indexed_datum(I first, S last) { T * p = detail::uninitialized_copy(first, last, data_); @@ -79,14 +83,16 @@ namespace ranges } // \pre Requires distance(r) <= N // \pre Requires default_constructible || distance(r) == N - template(typename R)( // + template(typename R)( + /// \pre requires input_range AND constructible_from>) explicit indexed_datum(R && r) : indexed_datum{ranges::begin(r), ranges::end(r)} {} CPP_member auto operator=(indexed_datum && that) // - -> CPP_ret(indexed_datum &)( // + -> CPP_ret(indexed_datum &)( + /// \pre requires assignable_from) { ranges::move(that.data_, data_); @@ -94,15 +100,17 @@ namespace ranges } CPP_member auto operator=(indexed_datum const & that) // - -> CPP_ret(indexed_datum &)( // + -> CPP_ret(indexed_datum &)( + /// \pre requires assignable_from) { ranges::copy(that.data_, data_); return *this; } // \pre Requires ranges::distance(r) <= N - template(typename R)( // - requires input_range AND assignable_from>) // + template(typename R)( + /// \pre + requires input_range AND assignable_from>) indexed_datum & operator=(R && r) { ranges::copy(r, data_); diff --git a/include/range/v3/view/adaptor.hpp b/include/range/v3/view/adaptor.hpp index 7fe1642353..0297d7f31b 100644 --- a/include/range/v3/view/adaptor.hpp +++ b/include/range/v3/view/adaptor.hpp @@ -128,46 +128,53 @@ namespace ranges return ranges::end(rng.base()) ) // clang-format on - template(typename I)( // - requires equality_comparable) // + template(typename I)( + /// \pre + requires equality_comparable) static bool equal(I const & it0, I const & it1) { return it0 == it1; } - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) static iter_reference_t read(I const & it, detail::adaptor_base_current_mem_fn = {}) noexcept(noexcept(iter_reference_t(*it))) { return *it; } - template(typename I)( // - requires input_or_output_iterator) // + template(typename I)( + /// \pre + requires input_or_output_iterator) static void next(I & it) { ++it; } - template(typename I)( // - requires bidirectional_iterator) // + template(typename I)( + /// \pre + requires bidirectional_iterator) static void prev(I & it) { --it; } - template(typename I)( // - requires random_access_iterator) // + template(typename I)( + /// \pre + requires random_access_iterator) static void advance(I & it, iter_difference_t n) { it += n; } - template(typename I)( // - requires sized_sentinel_for) // + template(typename I)( + /// \pre + requires sized_sentinel_for) static iter_difference_t distance_to(I const & it0, I const & it1) { return it1 - it0; } - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) static constexpr bool empty(I const & it, S const & last) { return it == last; @@ -448,10 +455,11 @@ namespace ranges adaptor_cursor(BaseIter iter, Adapt adapt) : base_t{{std::move(iter), std::move(adapt)}} {} - template(typename OtherIter, typename OtherAdapt)( // + template(typename OtherIter, typename OtherAdapt)( + /// \pre requires // (!same_as, adaptor_cursor>) AND - convertible_to AND // + convertible_to AND convertible_to) adaptor_cursor(adaptor_cursor that) : base_t{{std::move(that.data_.first()), std::move(that.data_.second())}} @@ -501,16 +509,18 @@ namespace ranges auto pos = adapt.begin(d); return {std::move(pos), std::move(adapt)}; } - template(typename D = Derived)( // - requires same_as) // + template(typename D = Derived)( + /// \pre + requires same_as) constexpr auto begin_cursor() noexcept( noexcept(view_adaptor::begin_cursor_(std::declval()))) -> decltype(view_adaptor::begin_cursor_(std::declval())) { return view_adaptor::begin_cursor_(derived()); } - template(typename D = Derived)( // - requires same_as AND range) // + template(typename D = Derived)( + /// \pre + requires same_as AND range) constexpr auto begin_cursor() const noexcept(noexcept(view_adaptor::begin_cursor_(std::declval()))) -> decltype(view_adaptor::begin_cursor_(std::declval())) @@ -527,16 +537,18 @@ namespace ranges auto pos = adapt.end(d); return {std::move(pos), std::move(adapt)}; } - template(typename D = Derived)( // - requires same_as) // + template(typename D = Derived)( + /// \pre + requires same_as) constexpr auto end_cursor() noexcept( noexcept(view_adaptor::end_cursor_(std::declval()))) -> decltype(view_adaptor::end_cursor_(std::declval())) { return view_adaptor::end_cursor_(derived()); } - template(typename D = Derived)( // - requires same_as AND range) // + template(typename D = Derived)( + /// \pre + requires same_as AND range) constexpr auto end_cursor() const noexcept( noexcept(view_adaptor::end_cursor_(std::declval()))) -> decltype(view_adaptor::end_cursor_(std::declval())) diff --git a/include/range/v3/view/addressof.hpp b/include/range/v3/view/addressof.hpp index b8872f5429..2e626e9ea7 100644 --- a/include/range/v3/view/addressof.hpp +++ b/include/range/v3/view/addressof.hpp @@ -44,8 +44,9 @@ namespace ranges }; public: - template(typename Rng)( // - requires viewable_range AND input_range AND // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range AND std::is_lvalue_reference>::value) // constexpr auto CPP_auto_fun(operator())(Rng && rng)(const) // ( diff --git a/include/range/v3/view/adjacent_filter.hpp b/include/range/v3/view/adjacent_filter.hpp index 0dcbcca8a1..b1462fa279 100644 --- a/include/range/v3/view/adjacent_filter.hpp +++ b/include/range/v3/view/adjacent_filter.hpp @@ -74,7 +74,8 @@ namespace ranges constexpr adaptor(Parent * rng) noexcept : rng_(rng) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const && CPP_NOT(Other)) // constexpr adaptor(adaptor that) : rng_(that.rng_) @@ -90,7 +91,8 @@ namespace ranges } CPP_member constexpr auto prev(iterator_t & it) const // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { auto const first = ranges::begin(rng_->base()); @@ -113,7 +115,8 @@ namespace ranges } CPP_member constexpr auto begin_adaptor() const noexcept // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires detail::adjacent_filter_constraints) { return {this}; @@ -124,7 +127,8 @@ namespace ranges } CPP_member constexpr auto end_adaptor() const noexcept // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires detail::adjacent_filter_constraints) { return {this}; @@ -139,7 +143,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires copy_constructible) adjacent_filter_view(Rng &&, Fun) ->adjacent_filter_view, Fun>; @@ -149,8 +154,9 @@ namespace ranges { struct adjacent_filter_base_fn { - template(typename Rng, typename Pred)( // - requires detail::adjacent_filter_constraints) // + template(typename Rng, typename Pred)( + /// \pre + requires detail::adjacent_filter_constraints) constexpr adjacent_filter_view, Pred> // operator()(Rng && rng, Pred pred) const { diff --git a/include/range/v3/view/adjacent_remove_if.hpp b/include/range/v3/view/adjacent_remove_if.hpp index 0561110432..014efcdf2b 100644 --- a/include/range/v3/view/adjacent_remove_if.hpp +++ b/include/range/v3/view/adjacent_remove_if.hpp @@ -72,7 +72,8 @@ namespace ranges } CPP_member constexpr auto prev(iterator_t & it) const // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { rng_->satisfy_reverse(it); @@ -87,7 +88,8 @@ namespace ranges } CPP_member constexpr auto end_adaptor() // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires common_range) { if(bidirectional_range) @@ -96,7 +98,8 @@ namespace ranges } CPP_member constexpr auto end_adaptor() noexcept // - -> CPP_ret(adaptor_base)( // + -> CPP_ret(adaptor_base)( + /// \pre requires (!common_range)) { return {}; @@ -140,7 +143,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires copy_constructible) adjacent_remove_if_view(Rng &&, Fun) -> adjacent_remove_if_view, Fun>; @@ -150,9 +154,10 @@ namespace ranges { struct adjacent_remove_if_base_fn { - template(typename Rng, typename Pred)( // + template(typename Rng, typename Pred)( + /// \pre requires viewable_range AND forward_range AND - indirect_binary_predicate_, iterator_t>) // + indirect_binary_predicate_, iterator_t>) constexpr adjacent_remove_if_view, Pred> // operator()(Rng && rng, Pred pred) const { diff --git a/include/range/v3/view/all.hpp b/include/range/v3/view/all.hpp index b0f1bf742f..831e8ac5b6 100644 --- a/include/range/v3/view/all.hpp +++ b/include/range/v3/view/all.hpp @@ -65,8 +65,9 @@ namespace ranges } public: - template(typename T)( // - requires range AND viewable_range) // + template(typename T)( + /// \pre + requires range AND viewable_range) constexpr auto operator()(T && t) const { return all_fn::from_range_(static_cast(t), @@ -112,8 +113,9 @@ namespace ranges using ranges::views::all; using ranges::views::all_t; } - template(typename Rng)( // - requires viewable_range) // + template(typename Rng)( + /// \pre + requires viewable_range) using all_view RANGES_DEPRECATED( "Please use ranges::cpp20::views::all_t instead.") = ranges::views::all_t; diff --git a/include/range/v3/view/any_view.hpp b/include/range/v3/view/any_view.hpp index 13a2f87766..ee1655d273 100644 --- a/include/range/v3/view/any_view.hpp +++ b/include/range/v3/view/any_view.hpp @@ -414,10 +414,11 @@ namespace ranges public: any_cursor() = default; - template(typename Rng)( // - requires (!same_as, any_cursor>) AND // - forward_range AND // - any_compatible_range) // + template(typename Rng)( + /// \pre + requires (!same_as, any_cursor>) AND + forward_range AND + any_compatible_range) explicit any_cursor(Rng && rng) : ptr_{detail::make_unique>(begin(rng))} {} @@ -453,7 +454,8 @@ namespace ranges } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires (category::bidirectional == (Cat & category::bidirectional))) { RANGES_EXPECT(ptr_); @@ -461,7 +463,8 @@ namespace ranges } CPP_member auto advance(std::ptrdiff_t n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires (category::random_access == (Cat & category::random_access))) { RANGES_EXPECT(ptr_); @@ -469,7 +472,8 @@ namespace ranges } CPP_member auto distance_to(any_cursor const & that) const // - -> CPP_ret(std::ptrdiff_t)( // + -> CPP_ret(std::ptrdiff_t)( + /// \pre requires (category::random_access == (Cat & category::random_access))) { RANGES_EXPECT(!ptr_ == !that.ptr_); @@ -549,11 +553,12 @@ namespace ranges CPP_assert((Cat & category::forward) == category::forward); any_view() = default; - template(typename Rng)( // + template(typename Rng)( + /// \pre requires // - (!same_as, any_view>) AND // - input_range AND // - detail::any_compatible_range) // + (!same_as, any_view>) AND + input_range AND + detail::any_compatible_range) any_view(Rng && rng) : any_view(static_cast(rng), meta::bool_<(get_categories() & Cat) == Cat>{}) @@ -571,7 +576,8 @@ namespace ranges CPP_member auto size() // - -> CPP_ret(std::size_t)( // + -> CPP_ret(std::size_t)( + /// \pre requires (category::sized == (Cat & category::sized))) { return ptr_ ? ptr_->size() : 0; @@ -613,18 +619,20 @@ namespace ranges friend range_access; any_view() = default; - template(typename Rng)( // + template(typename Rng)( + /// \pre requires // - (!same_as, any_view>) AND // - input_range AND // - detail::any_compatible_range) // + (!same_as, any_view>) AND + input_range AND + detail::any_compatible_range) any_view(Rng && rng) : ptr_{std::make_shared>(views::all(static_cast(rng)))} {} CPP_member auto size() // - -> CPP_ret(std::size_t)( // + -> CPP_ret(std::size_t)( + /// \pre requires (category::sized == (Cat & category::sized))) { return ptr_ ? ptr_->size() : 0; @@ -651,8 +659,9 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng)( // - requires view_) // + template(typename Rng)( + /// \pre + requires view_) any_view(Rng &&) ->any_view, get_categories()>; #endif diff --git a/include/range/v3/view/c_str.hpp b/include/range/v3/view/c_str.hpp index d3b08977ec..070168052c 100644 --- a/include/range/v3/view/c_str.hpp +++ b/include/range/v3/view/c_str.hpp @@ -63,7 +63,8 @@ namespace ranges struct c_str_fn { // Fixed-length - template(typename Char, std::size_t N)( // + template(typename Char, std::size_t N)( + /// \pre requires detail::is_char_type::value) // ranges::subrange operator()(Char (&sz)[N]) const { @@ -71,7 +72,8 @@ namespace ranges } // Null-terminated - template(typename Char)( // + template(typename Char)( + /// \pre requires detail::is_char_type::value) // ranges::delimit_view< ranges::subrange, diff --git a/include/range/v3/view/cache1.hpp b/include/range/v3/view/cache1.hpp index 4736f91d7c..1fecc16a4d 100644 --- a/include/range/v3/view/cache1.hpp +++ b/include/range/v3/view/cache1.hpp @@ -45,7 +45,8 @@ namespace ranges CPP_member auto update_(range_reference_t && val) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires assignable_from &, range_reference_t>) { if(!cache_) @@ -55,7 +56,8 @@ namespace ranges } CPP_member auto update_(range_reference_t && val) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires (!assignable_from &, range_reference_t>)) { cache_.emplace(static_cast &&>(val)); @@ -117,14 +119,16 @@ namespace ranges } CPP_member auto distance_to(cursor const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires sized_sentinel_for, iterator_t>) { return that.current_ - current_; } CPP_member auto distance_to(sentinel const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires sized_sentinel_for, iterator_t>) { return that.last_ - current_; @@ -156,7 +160,9 @@ namespace ranges : rng_{std::move(rng)} {} CPP_member - constexpr auto CPP_fun(size)()(requires sized_range) + constexpr auto CPP_fun(size)()( + /// \pre + requires sized_range) { return ranges::size(rng_); } @@ -177,9 +183,10 @@ namespace ranges /// recomputation. This can be useful in adaptor pipelines that include /// combinations of \c view::filter and \c view::transform, for instance. /// \note \c views::cache1 is always single-pass. - template(typename Rng)( // - requires viewable_range AND input_range AND // - constructible_from, range_reference_t>) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range AND + constructible_from, range_reference_t>) constexpr cache1_view> operator()(Rng && rng) const // { return cache1_view>{all(static_cast(rng))}; diff --git a/include/range/v3/view/cartesian_product.hpp b/include/range/v3/view/cartesian_product.hpp index 4f4bef077e..c0acdf00e7 100644 --- a/include/range/v3/view/cartesian_product.hpp +++ b/include/range/v3/view/cartesian_product.hpp @@ -57,9 +57,10 @@ namespace ranges struct cartesian_size_fn { - template(typename Size, typename Rng)( // - requires integer_like_ AND sized_range AND // - common_with>) // + template(typename Size, typename Rng)( + /// \pre + requires integer_like_ AND sized_range AND + common_with>) common_type_t> operator()(Size s, Rng && rng) const { using S = common_type_t>; @@ -321,7 +322,8 @@ namespace ranges meta::bool_< common_range...>, 0>>>{}) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst_ AND CPP_NOT(Other)) // cursor(cursor that) : view_(that.view_) @@ -344,7 +346,8 @@ namespace ranges return equal_(that, meta::size_t{}); } CPP_member - auto prev() -> CPP_ret(void)( // + auto prev() -> CPP_ret(void)( + /// \pre requires cartesian_produce_view_can_bidi) { prev_(meta::size_t{}); @@ -357,7 +360,8 @@ namespace ranges } CPP_member auto advance(difference_type n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires cartesian_produce_view_can_random) { advance_(meta::size_t{}, n); @@ -369,28 +373,32 @@ namespace ranges } CPP_member auto begin_cursor() const // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires cartesian_produce_view_can_const) { return cursor{begin_tag{}, this}; } CPP_member auto end_cursor() // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires cartesian_produce_view_can_bidi) { return cursor{end_tag{}, this}; } CPP_member auto end_cursor() const // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires cartesian_produce_view_can_bidi) { return cursor{end_tag{}, this}; } CPP_member auto end_cursor() const // - -> CPP_ret(default_sentinel_t)( // + -> CPP_ret(default_sentinel_t)( + /// \pre requires (!cartesian_produce_view_can_bidi)) { return {}; @@ -401,7 +409,8 @@ namespace ranges constexpr explicit cartesian_product_view(Views... views) : views_{detail::move(views)...} {} - template(int = 42)( // + template(int = 42)( + /// \pre requires (my_cardinality >= 0)) // static constexpr std::size_t size() noexcept { @@ -415,8 +424,10 @@ namespace ranges return tuple_foldl(views_, std::uintmax_t{1}, detail::cartesian_size_fn{}); } CPP_member - auto CPP_fun(size)()(requires(my_cardinality < 0) && - cartesian_produce_view_can_size) + auto CPP_fun(size)()( + /// \pre + requires (my_cardinality < 0) && + cartesian_produce_view_can_size) { return tuple_foldl(views_, std::uintmax_t{1}, detail::cartesian_size_fn{}); } @@ -436,9 +447,10 @@ namespace ranges { return {}; } - template(typename... Rngs)( // - requires (sizeof...(Rngs) != 0) AND // - concepts::and_v<(forward_range && viewable_range)...>) // + template(typename... Rngs)( + /// \pre + requires (sizeof...(Rngs) != 0) AND + concepts::and_v<(forward_range && viewable_range)...>) constexpr cartesian_product_view...> operator()(Rngs &&... rngs) const { @@ -446,16 +458,18 @@ namespace ranges all(static_cast(rngs))...}; } #if defined(_MSC_VER) - template(typename Rng0)( // - requires forward_range AND viewable_range) // + template(typename Rng0)( + /// \pre + requires forward_range AND viewable_range) constexpr cartesian_product_view> operator()(Rng0 && rng0) const { return cartesian_product_view>{ all(static_cast(rng0))}; } - template(typename Rng0, typename Rng1)( // - requires forward_range AND viewable_range AND // - forward_range AND viewable_range) // + template(typename Rng0, typename Rng1)( + /// \pre + requires forward_range AND viewable_range AND + forward_range AND viewable_range) constexpr cartesian_product_view, all_t> // operator()(Rng0 && rng0, Rng1 && rng1) const { @@ -463,10 +477,11 @@ namespace ranges all(static_cast(rng0)), // all(static_cast(rng1))}; } - template(typename Rng0, typename Rng1, typename Rng2)( // - requires forward_range AND viewable_range AND // - forward_range AND viewable_range AND // - forward_range AND viewable_range) // + template(typename Rng0, typename Rng1, typename Rng2)( + /// \pre + requires forward_range AND viewable_range AND + forward_range AND viewable_range AND + forward_range AND viewable_range) constexpr cartesian_product_view, all_t, all_t> // operator()(Rng0 && rng0, Rng1 && rng1, Rng2 && rng2) const { diff --git a/include/range/v3/view/chunk.hpp b/include/range/v3/view/chunk.hpp index c54179ec48..5ef9b389f8 100644 --- a/include/range/v3/view/chunk.hpp +++ b/include/range/v3/view/chunk.hpp @@ -126,7 +126,8 @@ namespace ranges , n_((RANGES_EXPECT(0 < cv->n_), cv->n_)) , end_(ranges::end(cv->base())) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // constexpr adaptor(adaptor that) : box>(that.offset()) @@ -148,7 +149,8 @@ namespace ranges } CPP_member constexpr auto prev(iterator_t & it) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { ranges::advance(it, -n_ + offset()); @@ -158,7 +160,8 @@ namespace ranges constexpr auto distance_to(iterator_t const & here, iterator_t const & there, adaptor const & that) const - -> CPP_ret(range_difference_t)( // + -> CPP_ret(range_difference_t)( + /// \pre requires (detail::can_sized_sentinel_())) { auto const delta = (there - here) + (that.offset() - offset()); @@ -170,7 +173,8 @@ namespace ranges } CPP_member constexpr auto advance(iterator_t & it, range_difference_t n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires random_access_range) { using Limits = std::numeric_limits>; @@ -197,7 +201,8 @@ namespace ranges } CPP_member constexpr auto begin_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires forward_range) { return adaptor{this}; @@ -216,12 +221,16 @@ namespace ranges , n_((RANGES_EXPECT(0 < n), n)) {} CPP_member - constexpr auto CPP_fun(size)()(const requires sized_range) + constexpr auto CPP_fun(size)()(const + /// \pre + requires sized_range) { return size_(ranges::size(this->base())); } CPP_member - constexpr auto CPP_fun(size)()(requires sized_range) + constexpr auto CPP_fun(size)()( + /// \pre + requires sized_range) { return size_(ranges::size(this->base())); } @@ -293,7 +302,8 @@ namespace ranges } CPP_member constexpr auto distance_to(default_sentinel_t) const - -> CPP_ret(range_difference_t)( // + -> CPP_ret(range_difference_t)( + /// \pre requires sized_sentinel_for, iterator_t>) { RANGES_EXPECT(rng_); @@ -308,6 +318,7 @@ namespace ranges {} CPP_member constexpr auto CPP_fun(size)()( + /// \pre requires sized_sentinel_for, iterator_t>) { using size_type = detail::iter_size_t>; @@ -346,7 +357,8 @@ namespace ranges } CPP_member constexpr auto distance_to(default_sentinel_t) const - -> CPP_ret(range_difference_t)( // + -> CPP_ret(range_difference_t)( + /// \pre requires sized_sentinel_for, iterator_t>) { RANGES_EXPECT(rng_); @@ -382,12 +394,16 @@ namespace ranges , it_cache_{nullopt} {} CPP_member - constexpr auto CPP_fun(size)()(const requires sized_range) + constexpr auto CPP_fun(size)()(const + /// \pre + requires sized_range) { return size_(ranges::size(base_)); } CPP_member - constexpr auto CPP_fun(size)()(requires sized_range) + constexpr auto CPP_fun(size)()( + /// \pre + requires sized_range) { return size_(ranges::size(base_)); } @@ -413,7 +429,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - chunk_view(Rng &&, range_difference_t) // + chunk_view(Rng &&, range_difference_t) -> chunk_view>; #endif @@ -424,8 +440,9 @@ namespace ranges // The last range may have fewer. struct chunk_base_fn { - template(typename Rng)( // - requires viewable_range AND input_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range) constexpr chunk_view> // operator()(Rng && rng, range_difference_t n) const { @@ -437,7 +454,8 @@ namespace ranges { using chunk_base_fn::operator(); - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { diff --git a/include/range/v3/view/common.hpp b/include/range/v3/view/common.hpp index 0034028e17..fa4dbe7ab8 100644 --- a/include/range/v3/view/common.hpp +++ b/include/range/v3/view/common.hpp @@ -71,14 +71,16 @@ namespace ranges { return ranges::begin(rng_) + ranges::distance(rng_); } - template(bool Const = true)( // - requires Const AND range>) // + template(bool Const = true)( + /// \pre + requires Const AND range>) sentinel_t> end_(std::false_type) const { return ranges::end(rng_); } - template(bool Const = true)( // - requires Const AND range>) // + template(bool Const = true)( + /// \pre + requires Const AND range>) iterator_t> end_(std::true_type) const { return ranges::begin(rng_) + ranges::distance(rng_); @@ -104,21 +106,25 @@ namespace ranges end_(meta::bool_>{})}; } CPP_member - auto CPP_fun(size)()(requires sized_range) + auto CPP_fun(size)()( + /// \pre + requires sized_range) { return ranges::size(rng_); } - template(bool Const = true)( // - requires range>) // + template(bool Const = true)( + /// \pre + requires range>) auto begin() const -> detail::common_view_iterator_t> { return detail::common_view_iterator_t>{ ranges::begin(rng_)}; } - template(bool Const = true)( // - requires range>) // + template(bool Const = true)( + /// \pre + requires range>) auto end() const -> detail::common_view_iterator_t> { @@ -127,7 +133,9 @@ namespace ranges meta::const_if_c>>{})}; } CPP_member - auto CPP_fun(size)()(const requires sized_range) + auto CPP_fun(size)()(const + /// \pre + requires sized_range) { return ranges::size(rng_); } @@ -138,7 +146,8 @@ namespace ranges enable_borrowed_range; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng)( // + template(typename Rng)( + /// \pre requires (!common_range)) // common_view(Rng &&) ->common_view>; @@ -155,14 +164,16 @@ namespace ranges { struct cpp20_common_fn { - template(typename Rng)( // - requires viewable_range AND common_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND common_range) all_t operator()(Rng && rng) const { return all(static_cast(rng)); } - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND (!common_range)) // common_view> operator()(Rng && rng) const { @@ -172,8 +183,9 @@ namespace ranges struct common_fn { - template(typename Rng)( // - requires viewable_range) // + template(typename Rng)( + /// \pre + requires viewable_range) common_view> operator()(Rng && rng) const { return common_view>{all(static_cast(rng))}; @@ -217,7 +229,8 @@ namespace ranges RANGES_INLINE_VARIABLE( ranges::views::view_closure, common) } - template(typename Rng)( // + template(typename Rng)( + /// \pre requires view_ && (!common_range)) // using common_view = ranges::common_view; } // namespace cpp20 diff --git a/include/range/v3/view/concat.hpp b/include/range/v3/view/concat.hpp index 89aec79a3a..6b1e5c8a01 100644 --- a/include/range/v3/view/concat.hpp +++ b/include/range/v3/view/concat.hpp @@ -93,7 +93,8 @@ namespace ranges sentinel(concat_view_t * rng, end_tag) : end_(end(std::get(rng->rngs_))) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) // sentinel(sentinel that) : end_(std::move(that.end_)) @@ -130,8 +131,9 @@ namespace ranges struct next_fun { cursor * pos; - template(typename I, std::size_t N)( // - requires input_iterator) // + template(typename I, std::size_t N)( + /// \pre + requires input_iterator) void operator()(indexed_element it) const { RANGES_ASSERT(it.get() != end(std::get(pos->rng_->rngs_))); @@ -142,15 +144,17 @@ namespace ranges struct prev_fun { cursor * pos; - template(typename I)( // - requires bidirectional_iterator) // + template(typename I)( + /// \pre + requires bidirectional_iterator) void operator()(indexed_element it) const { RANGES_ASSERT(it.get() != begin(std::get<0>(pos->rng_->rngs_))); --it.get(); } - template(typename I, std::size_t N)( // - requires (N != 0) AND bidirectional_iterator) // + template(typename I, std::size_t N)( + /// \pre + requires (N != 0) AND bidirectional_iterator) void operator()(indexed_element it) const { if(it.get() == begin(std::get(pos->rng_->rngs_))) @@ -169,14 +173,16 @@ namespace ranges { cursor * pos; difference_type n; - template(typename I)( // - requires random_access_iterator) // + template(typename I)( + /// \pre + requires random_access_iterator) void operator()(indexed_element it) const { ranges::advance(it.get(), n); } - template(typename I, std::size_t N)( // - requires random_access_iterator) // + template(typename I, std::size_t N)( + /// \pre + requires random_access_iterator) void operator()(indexed_element it) const { auto last = ranges::end(std::get(pos->rng_->rngs_)); @@ -194,14 +200,16 @@ namespace ranges { cursor * pos; difference_type n; - template(typename I)( // - requires random_access_iterator) // + template(typename I)( + /// \pre + requires random_access_iterator) void operator()(indexed_element it) const { ranges::advance(it.get(), n); } - template(typename I, std::size_t N)( // - requires random_access_iterator) // + template(typename I, std::size_t N)( + /// \pre + requires random_access_iterator) void operator()(indexed_element it) const { auto first = ranges::begin(std::get(pos->rng_->rngs_)); @@ -265,7 +273,8 @@ namespace ranges : rng_(rng) , its_{emplaced_index, end(std::get(rng->rngs_))} {} - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst && CPP_NOT(Other)) // cursor(cursor that) : rng_(that.rng_) @@ -283,7 +292,8 @@ namespace ranges } CPP_member auto equal(cursor const & pos) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires // equality_comparable>...>>) { @@ -296,14 +306,16 @@ namespace ranges } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires and_v...>) { its_.visit_i(prev_fun{this}); } CPP_member auto advance(difference_type n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires and_v...>) { if(n > 0) @@ -313,7 +325,8 @@ namespace ranges } CPP_member auto distance_to(cursor const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires and_v, iterator_t>...>) { @@ -335,7 +348,8 @@ namespace ranges } CPP_member auto begin_cursor() const // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires and_v...>) { return {this, begin_tag{}}; @@ -345,7 +359,8 @@ namespace ranges -> CPP_ret( meta::if_...>, // cursor, // - sentinel>)( // + sentinel>)( + /// \pre requires and_v...>) { return {this, end_tag{}}; @@ -358,7 +373,8 @@ namespace ranges {} CPP_member constexpr auto size() const // - -> CPP_ret(std::size_t)( // + -> CPP_ret(std::size_t)( + /// \pre requires (detail::concat_cardinality::value >= 0)) { return static_cast(detail::concat_cardinality::value); @@ -377,6 +393,7 @@ namespace ranges } CPP_member constexpr auto CPP_fun(size)()( + /// \pre requires (detail::concat_cardinality::value < 0) && and_v...>) { @@ -399,23 +416,26 @@ namespace ranges { struct concat_fn { - template(typename... Rngs)( // - requires and_v<(viewable_range && input_range)...>) // + template(typename... Rngs)( + /// \pre + requires and_v<(viewable_range && input_range)...>) concat_view...> operator()(Rngs &&... rngs) const { return concat_view...>{all(static_cast(rngs))...}; } - template(typename Rng)( // - requires viewable_range AND input_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range) all_t operator()(Rng && rng) const // { return all(static_cast(rng)); } // MSVC doesn't like variadics in operator() for some reason #if defined(_MSC_VER) - template(typename Rng0, typename Rng1)( // - requires viewable_range AND input_range AND // - viewable_range AND input_range) // + template(typename Rng0, typename Rng1)( + /// \pre + requires viewable_range AND input_range AND + viewable_range AND input_range) concat_view, all_t> operator()(Rng0 && rng0, Rng1 && rng1) const { @@ -423,10 +443,11 @@ namespace ranges all(static_cast(rng0)), all(static_cast(rng1))}; } - template(typename Rng0, typename Rng1, typename Rng2)( // - requires viewable_range AND input_range AND // - viewable_range AND input_range AND // - viewable_range AND input_range) // + template(typename Rng0, typename Rng1, typename Rng2)( + /// \pre + requires viewable_range AND input_range AND + viewable_range AND input_range AND + viewable_range AND input_range) concat_view, all_t, all_t> // operator()(Rng0 && rng0, Rng1 && rng1, Rng2 && rng2) const { diff --git a/include/range/v3/view/const.hpp b/include/range/v3/view/const.hpp index 85cd1865d8..af18e50985 100644 --- a/include/range/v3/view/const.hpp +++ b/include/range/v3/view/const.hpp @@ -50,7 +50,8 @@ namespace ranges using rvalue_reference_ = common_reference_t>; adaptor() = default; - template(bool Other)( // + template(bool Other)( + /// \pre requires Const && CPP_NOT(Other)) // constexpr adaptor(adaptor) {} @@ -70,7 +71,8 @@ namespace ranges } CPP_member auto begin_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires range) { return {}; @@ -81,7 +83,8 @@ namespace ranges } CPP_member auto end_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires range) { return {}; @@ -93,12 +96,16 @@ namespace ranges : const_view::view_adaptor{std::move(rng)} {} CPP_member - constexpr auto CPP_fun(size)()(requires sized_range) + constexpr auto CPP_fun(size)()( + /// \pre + requires sized_range) { return ranges::size(this->base()); } CPP_member - constexpr auto CPP_fun(size)()(const requires sized_range) + constexpr auto CPP_fun(size)()(const + /// \pre + requires sized_range) { return ranges::size(this->base()); } @@ -118,8 +125,9 @@ namespace ranges { struct const_fn { - template(typename Rng)( // - requires viewable_range AND input_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range) const_view> operator()(Rng && rng) const { return const_view>{all(static_cast(rng))}; diff --git a/include/range/v3/view/counted.hpp b/include/range/v3/view/counted.hpp index 26fcd9e38b..380dd3489f 100644 --- a/include/range/v3/view/counted.hpp +++ b/include/range/v3/view/counted.hpp @@ -66,7 +66,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - counted_view(I, iter_difference_t) // + counted_view(I, iter_difference_t) -> counted_view; #endif @@ -74,15 +74,17 @@ namespace ranges { struct cpp20_counted_fn { - template(typename I)( // + template(typename I)( + /// \pre requires input_or_output_iterator AND (!random_access_iterator)) // subrange, default_sentinel_t> // operator()(I it, iter_difference_t n) const { return {make_counted_iterator(std::move(it), n), default_sentinel}; } - template(typename I)( // - requires random_access_iterator) // + template(typename I)( + /// \pre + requires random_access_iterator) subrange operator()(I it, iter_difference_t n) const { return {it, it + n}; @@ -91,14 +93,16 @@ namespace ranges struct counted_fn { - template(typename I)( // + template(typename I)( + /// \pre requires input_or_output_iterator AND (!random_access_iterator)) // counted_view operator()(I it, iter_difference_t n) const { return {std::move(it), n}; } - template(typename I)( // - requires random_access_iterator) // + template(typename I)( + /// \pre + requires random_access_iterator) subrange operator()(I it, iter_difference_t n) const { return {it, it + n}; diff --git a/include/range/v3/view/cycle.hpp b/include/range/v3/view/cycle.hpp index a7e990331b..10c167131d 100644 --- a/include/range/v3/view/cycle.hpp +++ b/include/range/v3/view/cycle.hpp @@ -100,7 +100,8 @@ namespace ranges : rng_(rng) , it_(ranges::begin(rng->rng_)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) // cursor(cursor that) : rng_(that.rng_) @@ -114,7 +115,8 @@ namespace ranges // clang-format on CPP_member auto equal(cursor const & pos) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires equality_comparable) { RANGES_EXPECT(rng_ == pos.rng_); @@ -133,7 +135,8 @@ namespace ranges } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { if(it_ == ranges::begin(rng_->rng_)) @@ -144,7 +147,8 @@ namespace ranges } --it_; } - template(typename Diff)( // + template(typename Diff)( + /// \pre requires random_access_range AND detail::integer_like_) void advance(Diff n) { @@ -174,14 +178,16 @@ namespace ranges CPP_member auto begin_cursor() // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires (!simple_view() || !common_range)) { return {this}; } CPP_member auto begin_cursor() const // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires common_range) { return {this}; @@ -221,8 +227,9 @@ namespace ranges struct cycle_fn { /// \pre !empty(rng) - template(typename Rng)( // - requires viewable_range AND forward_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND forward_range) cycled_view> operator()(Rng && rng) const { return cycled_view>{all(static_cast(rng))}; diff --git a/include/range/v3/view/delimit.hpp b/include/range/v3/view/delimit.hpp index bdbed01609..56bb9abede 100644 --- a/include/range/v3/view/delimit.hpp +++ b/include/range/v3/view/delimit.hpp @@ -77,7 +77,8 @@ namespace ranges enable_borrowed_range; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Val)( // + template(typename Rng, typename Val)( + /// \pre requires copy_constructible) delimit_view(Rng &&, Val) -> delimit_view, Val>; @@ -87,19 +88,21 @@ namespace ranges { struct delimit_base_fn { - template(typename I_, typename Val, typename I = detail::decay_t)( // + template(typename I_, typename Val, typename I = detail::decay_t)( + /// \pre requires (!range) AND convertible_to AND input_iterator AND - semiregular AND // - equality_comparable_with>) // + semiregular AND + equality_comparable_with>) constexpr auto operator()(I_ && begin_, Val value) const -> delimit_view, Val> { return {{static_cast(begin_), {}}, std::move(value)}; } - template(typename Rng, typename Val)( // + template(typename Rng, typename Val)( + /// \pre requires viewable_range AND input_range AND semiregular< - Val> AND equality_comparable_with>) // + Val> AND equality_comparable_with>) constexpr auto operator()(Rng && rng, Val value) const // -> delimit_view, Val> { diff --git a/include/range/v3/view/drop.hpp b/include/range/v3/view/drop.hpp index bf483bac43..691f6a41ec 100644 --- a/include/range/v3/view/drop.hpp +++ b/include/range/v3/view/drop.hpp @@ -52,8 +52,9 @@ namespace ranges Rng rng_; difference_type_ n_; - template(bool Const = true)( // - requires Const AND range>) // + template(bool Const = true)( + /// \pre + requires Const AND range>) iterator_t> // get_begin_(std::true_type, std::true_type) const { @@ -93,14 +94,16 @@ namespace ranges { return ranges::end(rng_); } - template(bool Const = true)( // - requires Const AND random_access_range>) // + template(bool Const = true)( + /// \pre + requires Const AND random_access_range>) iterator_t> begin() const { return this->get_begin_(std::true_type{}, std::true_type{}); } - template(bool Const = true)( // - requires Const AND random_access_range>) // + template(bool Const = true)( + /// \pre + requires Const AND random_access_range>) sentinel_t> end() const { return ranges::end(rng_); @@ -114,7 +117,8 @@ namespace ranges return s < n ? 0 : s - n; } CPP_member - auto CPP_fun(size)()( // + auto CPP_fun(size)()( + /// \pre requires sized_range) { auto const s = ranges::size(rng_); @@ -133,7 +137,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - drop_view(Rng &&, range_difference_t) // + drop_view(Rng &&, range_difference_t) -> drop_view>; #endif @@ -148,8 +152,9 @@ namespace ranges { return {all(static_cast(rng)), n}; } - template(typename Rng)( // - requires borrowed_range AND sized_range) // + template(typename Rng)( + /// \pre + requires borrowed_range AND sized_range) static subrange, sentinel_t> // impl_(Rng && rng, range_difference_t n, random_access_range_tag) { @@ -157,7 +162,8 @@ namespace ranges } public: - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range) auto operator()(Rng && rng, range_difference_t n) const { @@ -170,7 +176,8 @@ namespace ranges { using drop_base_fn::operator(); - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { @@ -189,8 +196,9 @@ namespace ranges { using ranges::views::drop; } - template(typename Rng)( // - requires view_) // + template(typename Rng)( + /// \pre + requires view_) using drop_view = ranges::drop_view; } // namespace cpp20 /// @} diff --git a/include/range/v3/view/drop_exactly.hpp b/include/range/v3/view/drop_exactly.hpp index 740d2fb0e3..7f1d7b2396 100644 --- a/include/range/v3/view/drop_exactly.hpp +++ b/include/range/v3/view/drop_exactly.hpp @@ -52,8 +52,9 @@ namespace ranges difference_type_ n_; // random_access_range == true - template(bool Const = true)( // - requires Const AND random_access_range>) // + template(bool Const = true)( + /// \pre + requires Const AND random_access_range>) iterator_t> get_begin_(std::true_type) const { return next(ranges::begin(rng_), n_); @@ -89,25 +90,31 @@ namespace ranges { return ranges::end(rng_); } - template(bool Const = true)( // - requires Const AND random_access_range>) // + template(bool Const = true)( + /// \pre + requires Const AND random_access_range>) iterator_t> begin() const { return this->get_begin_(std::true_type{}); } - template(bool Const = true)( // - requires Const AND random_access_range>) // + template(bool Const = true)( + /// \pre + requires Const AND random_access_range>) sentinel_t> end() const { return ranges::end(rng_); } CPP_member - auto CPP_fun(size)()(const requires sized_range) + auto CPP_fun(size)()(const + /// \pre + requires sized_range) { return ranges::size(rng_) - static_cast>(n_); } CPP_member - auto CPP_fun(size)()(requires sized_range) + auto CPP_fun(size)()( + /// \pre + requires sized_range) { return ranges::size(rng_) - static_cast>(n_); } @@ -138,8 +145,9 @@ namespace ranges { return {all(static_cast(rng)), n}; } - template(typename Rng)( // - requires borrowed_range) // + template(typename Rng)( + /// \pre + requires borrowed_range) static subrange, sentinel_t> // impl_(Rng && rng, range_difference_t n, random_access_range_tag) { @@ -147,7 +155,8 @@ namespace ranges } public: - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range) auto operator()(Rng && rng, range_difference_t n) const { @@ -160,7 +169,8 @@ namespace ranges { using drop_exactly_base_fn::operator(); - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { diff --git a/include/range/v3/view/drop_last.hpp b/include/range/v3/view/drop_last.hpp index 441d71c792..efb9cbb9d8 100644 --- a/include/range/v3/view/drop_last.hpp +++ b/include/range/v3/view/drop_last.hpp @@ -54,15 +54,17 @@ namespace ranges return initial_size > n ? initial_size - n : 0; } - template(typename Rng)( // - requires random_access_range AND sized_range) // + template(typename Rng)( + /// \pre + requires random_access_range AND sized_range) iterator_t get_end(Rng & rng, range_difference_t n, int) { return begin(rng) + static_cast>( drop_last_view::get_size(rng, n)); } - template(typename Rng)( // - requires bidirectional_range AND common_range) // + template(typename Rng)( + /// \pre + requires bidirectional_range AND common_range) iterator_t get_end(Rng & rng, range_difference_t n, long) { return prev(end(rng), n, begin(rng)); @@ -158,21 +160,24 @@ namespace ranges end_ = detail::drop_last_view::get_end(rng_, n_, 0); return *end_; } - template(typename CRng = Rng const)( // - requires random_access_range AND sized_range) // + template(typename CRng = Rng const)( + /// \pre + requires random_access_range AND sized_range) iterator_t begin() const { return ranges::begin(rng_); } - template(typename CRng = Rng const)( // - requires random_access_range AND sized_range) // + template(typename CRng = Rng const)( + /// \pre + requires random_access_range AND sized_range) iterator_t end() const { return detail::drop_last_view::get_end(rng_, n_, 0); } CPP_member - auto CPP_fun(size)()( // + auto CPP_fun(size)()( + /// \pre requires sized_range) { return detail::drop_last_view::get_size(rng_, n_); @@ -256,7 +261,8 @@ namespace ranges } CPP_member - auto CPP_fun(size)()( // + auto CPP_fun(size)()( + /// \pre requires sized_range) { return detail::drop_last_view::get_size(this->base(), n_); @@ -295,8 +301,9 @@ namespace ranges { return {ranges::begin(rng_), static_cast(size())}; } - template(typename CRng = Rng const)( // - requires sized_range) // + template(typename CRng = Rng const)( + /// \pre + requires sized_range) counted_iterator> begin() const { return {ranges::begin(rng_), static_cast(size())}; @@ -332,7 +339,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - drop_last_view(Rng &&, range_difference_t) // + drop_last_view(Rng &&, range_difference_t) -> drop_last_view>; #endif @@ -340,8 +347,9 @@ namespace ranges { struct drop_last_base_fn { - template(typename Rng)( // - requires sized_range || forward_range) // + template(typename Rng)( + /// \pre + requires sized_range || forward_range) constexpr auto operator()(Rng && rng, range_difference_t n) const -> drop_last_view> { @@ -353,7 +361,8 @@ namespace ranges { using drop_last_base_fn::operator(); - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { diff --git a/include/range/v3/view/drop_while.hpp b/include/range/v3/view/drop_while.hpp index 8d98a59ec9..3b06e8c052 100644 --- a/include/range/v3/view/drop_while.hpp +++ b/include/range/v3/view/drop_while.hpp @@ -82,7 +82,8 @@ namespace ranges enable_borrowed_range; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires copy_constructible) drop_while_view(Rng &&, Fun) -> drop_while_view, Fun>; @@ -96,17 +97,19 @@ namespace ranges { struct drop_while_base_fn { - template(typename Rng, typename Pred)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate>) // + template(typename Rng, typename Pred)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate>) auto operator()(Rng && rng, Pred pred) const -> drop_while_view, Pred> { return {all(static_cast(rng)), std::move(pred)}; } - template(typename Rng, typename Pred, typename Proj)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate, iterator_t>) // + template(typename Rng, typename Pred, typename Proj)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate, iterator_t>) auto operator()(Rng && rng, Pred pred, Proj proj) const -> drop_while_view, composed> { @@ -123,7 +126,8 @@ namespace ranges return make_view_closure( bind_back(drop_while_base_fn{}, std::move(pred))); } - template(typename Pred, typename Proj)( // + template(typename Pred, typename Proj)( + /// \pre requires (!range)) // TODO: underconstrained constexpr auto operator()(Pred && pred, Proj proj) const { @@ -150,9 +154,10 @@ namespace ranges { using ranges::views::drop_while; } - template(typename Rng, typename Pred)( // + template(typename Rng, typename Pred)( + /// \pre requires viewable_range AND input_range AND - indirect_unary_predicate>) // + indirect_unary_predicate>) using drop_while_view = ranges::drop_while_view; } // namespace cpp20 /// @} diff --git a/include/range/v3/view/empty.hpp b/include/range/v3/view/empty.hpp index 9960a55a6b..f1e6dab400 100644 --- a/include/range/v3/view/empty.hpp +++ b/include/range/v3/view/empty.hpp @@ -70,7 +70,8 @@ namespace ranges { using ranges::views::empty; } - template(typename T)( // + template(typename T)( + /// \pre requires std::is_object::value) // using empty_view = ranges::empty_view; } // namespace cpp20 diff --git a/include/range/v3/view/enumerate.hpp b/include/range/v3/view/enumerate.hpp index 9f34423b92..8a88a78eed 100644 --- a/include/range/v3/view/enumerate.hpp +++ b/include/range/v3/view/enumerate.hpp @@ -95,7 +95,8 @@ namespace ranges /// its corresponding index. struct enumerate_fn { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range) auto operator()(Rng && rng) const { diff --git a/include/range/v3/view/exclusive_scan.hpp b/include/range/v3/view/exclusive_scan.hpp index 629a6f2148..f7950f2cb3 100644 --- a/include/range/v3/view/exclusive_scan.hpp +++ b/include/range/v3/view/exclusive_scan.hpp @@ -82,7 +82,8 @@ namespace ranges adaptor(exclusive_scan_view_t * rng) : rng_(rng) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) // adaptor(adaptor that) : rng_(that.rng_) @@ -115,14 +116,16 @@ namespace ranges } CPP_member auto begin_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires exclusive_scan_constraints) { return {this}; } CPP_member auto end_adaptor() const - -> CPP_ret(meta::if_>)( // + -> CPP_ret(meta::if_>)( + /// \pre requires exclusive_scan_constraints) { return {this}; @@ -136,21 +139,24 @@ namespace ranges , fun_(std::move(fun)) {} CPP_member - auto CPP_fun(size)()(const // + auto CPP_fun(size)()(const + /// \pre requires sized_range) { return ranges::size(this->base()); } CPP_member - auto CPP_fun(size)()(requires // - sized_range) + auto CPP_fun(size)()( + /// \pre + requires sized_range) { return ranges::size(this->base()); } }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename T, typename Fun)( // + template(typename Rng, typename T, typename Fun)( + /// \pre requires copy_constructible AND copy_constructible) exclusive_scan_view(Rng &&, T, Fun) // -> exclusive_scan_view, T, Fun>; @@ -160,8 +166,9 @@ namespace ranges { struct exclusive_scan_base_fn { - template(typename Rng, typename T, typename Fun = plus)( // - requires exclusive_scan_constraints) // + template(typename Rng, typename T, typename Fun = plus)( + /// \pre + requires exclusive_scan_constraints) constexpr exclusive_scan_view, T, Fun> // operator()(Rng && rng, T init, Fun fun = Fun{}) const { diff --git a/include/range/v3/view/facade.hpp b/include/range/v3/view/facade.hpp index 03c1f0656c..597c899c37 100644 --- a/include/range/v3/view/facade.hpp +++ b/include/range/v3/view/facade.hpp @@ -91,16 +91,18 @@ namespace ranges /// otherwise, let `b` be `d.begin_cursor()`. Let `B` be the type of /// `b`. /// \return `ranges::basic_iterator(b)` - template(typename D = Derived)( // - requires same_as) // + template(typename D = Derived)( + /// \pre + requires same_as) constexpr auto begin() -> detail::facade_iterator_t { return detail::facade_iterator_t{ range_access::begin_cursor(*static_cast(this))}; } /// \overload - template(typename D = Derived)( // - requires same_as) // + template(typename D = Derived)( + /// \pre + requires same_as) constexpr auto begin() const -> detail::facade_iterator_t { return detail::facade_iterator_t{ @@ -112,16 +114,18 @@ namespace ranges /// `e`. /// \return `ranges::basic_iterator(e)` if `E` is the same /// as `B` computed above for `begin()`; otherwise, return `e`. - template(typename D = Derived)( // - requires same_as) // + template(typename D = Derived)( + /// \pre + requires same_as) constexpr auto end() -> detail::facade_sentinel_t { return static_cast>( range_access::end_cursor(*static_cast(this))); } /// \overload - template(typename D = Derived)( // - requires same_as) // + template(typename D = Derived)( + /// \pre + requires same_as) constexpr auto end() const -> detail::facade_sentinel_t { return static_cast>( diff --git a/include/range/v3/view/filter.hpp b/include/range/v3/view/filter.hpp index 4ea05b129f..e7a712dc74 100644 --- a/include/range/v3/view/filter.hpp +++ b/include/range/v3/view/filter.hpp @@ -38,7 +38,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Pred)( // + template(typename Rng, typename Pred)( + /// \pre requires input_range AND indirect_unary_predicate> AND view_ AND std::is_object::value) // filter_view(Rng &&, Pred) @@ -53,9 +54,10 @@ namespace ranges /// present a view of the elements that satisfy the predicate. struct cpp20_filter_base_fn { - template(typename Rng, typename Pred)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate>) // + template(typename Rng, typename Pred)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate>) constexpr filter_view, Pred> operator()(Rng && rng, Pred pred) // const { @@ -82,9 +84,10 @@ namespace ranges { using cpp20_filter_base_fn::operator(); - template(typename Rng, typename Pred, typename Proj)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate, Proj>>) // + template(typename Rng, typename Pred, typename Proj)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate, Proj>>) constexpr filter_view, composed> // operator()(Rng && rng, Pred pred, Proj proj) const { @@ -104,7 +107,8 @@ namespace ranges return make_view_closure(bind_back(filter_base_fn{}, std::move(pred))); } - template(typename Pred, typename Proj)( // + template(typename Pred, typename Proj)( + /// \pre requires (!range)) constexpr auto operator()(Pred pred, Proj proj) const { @@ -124,7 +128,8 @@ namespace ranges { RANGES_INLINE_VARIABLE(ranges::views::cpp20_filter_fn, filter) } - template(typename V, typename Pred)( // + template(typename V, typename Pred)( + /// \pre requires input_range AND indirect_unary_predicate> AND view_ AND std::is_object::value) // using filter_view = ranges::filter_view; diff --git a/include/range/v3/view/for_each.hpp b/include/range/v3/view/for_each.hpp index ca7d687e78..5ddf43e8a7 100644 --- a/include/range/v3/view/for_each.hpp +++ b/include/range/v3/view/for_each.hpp @@ -42,7 +42,8 @@ namespace ranges /// the result. struct for_each_base_fn { - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires viewable_range AND transformable_range AND joinable_range, Fun>>) constexpr auto operator()(Rng && rng, Fun fun) const @@ -69,8 +70,9 @@ namespace ranges struct yield_fn { - template(typename V)( // - requires copy_constructible) // + template(typename V)( + /// \pre + requires copy_constructible) single_view operator()(V v) const { return views::single(std::move(v)); @@ -83,8 +85,9 @@ namespace ranges struct yield_from_fn { - template(typename Rng)( // - requires view_) // + template(typename Rng)( + /// \pre + requires view_) Rng operator()(Rng rng) const { return rng; @@ -110,8 +113,9 @@ namespace ranges struct lazy_yield_if_fn { - template(typename F)( // - requires invocable) // + template(typename F)( + /// \pre + requires invocable) generate_n_view operator()(bool b, F f) const { return views::generate_n(std::move(f), b ? 1 : 0); @@ -124,9 +128,10 @@ namespace ranges /// @} /// \cond - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires viewable_range AND views::transformable_range AND - input_range>>) // + input_range>>) auto operator>>=(Rng && rng, Fun fun) { diff --git a/include/range/v3/view/generate.hpp b/include/range/v3/view/generate.hpp index 1d869a7ee9..22040e9432 100644 --- a/include/range/v3/view/generate.hpp +++ b/include/range/v3/view/generate.hpp @@ -93,13 +93,14 @@ namespace ranges { struct generate_fn { - template(typename G)( // + template(typename G)( + /// \pre requires invocable AND copy_constructible AND std::is_object>>::value AND constructible_from>, invoke_result_t> AND assignable_from> &, - invoke_result_t>) // + invoke_result_t>) generate_view operator()(G g) const { return generate_view{std::move(g)}; diff --git a/include/range/v3/view/generate_n.hpp b/include/range/v3/view/generate_n.hpp index 41924caf2a..237913140d 100644 --- a/include/range/v3/view/generate_n.hpp +++ b/include/range/v3/view/generate_n.hpp @@ -100,13 +100,14 @@ namespace ranges { struct generate_n_fn { - template(typename G)( // + template(typename G)( + /// \pre requires invocable AND copy_constructible AND std::is_object>>::value AND constructible_from>, invoke_result_t> AND assignable_from> &, - invoke_result_t>) // + invoke_result_t>) generate_n_view operator()(G g, std::size_t n) const { return generate_n_view{std::move(g), n}; diff --git a/include/range/v3/view/group_by.hpp b/include/range/v3/view/group_by.hpp index c579127f9d..4c2af2925a 100644 --- a/include/range/v3/view/group_by.hpp +++ b/include/range/v3/view/group_by.hpp @@ -160,8 +160,9 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // - requires copy_constructible) // + template(typename Rng, typename Fun)( + /// \pre + requires copy_constructible) group_by_view(Rng &&, Fun) ->group_by_view, Fun>; #endif @@ -170,9 +171,10 @@ namespace ranges { struct group_by_base_fn { - template(typename Rng, typename Fun)( // - requires viewable_range AND forward_range AND // - indirect_relation>) // + template(typename Rng, typename Fun)( + /// \pre + requires viewable_range AND forward_range AND + indirect_relation>) constexpr group_by_view, Fun> operator()(Rng && rng, Fun fun) const { return {all(static_cast(rng)), std::move(fun)}; diff --git a/include/range/v3/view/indices.hpp b/include/range/v3/view/indices.hpp index c09876bd52..7c5dda72c4 100644 --- a/include/range/v3/view/indices.hpp +++ b/include/range/v3/view/indices.hpp @@ -34,14 +34,16 @@ namespace ranges { indices_fn() = default; - template(typename Val)( // - requires integral) // + template(typename Val)( + /// \pre + requires integral) iota_view operator()(Val to) const { return {Val(), to}; } - template(typename Val)( // - requires integral) // + template(typename Val)( + /// \pre + requires integral) iota_view operator()(Val from, Val to) const { return {from, to}; @@ -51,14 +53,16 @@ namespace ranges /// Inclusive range of indices: [from, to]. struct closed_indices_fn { - template(typename Val)( // - requires integral) // + template(typename Val)( + /// \pre + requires integral) closed_iota_view operator()(Val to) const { return {Val(), to}; } - template(typename Val)( // - requires integral) // + template(typename Val)( + /// \pre + requires integral) closed_iota_view operator()(Val from, Val to) const { return {from, to}; diff --git a/include/range/v3/view/indirect.hpp b/include/range/v3/view/indirect.hpp index fc66db180e..4c7484ad66 100644 --- a/include/range/v3/view/indirect.hpp +++ b/include/range/v3/view/indirect.hpp @@ -48,7 +48,8 @@ namespace ranges using CRng = meta::const_if_c; adaptor() = default; - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst && CPP_NOT(Other)) // constexpr adaptor(adaptor) noexcept {} @@ -67,14 +68,16 @@ namespace ranges CPP_member constexpr auto begin_adaptor() noexcept // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires (!simple_view())) { return {}; } CPP_member constexpr auto begin_adaptor() const noexcept // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires range) { return {}; @@ -82,14 +85,16 @@ namespace ranges CPP_member constexpr auto end_adaptor() noexcept // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires (!simple_view())) { return {}; } CPP_member constexpr auto end_adaptor() const noexcept // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires range) { return {}; @@ -107,7 +112,8 @@ namespace ranges return ranges::size(this->base()); } CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires sized_range) { return ranges::size(this->base()); @@ -128,7 +134,8 @@ namespace ranges { struct indirect_fn { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range AND // We shouldn't need to strip references to test if something // is readable. https://github.com/ericniebler/stl2/issues/594 diff --git a/include/range/v3/view/interface.hpp b/include/range/v3/view/interface.hpp index 9e8d2fa082..8e947e0590 100644 --- a/include/range/v3/view/interface.hpp +++ b/include/range/v3/view/interface.hpp @@ -46,8 +46,9 @@ namespace ranges { From from; To to; - template(typename F, typename T)( // - requires convertible_to AND convertible_to) // + template(typename F, typename T)( + /// \pre + requires convertible_to AND convertible_to) constexpr slice_bounds(F f, T t) : from(static_cast(f)) , to(static_cast(t)) @@ -63,7 +64,8 @@ namespace ranges : dist_(dist) {} - template(typename Other)( // + template(typename Other)( + /// \pre requires integer_like_ AND explicitly_convertible_to) constexpr operator from_end_() const { @@ -148,33 +150,37 @@ namespace ranges // A few ways of testing whether a range can be empty: CPP_member constexpr auto empty() const noexcept // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires (detail::has_fixed_size_)) { return Cardinality == 0; } /// \overload - template(bool True = true)( // + template(bool True = true)( + /// \pre requires True AND (Cardinality < 0) AND (Cardinality != infinite) AND - (!forward_range>)&&sized_range>) // + (!forward_range>)&&sized_range>) constexpr bool empty() // noexcept(noexcept(bool(ranges::size(std::declval &>()) == 0))) { return ranges::size(derived()) == 0; } /// \overload - template(bool True = true)( // + template(bool True = true)( + /// \pre requires True AND (Cardinality < 0) AND (Cardinality != infinite) AND - (!forward_range const>)&&sized_range const>) // + (!forward_range const>)&&sized_range const>) constexpr bool empty() const // noexcept(noexcept(bool(ranges::size(std::declval const &>()) == 0))) { return ranges::size(derived()) == 0; } /// \overload - template(bool True = true)( // + template(bool True = true)( + /// \pre requires True AND (!detail::has_fixed_size_) AND - forward_range>) // + forward_range>) constexpr bool empty() noexcept( noexcept(bool(ranges::begin(std::declval &>()) == ranges::end(std::declval &>())))) @@ -182,16 +188,18 @@ namespace ranges return bool(ranges::begin(derived()) == ranges::end(derived())); } /// \overload - template(bool True = true)( // + template(bool True = true)( + /// \pre requires True AND (!detail::has_fixed_size_) AND - forward_range const>) // + forward_range const>) constexpr bool empty() const noexcept(noexcept(bool(ranges::begin(std::declval const &>()) == ranges::end(std::declval const &>())))) { return bool(ranges::begin(derived()) == ranges::end(derived())); } - CPP_template_gcc_workaround(bool True = true)( // + CPP_template_gcc_workaround(bool True = true)( + /// \pre requires True && detail::can_empty_>) // clang-format off constexpr explicit operator bool() noexcept(noexcept(ranges::empty(std::declval &>()))) @@ -200,7 +208,8 @@ namespace ranges } // clang-format on /// \overload - CPP_template_gcc_workaround(bool True = true)( // + CPP_template_gcc_workaround(bool True = true)( + /// \pre requires True && detail::can_empty_ const>) // clang-format off constexpr explicit operator bool() const noexcept(noexcept(ranges::empty(std::declval const &>()))) @@ -210,7 +219,8 @@ namespace ranges // clang-format on /// If the size of the range is known at compile-time and finite, /// return it. - template(bool True = true, int = 42)( // + template(bool True = true, int = 42)( + /// \pre requires True AND (Cardinality >= 0)) // static constexpr std::size_t size() noexcept { @@ -219,65 +229,73 @@ namespace ranges /// If `sized_sentinel_for, iterator_t>` is /// satisfied, and if `Derived` is a `forward_range`, then return /// `end - begin` cast to an unsigned integer. - template(bool True = true)( // + template(bool True = true)( + /// \pre requires True AND (Cardinality < 0) AND sized_sentinel_for>, iterator_t>> AND - forward_range>) // + forward_range>) constexpr detail::iter_size_t>> size() { using size_type = detail::iter_size_t>>; return static_cast(derived().end() - derived().begin()); } /// \overload - template(bool True = true)( // + template(bool True = true)( + /// \pre requires True AND (Cardinality < 0) AND sized_sentinel_for const>, iterator_t const>> AND - forward_range const>) // + forward_range const>) constexpr detail::iter_size_t>> size() const // { using size_type = detail::iter_size_t>>; return static_cast(derived().end() - derived().begin()); } /// Access the first element in a range: - template(bool True = true)( // - requires True AND forward_range>) // + template(bool True = true)( + /// \pre + requires True AND forward_range>) constexpr range_reference_t> front() { return *derived().begin(); } /// \overload - template(bool True = true)( // - requires True AND forward_range const>) // + template(bool True = true)( + /// \pre + requires True AND forward_range const>) constexpr range_reference_t const> front() const { return *derived().begin(); } /// Access the last element in a range: - template(bool True = true)( // - requires True AND common_range> AND bidirectional_range>) // + template(bool True = true)( + /// \pre + requires True AND common_range> AND bidirectional_range>) constexpr range_reference_t> back() { return *prev(derived().end()); } /// \overload - template(bool True = true)( // + template(bool True = true)( + /// \pre requires True AND common_range const> AND - bidirectional_range const>) // + bidirectional_range const>) constexpr range_reference_t const> back() const { return *prev(derived().end()); } /// Simple indexing: - template(bool True = true)( // - requires True AND random_access_range>) // + template(bool True = true)( + /// \pre + requires True AND random_access_range>) constexpr range_reference_t> operator[](range_difference_t> n) { return derived().begin()[n]; } /// \overload - template(bool True = true)( // - requires True AND random_access_range const>) // + template(bool True = true)( + /// \pre + requires True AND random_access_range const>) constexpr range_reference_t const> // operator[](range_difference_t> n) const { @@ -285,23 +303,26 @@ namespace ranges } /// Returns a pointer to the block of memory /// containing the elements of a contiguous range: - template(bool True = true)( // - requires True AND contiguous_iterator>>) // + template(bool True = true)( + /// \pre + requires True AND contiguous_iterator>>) constexpr std::add_pointer_t>> data() // { return std::addressof(*ranges::begin(derived())); } /// \overload - template(bool True = true)( // - requires True AND contiguous_iterator const>>) // + template(bool True = true)( + /// \pre + requires True AND contiguous_iterator const>>) constexpr std::add_pointer_t const>> data() const // { return std::addressof(*ranges::begin(derived())); } /// Returns a reference to the element at specified location pos, with bounds /// checking. - template(bool True = true)( // - requires True AND random_access_range> AND sized_range>) // + template(bool True = true)( + /// \pre + requires True AND random_access_range> AND sized_range>) constexpr range_reference_t> at(range_difference_t> n) { using size_type = range_size_t; @@ -312,9 +333,10 @@ namespace ranges return derived().begin()[n]; } /// \overload - template(bool True = true)( // - requires True AND random_access_range const> AND // - sized_range const>) // + template(bool True = true)( + /// \pre + requires True AND random_access_range const> AND + sized_range const>) constexpr range_reference_t const> at(range_difference_t> n) const { using size_type = range_size_t; @@ -326,24 +348,27 @@ namespace ranges } /// Python-ic slicing: // rng[{4,6}] - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range &>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range &>) constexpr auto operator[](detail::slice_bounds>> offs) & { return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range const &>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range const &>) constexpr auto operator[](detail::slice_bounds>> offs) const & { return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range>) constexpr auto operator[](detail::slice_bounds>> offs) && { @@ -351,8 +376,9 @@ namespace ranges } // rng[{4,end-2}] /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range &> AND sized_range &>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range &> AND sized_range &>) constexpr auto // operator[](detail::slice_bounds>, detail::from_end_of_t>> offs) & @@ -360,9 +386,10 @@ namespace ranges return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre requires True AND input_range const &> AND - sized_range const &>) // + sized_range const &>) constexpr auto // operator[](detail::slice_bounds>, detail::from_end_of_t>> offs) const & @@ -370,8 +397,9 @@ namespace ranges return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range> AND sized_range>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range> AND sized_range>) constexpr auto // operator[](detail::slice_bounds>, detail::from_end_of_t>> offs) && @@ -380,7 +408,8 @@ namespace ranges } // rng[{end-4,end-2}] /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre requires True AND (forward_range &> || (input_range &> && sized_range &>))) // constexpr auto // @@ -390,7 +419,8 @@ namespace ranges return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre requires True AND (forward_range const &> || (input_range const &> && sized_range const &>))) // @@ -401,7 +431,8 @@ namespace ranges return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre requires True AND (forward_range> || (input_range> && sized_range>))) // @@ -413,24 +444,27 @@ namespace ranges } // rng[{4,end}] /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range &>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range &>) constexpr auto // operator[](detail::slice_bounds>, end_fn> offs) & { return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range const &>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range const &>) constexpr auto // operator[](detail::slice_bounds>, end_fn> offs) const & { return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND input_range>) // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND input_range>) constexpr auto // operator[](detail::slice_bounds>, end_fn> offs) && { @@ -438,8 +472,9 @@ namespace ranges } // rng[{end-4,end}] /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND (forward_range &> || (input_range &> && sized_range &>))) // constexpr auto // @@ -448,8 +483,9 @@ namespace ranges return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // - requires True AND // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre + requires True AND (forward_range const &> || (input_range const &> && sized_range const &>))) // constexpr auto // @@ -459,7 +495,8 @@ namespace ranges return Slice{}(derived(), offs.from, offs.to); } /// \overload - template(bool True = true, typename Slice = views::slice_fn)( // + template(bool True = true, typename Slice = views::slice_fn)( + /// \pre requires True AND (forward_range> || (input_range> && sized_range>))) // @@ -472,7 +509,8 @@ namespace ranges /// \brief Print a range to an ostream template friend auto operator<<(std::ostream & sout, Derived const & rng) - -> CPP_broken_friend_ret(std::ostream &)( // + -> CPP_broken_friend_ret(std::ostream &)( + /// \pre requires True && input_range const>) { return detail::print_rng_(sout, rng); @@ -480,7 +518,8 @@ namespace ranges /// \overload template friend auto operator<<(std::ostream & sout, Derived & rng) - -> CPP_broken_friend_ret(std::ostream &)( // + -> CPP_broken_friend_ret(std::ostream &)( + /// \pre requires True && (!range const>) && input_range>) { return detail::print_rng_(sout, rng); @@ -488,7 +527,8 @@ namespace ranges /// \overload template friend auto operator<<(std::ostream & sout, Derived && rng) - -> CPP_broken_friend_ret(std::ostream &)( // + -> CPP_broken_friend_ret(std::ostream &)( + /// \pre requires True && (!range const>) && input_range>) { return detail::print_rng_(sout, rng); @@ -497,9 +537,10 @@ namespace ranges namespace cpp20 { - template(typename Derived)( // + template(typename Derived)( + /// \pre requires std::is_class::value AND - same_as>>) // + same_as>>) using view_interface = ranges::view_interface; } /// @} diff --git a/include/range/v3/view/intersperse.hpp b/include/range/v3/view/intersperse.hpp index 8f3a878dec..c1e6bf1c12 100644 --- a/include/range/v3/view/intersperse.hpp +++ b/include/range/v3/view/intersperse.hpp @@ -57,7 +57,8 @@ namespace ranges return n ? n * 2 - 1 : 0; } CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires sized_range) { auto const n = ranges::size(this->base()); @@ -80,7 +81,8 @@ namespace ranges constexpr explicit cursor_adaptor(range_value_t const & val) : val_{val} {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // cursor_adaptor(cursor_adaptor that) : toggle_(that.toggle_) @@ -101,7 +103,8 @@ namespace ranges constexpr auto equal(iterator_t const & it0, iterator_t const & it1, cursor_adaptor const & other) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires sentinel_for, iterator_t>) { return it0 == it1 && toggle_ == other.toggle_; @@ -114,7 +117,8 @@ namespace ranges } CPP_member constexpr auto prev(iterator_t & it) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { toggle_ = !toggle_; @@ -125,14 +129,16 @@ namespace ranges constexpr auto distance_to(iterator_t const & it, iterator_t const & other_it, cursor_adaptor const & other) const - -> CPP_ret(range_difference_t)( // + -> CPP_ret(range_difference_t)( + /// \pre requires sized_sentinel_for, iterator_t>) { return (other_it - it) * 2 + (other.toggle_ - toggle_); } CPP_member constexpr auto advance(iterator_t & it, range_difference_t n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires random_access_range) { ranges::advance(it, n >= 0 ? (n + toggle_) / 2 : (n - !toggle_) / 2); @@ -148,7 +154,8 @@ namespace ranges public: sentinel_adaptor() = default; - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // sentinel_adaptor(sentinel_adaptor) {} @@ -165,26 +172,30 @@ namespace ranges } CPP_member constexpr auto begin_adaptor() const // - -> CPP_ret(cursor_adaptor)( // + -> CPP_ret(cursor_adaptor)( + /// \pre requires range) { return cursor_adaptor{val_}; } CPP_member constexpr auto end_adaptor() // - -> CPP_ret(cursor_adaptor)( // + -> CPP_ret(cursor_adaptor)( + /// \pre requires common_range && (!single_pass_iterator_>)) { return cursor_adaptor{val_}; } CPP_member constexpr auto end_adaptor() noexcept // - -> CPP_ret(sentinel_adaptor)( // + -> CPP_ret(sentinel_adaptor)( + /// \pre requires (!common_range) || single_pass_iterator_>) { return {}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND common_range> AND (!single_pass_iterator_>>)) // @@ -192,7 +203,8 @@ namespace ranges { return cursor_adaptor{val_}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND (!common_range> || single_pass_iterator_>>)) // @@ -210,7 +222,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - intersperse_view(Rng &&, range_value_t) // + intersperse_view(Rng &&, range_value_t) -> intersperse_view>; #endif @@ -218,10 +230,11 @@ namespace ranges { struct intersperse_base_fn { - template(typename Rng)( // - requires viewable_range AND input_range AND // - convertible_to, range_value_t> AND // - semiregular>) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range AND + convertible_to, range_value_t> AND + semiregular>) constexpr intersperse_view> // operator()(Rng && rng, range_value_t val) const { @@ -233,7 +246,8 @@ namespace ranges { using intersperse_base_fn::operator(); - template(typename T)( // + template(typename T)( + /// \pre requires copyable) constexpr auto operator()(T t) const { diff --git a/include/range/v3/view/iota.hpp b/include/range/v3/view/iota.hpp index 26f3c464ca..21a19d67e7 100644 --- a/include/range/v3/view/iota.hpp +++ b/include/range/v3/view/iota.hpp @@ -118,7 +118,8 @@ namespace ranges CPP_requires_ref(detail::_advanceable_, I); // clang-format on - template(typename I)( // + template(typename I)( + /// \pre requires (!unsigned_integral)) // void iota_advance_(I & i, iota_difference_t n) { @@ -126,8 +127,9 @@ namespace ranges i += n; } - template(typename Int)( // - requires unsigned_integral) // + template(typename Int)( + /// \pre + requires unsigned_integral) void iota_advance_(Int & i, iota_difference_t n) { // TODO: bounds-check this @@ -137,15 +139,17 @@ namespace ranges i -= static_cast(-n); } - template(typename I)( // + template(typename I)( + /// \pre requires advanceable_ AND (!integral)) // iota_difference_t iota_distance_(I const & i, I const & s) { return static_cast>(s - i); } - template(typename Int)( // - requires signed_integral) // + template(typename Int)( + /// \pre + requires signed_integral) iota_difference_t iota_distance_(Int i0, Int i1) { // TODO: bounds-check this @@ -154,8 +158,9 @@ namespace ranges static_cast>(i0)); } - template(typename Int)( // - requires unsigned_integral) // + template(typename Int)( + /// \pre + requires unsigned_integral) iota_difference_t iota_distance_(Int i0, Int i1) { // TODO: bounds-check this @@ -209,14 +214,16 @@ namespace ranges } CPP_member auto equal(cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires equality_comparable) { return that.from_ == from_ && that.done_ == done_; } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires detail::decrementable_) { if(done_) @@ -226,7 +233,8 @@ namespace ranges } CPP_member auto advance(difference_type n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires detail::advanceable_) { if(n > 0) @@ -241,7 +249,8 @@ namespace ranges } CPP_member auto distance_to(cursor const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires detail::advanceable_) { using D = difference_type; @@ -250,7 +259,8 @@ namespace ranges } CPP_member auto distance_to(default_sentinel_t) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires sized_sentinel_for) { return difference_type(to_ - from_) + !done_; @@ -271,14 +281,16 @@ namespace ranges } CPP_member auto end_cursor() const // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires same_as) { return {to_, to_, true}; } CPP_member auto end_cursor() const // - -> CPP_ret(default_sentinel_t)( // + -> CPP_ret(default_sentinel_t)( + /// \pre requires (!same_as)) { return {}; @@ -306,7 +318,8 @@ namespace ranges true; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename From, typename To)( // + template(typename From, typename To)( + /// \pre requires weakly_incrementable AND semiregular AND (!integral || !integral || std::is_signed::value == std::is_signed::value)) // @@ -364,21 +377,24 @@ namespace ranges } CPP_member auto equal(cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires equality_comparable) { return that.from_ == from_; } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires detail::decrementable_) { --from_; } CPP_member auto advance(difference_type n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires detail::advanceable_) { detail::iota_advance_(from_, n); @@ -388,7 +404,8 @@ namespace ranges // Reimplement iota_view without view_facade or basic_iterator. CPP_member auto distance_to(cursor const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires detail::advanceable_) { return detail::iota_distance_(from_, that.from_); @@ -396,7 +413,8 @@ namespace ranges // Extension: see https://github.com/ericniebler/stl2/issues/613 CPP_member auto distance_to(sentinel const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires sized_sentinel_for) { return that.to_ - from_; @@ -451,7 +469,8 @@ namespace ranges RANGES_INLINE_VAR constexpr bool enable_borrowed_range> = true; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename From, typename To)( // + template(typename From, typename To)( + /// \pre requires weakly_incrementable AND semiregular AND (!integral || !integral || std::is_signed::value == std::is_signed::value)) // @@ -463,13 +482,15 @@ namespace ranges { struct iota_fn { - template(typename From)( // - requires weakly_incrementable) // + template(typename From)( + /// \pre + requires weakly_incrementable) iota_view operator()(From value) const { return iota_view{std::move(value)}; } - template(typename From, typename To)( // + template(typename From, typename To)( + /// \pre requires weakly_incrementable AND semiregular AND detail::weakly_equality_comparable_with_ AND (!integral || !integral || @@ -482,7 +503,8 @@ namespace ranges struct closed_iota_fn { - template(typename From, typename To)( // + template(typename From, typename To)( + /// \pre requires weakly_incrementable AND semiregular AND detail::weakly_equality_comparable_with_ AND (!integral || !integral || @@ -505,7 +527,8 @@ namespace ranges { ints_fn() = default; - template(typename Val)( // + template(typename Val)( + /// \pre requires integral) RANGES_DEPRECATED( "This potentially confusing API is deprecated. Prefer to " @@ -515,14 +538,16 @@ namespace ranges { return iota_view{value}; } - template(typename Val)( // - requires integral) // + template(typename Val)( + /// \pre + requires integral) constexpr iota_view operator()(Val value, unreachable_sentinel_t) const { return iota_view{value}; } - template(typename Val)( // - requires integral) // + template(typename Val)( + /// \pre + requires integral) constexpr iota_view operator()(Val from, Val to) const { return {from, to}; diff --git a/include/range/v3/view/istream.hpp b/include/range/v3/view/istream.hpp index 58209073f7..c708a17f29 100644 --- a/include/range/v3/view/istream.hpp +++ b/include/range/v3/view/istream.hpp @@ -99,8 +99,9 @@ namespace ranges namespace _istream_ { /// \endcond - template(typename Val)( // - requires copy_constructible AND default_constructible) // + template(typename Val)( + /// \pre + requires copy_constructible AND default_constructible) inline istream_view istream(std::istream & sin) { return istream_view{sin}; diff --git a/include/range/v3/view/join.hpp b/include/range/v3/view/join.hpp index 123b4b7a23..f950b41688 100644 --- a/include/range/v3/view/join.hpp +++ b/include/range/v3/view/join.hpp @@ -149,14 +149,16 @@ namespace ranges // Not to spec CPP_member static constexpr auto size() // - -> CPP_ret(std::size_t)( // + -> CPP_ret(std::size_t)( + /// \pre requires (detail::join_cardinality() >= 0)) { return static_cast(detail::join_cardinality()); } // Not to spec CPP_member - constexpr auto CPP_fun(size)()(// + constexpr auto CPP_fun(size)()( + /// \pre requires(detail::join_cardinality() < 0) && (range_cardinality::value >= 0) && forward_range && @@ -215,11 +217,12 @@ namespace ranges { satisfy(); } - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other) AND convertible_to, iterator_t> AND convertible_to>, - iterator_t>) // + iterator_t>) constexpr cursor(cursor that) : rng_(that.rng_) , outer_it_(std::move(that.outer_it_)) @@ -227,7 +230,8 @@ namespace ranges {} CPP_member constexpr auto arrow() // - -> CPP_ret(iterator_t)( // + -> CPP_ret(iterator_t)( + /// \pre requires detail::has_arrow_>) { return inner_it_; @@ -238,7 +242,8 @@ namespace ranges } CPP_member constexpr auto equal(cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires ref_is_glvalue::value && // equality_comparable> && // equality_comparable>) @@ -256,7 +261,8 @@ namespace ranges } CPP_member constexpr auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires ref_is_glvalue::value && // bidirectional_range && // bidirectional_range && // @@ -311,7 +317,8 @@ namespace ranges return {this, ranges::begin}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND input_range> AND std::is_reference>>::value) constexpr cursor begin_cursor() const @@ -328,7 +335,8 @@ namespace ranges return end_cursor_fn{}(this, cond{}); } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND input_range> AND std::is_reference>>::value) constexpr auto end_cursor() const @@ -364,7 +372,8 @@ namespace ranges {} CPP_member static constexpr auto size() // - -> CPP_ret(std::size_t)( // + -> CPP_ret(std::size_t)( + /// \pre requires (detail::join_cardinality() >= 0)) { return static_cast(detail::join_cardinality()); @@ -532,8 +541,9 @@ namespace ranges struct cpp20_join_fn { - template(typename Rng)( // - requires joinable_range) // + template(typename Rng)( + /// \pre + requires joinable_range) join_view> operator()(Rng && rng) const { return join_view>{all(static_cast(rng))}; @@ -548,16 +558,18 @@ namespace ranges public: using cpp20_join_fn::operator(); - template(typename Rng)( // - requires joinable_with_range>>) // + template(typename Rng)( + /// \pre + requires joinable_with_range>>) join_with_view, single_view>> // operator()(Rng && rng, inner_value_t v) const { return {all(static_cast(rng)), single(std::move(v))}; } - template(typename Rng, typename ValRng)( // - requires joinable_with_range) // + template(typename Rng, typename ValRng)( + /// \pre + requires joinable_with_range) join_with_view, all_t> // operator()(Rng && rng, ValRng && val) const { @@ -576,13 +588,15 @@ namespace ranges struct join_bind_fn { - template(typename T)( // + template(typename T)( + /// \pre requires (!joinable_range)) // TODO: underconstrained constexpr auto operator()(T && t)const { return make_view_closure(bind_back(join_base_fn{}, static_cast(t))); } - template(typename T)( // + template(typename T)( + /// \pre requires (!joinable_range) AND range) constexpr auto operator()(T & t) const { @@ -605,13 +619,15 @@ namespace ranges /// @} #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng)( // - requires views::joinable_range) // + template(typename Rng)( + /// \pre + requires views::joinable_range) explicit join_view(Rng &&) ->join_view>; - template(typename Rng, typename ValRng)( // - requires views::joinable_with_range) // + template(typename Rng, typename ValRng)( + /// \pre + requires views::joinable_with_range) explicit join_with_view(Rng &&, ValRng &&) ->join_with_view, views::all_t>; #endif @@ -623,7 +639,8 @@ namespace ranges RANGES_INLINE_VARIABLE( ranges::views::view_closure, join) } - template(typename Rng)( // + template(typename Rng)( + /// \pre requires input_range AND view_ AND input_range>> AND (std::is_reference>>::value || diff --git a/include/range/v3/view/linear_distribute.hpp b/include/range/v3/view/linear_distribute.hpp index 456aaee591..066bf5814d 100644 --- a/include/range/v3/view/linear_distribute.hpp +++ b/include/range/v3/view/linear_distribute.hpp @@ -99,7 +99,8 @@ namespace ranges /// If `n == 1` returns `to`. struct linear_distribute_fn { - template(typename T)( // + template(typename T)( + /// \pre requires std::is_arithmetic::value) constexpr auto operator()(T from, T to, std::ptrdiff_t n) const { diff --git a/include/range/v3/view/map.hpp b/include/range/v3/view/map.hpp index b3823be57b..5e20c8fcd0 100644 --- a/include/range/v3/view/map.hpp +++ b/include/range/v3/view/map.hpp @@ -42,8 +42,9 @@ namespace ranges return t; } - template(typename T)( // - requires move_constructible) // + template(typename T)( + /// \pre + requires move_constructible) constexpr T get_first_second_helper(T & t, std::false_type) // noexcept(std::is_nothrow_move_constructible::value) { @@ -95,9 +96,10 @@ namespace ranges { struct keys_fn { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range AND - detail::kv_pair_like_>) // + detail::kv_pair_like_>) keys_range_view> operator()(Rng && rng) const { return {all(static_cast(rng)), detail::get_first{}}; @@ -106,9 +108,10 @@ namespace ranges struct values_fn { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range AND - detail::kv_pair_like_>) // + detail::kv_pair_like_>) values_view> operator()(Rng && rng) const { return {all(static_cast(rng)), detail::get_second{}}; diff --git a/include/range/v3/view/move.hpp b/include/range/v3/view/move.hpp index 7200679cc8..fcd8b0f20d 100644 --- a/include/range/v3/view/move.hpp +++ b/include/range/v3/view/move.hpp @@ -43,7 +43,8 @@ namespace ranges struct adaptor : adaptor_base { adaptor() = default; - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // constexpr adaptor(adaptor) {} @@ -68,14 +69,16 @@ namespace ranges } CPP_member auto begin_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires input_range) { return {}; } CPP_member auto end_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires input_range) { return {}; @@ -93,7 +96,8 @@ namespace ranges return ranges::size(this->base()); } CPP_member - auto CPP_fun(size)()( // + auto CPP_fun(size)()( + /// \pre requires sized_range) { return ranges::size(this->base()); @@ -114,8 +118,9 @@ namespace ranges { struct move_fn { - template(typename Rng)( // - requires viewable_range AND input_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range) move_view> operator()(Rng && rng) const { return move_view>{all(static_cast(rng))}; diff --git a/include/range/v3/view/partial_sum.hpp b/include/range/v3/view/partial_sum.hpp index a45db3cdbd..e237bd90c5 100644 --- a/include/range/v3/view/partial_sum.hpp +++ b/include/range/v3/view/partial_sum.hpp @@ -100,10 +100,11 @@ namespace ranges if(current_ != ranges::end(rng->base_)) sum_ = *current_; } - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other) AND convertible_to const &, - iterator_t>) // + iterator_t>) constexpr cursor(cursor const & that) : parent_{that.parent_} , current_(that.current_) @@ -143,8 +144,9 @@ namespace ranges { return cursor{this}; } - template(typename CRng = Rng const)( // - requires detail::partial_sum_view_constraints) // + template(typename CRng = Rng const)( + /// \pre + requires detail::partial_sum_view_constraints) constexpr cursor begin_cursor() const { return cursor{this}; @@ -159,7 +161,8 @@ namespace ranges , fun_(std::move(fun)) {} CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires sized_range) { return ranges::size(base_); @@ -173,7 +176,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires copy_constructible) partial_sum_view(Rng &&, Fun) -> partial_sum_view, Fun>; @@ -183,8 +187,9 @@ namespace ranges { struct partial_sum_base_fn { - template(typename Rng, typename Fun = plus)( // - requires detail::partial_sum_view_constraints, Fun>) // + template(typename Rng, typename Fun = plus)( + /// \pre + requires detail::partial_sum_view_constraints, Fun>) constexpr partial_sum_view, Fun> // operator()(Rng && rng, Fun fun = {}) const { @@ -196,7 +201,8 @@ namespace ranges { using partial_sum_base_fn::operator(); - template(typename Fun)( // + template(typename Fun)( + /// \pre requires (!range)) constexpr auto operator()(Fun && fun) const { diff --git a/include/range/v3/view/ref.hpp b/include/range/v3/view/ref.hpp index e229830a40..66dce19609 100644 --- a/include/range/v3/view/ref.hpp +++ b/include/range/v3/view/ref.hpp @@ -62,7 +62,8 @@ namespace ranges } CPP_member constexpr auto empty() const noexcept(noexcept(ranges::empty(*rng_))) - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires detail::can_empty_) { return ranges::empty(*rng_); @@ -84,7 +85,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename R)( // + template(typename R)( + /// \pre requires range) ref_view(R &) // -> ref_view; @@ -94,8 +96,9 @@ namespace ranges { struct ref_fn { - template(typename Rng)( // - requires range) // + template(typename Rng)( + /// \pre + requires range) constexpr ref_view operator()(Rng & rng) const noexcept { return ref_view(rng); @@ -111,7 +114,8 @@ namespace ranges namespace cpp20 { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires std::is_object::value) // using ref_view = ranges::ref_view; } diff --git a/include/range/v3/view/remove.hpp b/include/range/v3/view/remove.hpp index e63060cab0..833d73bbe5 100644 --- a/include/range/v3/view/remove.hpp +++ b/include/range/v3/view/remove.hpp @@ -43,8 +43,9 @@ namespace ranges struct pred_ { Value value_; - template(typename T)( // - requires equality_comparable_with) // + template(typename T)( + /// \pre + requires equality_comparable_with) bool operator()(T && other) const { return static_cast(other) == value_; @@ -52,7 +53,8 @@ namespace ranges }; public: - template(typename Rng, typename Value)( // + template(typename Rng, typename Value)( + /// \pre requires move_constructible AND viewable_range AND input_range AND indirectly_comparable, Value const *, equal_to>) @@ -62,9 +64,10 @@ namespace ranges pred_{std::move(value)}); } - template(typename Rng, typename Value, typename Proj)( // + template(typename Rng, typename Value, typename Proj)( + /// \pre requires move_constructible AND viewable_range AND - input_range AND // + input_range AND indirectly_comparable, Value const *, equal_to, Proj>) constexpr auto operator()(Rng && rng, Value value, Proj proj) const { @@ -81,7 +84,8 @@ namespace ranges { return make_view_closure(bind_back(remove_base_fn{}, std::move(value))); } - template(typename Value, typename Proj)( // + template(typename Value, typename Proj)( + /// \pre requires (!range)) // TODO: underconstrained constexpr auto operator()(Value && value, Proj proj) const { diff --git a/include/range/v3/view/remove_if.hpp b/include/range/v3/view/remove_if.hpp index b90e6bf94b..9e04115ea3 100644 --- a/include/range/v3/view/remove_if.hpp +++ b/include/range/v3/view/remove_if.hpp @@ -72,7 +72,8 @@ namespace ranges } CPP_member constexpr auto prev(iterator_t & it) const // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { rng_->satisfy_reverse(it); @@ -90,14 +91,16 @@ namespace ranges } CPP_member constexpr auto end_adaptor() const noexcept // - -> CPP_ret(adaptor_base)( // + -> CPP_ret(adaptor_base)( + /// \pre requires (!common_range)) { return {}; } CPP_member constexpr auto end_adaptor() // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires common_range) { if(bidirectional_range) @@ -138,7 +141,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Pred)( // + template(typename Rng, typename Pred)( + /// \pre requires copy_constructible) remove_if_view(Rng &&, Pred) -> remove_if_view, Pred>; @@ -150,18 +154,20 @@ namespace ranges /// present a view of the elements that do not satisfy the predicate. struct remove_if_base_fn { - template(typename Rng, typename Pred)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate>) // + template(typename Rng, typename Pred)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate>) constexpr remove_if_view, Pred> operator()(Rng && rng, Pred pred) const { return remove_if_view, Pred>{all(static_cast(rng)), std::move(pred)}; } - template(typename Rng, typename Pred, typename Proj)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate, Proj>>) // + template(typename Rng, typename Pred, typename Proj)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate, Proj>>) constexpr remove_if_view, composed> // operator()(Rng && rng, Pred pred, Proj proj) const { @@ -178,7 +184,8 @@ namespace ranges { return make_view_closure(bind_back(remove_if_base_fn{}, std::move(pred))); } - template(typename Pred, typename Proj)( // + template(typename Pred, typename Proj)( + /// \pre requires (!range)) // TODO: underconstrained constexpr auto operator()(Pred && pred, Proj proj) const { diff --git a/include/range/v3/view/repeat.hpp b/include/range/v3/view/repeat.hpp index 560c0e75c5..bc366c7821 100644 --- a/include/range/v3/view/repeat.hpp +++ b/include/range/v3/view/repeat.hpp @@ -101,8 +101,9 @@ namespace ranges { struct repeat_fn { - template(typename Val)( // - requires copy_constructible) // + template(typename Val)( + /// \pre + requires copy_constructible) repeat_view operator()(Val value) const { return repeat_view{std::move(value)}; diff --git a/include/range/v3/view/repeat_n.hpp b/include/range/v3/view/repeat_n.hpp index cf0ff7cb0c..80dda8fb15 100644 --- a/include/range/v3/view/repeat_n.hpp +++ b/include/range/v3/view/repeat_n.hpp @@ -109,8 +109,9 @@ namespace ranges { struct repeat_n_fn { - template(typename Val)( // - requires copy_constructible) // + template(typename Val)( + /// \pre + requires copy_constructible) repeat_n_view operator()(Val value, std::ptrdiff_t n) const { return repeat_n_view{std::move(value), n}; diff --git a/include/range/v3/view/replace.hpp b/include/range/v3/view/replace.hpp index 427252bcdc..fadfa20eeb 100644 --- a/include/range/v3/view/replace.hpp +++ b/include/range/v3/view/replace.hpp @@ -88,8 +88,9 @@ namespace ranges { struct replace_base_fn { - template(typename Rng, typename Val1, typename Val2)( // - requires viewable_range AND input_range AND // + template(typename Rng, typename Val1, typename Val2)( + /// \pre + requires viewable_range AND input_range AND same_as< detail::decay_t>, detail::decay_t>> AND @@ -102,7 +103,7 @@ namespace ranges range_reference_t> AND common_reference_with< unwrap_reference_t, - range_rvalue_reference_t>) // + range_rvalue_reference_t>) constexpr replace_view< // all_t, // detail::decay_t, // @@ -120,7 +121,8 @@ namespace ranges { using replace_base_fn::operator(); - template(typename Val1, typename Val2)( // + template(typename Val1, typename Val2)( + /// \pre requires same_as>, detail::decay_t>>) constexpr auto operator()(Val1 old_value, Val2 new_value) const diff --git a/include/range/v3/view/replace_if.hpp b/include/range/v3/view/replace_if.hpp index c74138b647..8eee0e581d 100644 --- a/include/range/v3/view/replace_if.hpp +++ b/include/range/v3/view/replace_if.hpp @@ -61,7 +61,8 @@ namespace ranges RANGES_EXPECT(false); } - template(typename I)( // + template(typename I)( + /// \pre requires (!invocable>)) common_reference_t, iter_reference_t> // operator()(I const & i) @@ -71,7 +72,8 @@ namespace ranges return unwrap_reference(second()); return (decltype(x) &&)x; } - template(typename I)( // + template(typename I)( + /// \pre requires invocable>) common_reference_t, iter_reference_t> // operator()(I const & i) const @@ -82,7 +84,8 @@ namespace ranges return (decltype(x) &&)x; } - template(typename I)( // + template(typename I)( + /// \pre requires (!invocable>)) common_reference_t< unwrap_reference_t, // @@ -94,7 +97,8 @@ namespace ranges return unwrap_reference(second()); return (decltype(x) &&)x; } - template(typename I)( // + template(typename I)( + /// \pre requires invocable>) common_reference_t< // unwrap_reference_t, // @@ -116,7 +120,8 @@ namespace ranges { struct replace_if_base_fn { - template(typename Rng, typename Pred, typename Val)( // + template(typename Rng, typename Pred, typename Val)( + /// \pre requires viewable_range AND input_range AND indirect_unary_predicate> AND common_with>, @@ -124,7 +129,7 @@ namespace ranges common_reference_with, range_reference_t> AND common_reference_with, - range_rvalue_reference_t>) // + range_rvalue_reference_t>) constexpr replace_if_view, Pred, Val> // operator()(Rng && rng, Pred pred, Val new_value) const { diff --git a/include/range/v3/view/reverse.hpp b/include/range/v3/view/reverse.hpp index 5d82a4f711..066b29cd5f 100644 --- a/include/range/v3/view/reverse.hpp +++ b/include/range/v3/view/reverse.hpp @@ -86,8 +86,9 @@ namespace ranges { return begin_(meta::bool_<(bool)common_range>{}); } - template(bool Const = true)( // - requires Const AND common_range>) // + template(bool Const = true)( + /// \pre + requires Const AND common_range>) constexpr reverse_iterator>> begin() const { return make_reverse_iterator(ranges::end(rng_)); @@ -96,14 +97,16 @@ namespace ranges { return make_reverse_iterator(ranges::begin(rng_)); } - template(bool Const = true)( // - requires Const AND common_range>) // + template(bool Const = true)( + /// \pre + requires Const AND common_range>) constexpr reverse_iterator>> end() const { return make_reverse_iterator(ranges::begin(rng_)); } CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires sized_range) { return ranges::size(rng_); @@ -145,7 +148,7 @@ namespace ranges -> reverse_view>; template - reverse_view(reverse_view) // + reverse_view(reverse_view) -> reverse_view>; #endif @@ -153,8 +156,9 @@ namespace ranges { struct reverse_fn { - template(typename Rng)( // - requires viewable_range AND bidirectional_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND bidirectional_range) constexpr reverse_view> operator()(Rng && rng) const { return reverse_view>{all(static_cast(rng))}; @@ -172,8 +176,9 @@ namespace ranges { using ranges::views::reverse; } - template(typename Rng)( // - requires view_ AND bidirectional_range) // + template(typename Rng)( + /// \pre + requires view_ AND bidirectional_range) using reverse_view = ranges::reverse_view; } // namespace cpp20 /// @} diff --git a/include/range/v3/view/sample.hpp b/include/range/v3/view/sample.hpp index b43e069cfe..222658ce9e 100644 --- a/include/range/v3/view/sample.hpp +++ b/include/range/v3/view/sample.hpp @@ -138,7 +138,8 @@ namespace ranges rng->size_ = n; advance(); } - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) // cursor(cursor that) : parent_(that.parent_) @@ -170,7 +171,8 @@ namespace ranges { return cursor{this}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND (sized_range> || sized_sentinel_for>, @@ -209,7 +211,8 @@ namespace ranges /// Returns a random sample of a range of length `size(range)`. struct sample_base_fn { - template(typename Rng, typename URNG = detail::default_random_engine)( // + template(typename Rng, typename URNG = detail::default_random_engine)( + /// \pre requires viewable_range AND input_range AND uniform_random_bit_generator AND convertible_to, range_difference_t> AND @@ -242,8 +245,9 @@ namespace ranges { using sample_base_fn::operator(); - template(typename Size, typename URNG = detail::default_random_engine)( // - requires integral AND uniform_random_bit_generator) // + template(typename Size, typename URNG = detail::default_random_engine)( + /// \pre + requires integral AND uniform_random_bit_generator) constexpr auto operator()( Size n, URNG & urng = detail::get_random_engine()) const // diff --git a/include/range/v3/view/set_algorithm.hpp b/include/range/v3/view/set_algorithm.hpp index cd179874ce..7d5911064a 100644 --- a/include/range/v3/view/set_algorithm.hpp +++ b/include/range/v3/view/set_algorithm.hpp @@ -74,7 +74,8 @@ namespace ranges } CPP_member auto begin_cursor() const // - -> CPP_ret(cursor)( // + -> CPP_ret(cursor)( + /// \pre requires range && range) { return {pred_, @@ -158,7 +159,8 @@ namespace ranges { satisfy(); } - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst && CPP_NOT(Other)) // set_difference_cursor( set_difference_cursor that) @@ -183,7 +185,8 @@ namespace ranges } CPP_member auto equal(set_difference_cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires forward_range) { // does not support comparing iterators from different ranges @@ -223,13 +226,14 @@ namespace ranges struct set_difference_base_fn { template(typename Rng1, typename Rng2, typename C = less, - typename P1 = identity, typename P2 = identity)( // + typename P1 = identity, typename P2 = identity)( + /// \pre requires // viewable_range AND input_range AND viewable_range AND input_range AND indirect_relation, P1>, - projected, P2>>) // + projected, P2>>) set_difference_view, all_t, C, P1, P2> // operator()(Rng1 && rng1, Rng2 && rng2, @@ -250,7 +254,8 @@ namespace ranges using set_difference_base_fn::operator(); template(typename Rng2, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires viewable_range AND input_range AND (!range)) constexpr auto operator()(Rng2 && rng2, C && pred = C{}, @@ -333,7 +338,8 @@ namespace ranges { satisfy(); } - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst && CPP_NOT(Other)) // set_intersection_cursor( set_intersection_cursor that) @@ -359,7 +365,8 @@ namespace ranges } CPP_member auto equal(set_intersection_cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires forward_range) { // does not support comparing iterators from different ranges @@ -399,13 +406,14 @@ namespace ranges struct set_intersection_base_fn { template(typename Rng1, typename Rng2, typename C = less, - typename P1 = identity, typename P2 = identity)( // + typename P1 = identity, typename P2 = identity)( + /// \pre requires viewable_range AND input_range AND viewable_range AND input_range AND indirect_relation< C, projected, P1>, - projected, P2>>) // + projected, P2>>) set_intersection_view, all_t, C, P1, P2> operator()(Rng1 && rng1, Rng2 && rng2, @@ -426,7 +434,8 @@ namespace ranges using set_intersection_base_fn::operator(); template(typename Rng2, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires viewable_range AND input_range AND (!range)) constexpr auto operator()(Rng2 && rng2, C && pred = C{}, @@ -531,7 +540,8 @@ namespace ranges { satisfy(); } - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) set_union_cursor(set_union_cursor that) : pred_(std::move(that.pred_)) @@ -559,7 +569,8 @@ namespace ranges } CPP_member auto equal(set_union_cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires forward_range && forward_range) { // does not support comparing iterators from different ranges @@ -602,7 +613,8 @@ namespace ranges { public: template(typename Rng1, typename Rng2, typename C = less, - typename P1 = identity, typename P2 = identity)( // + typename P1 = identity, typename P2 = identity)( + /// \pre requires // viewable_range AND input_range AND viewable_range AND input_range AND @@ -613,7 +625,7 @@ namespace ranges range_rvalue_reference_t> AND indirect_relation, P1>, - projected, P2>>) // + projected, P2>>) set_union_view, all_t, C, P1, P2> // operator()(Rng1 && rng1, Rng2 && rng2, @@ -634,7 +646,8 @@ namespace ranges using set_union_base_fn::operator(); template(typename Rng2, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires viewable_range AND input_range AND (!range)) constexpr auto operator()(Rng2 && rng2, C && pred = C{}, @@ -750,7 +763,8 @@ namespace ranges { satisfy(); } - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst && CPP_NOT(Other)) // set_symmetric_difference_cursor( set_symmetric_difference_cursor that) @@ -792,7 +806,8 @@ namespace ranges } CPP_member auto equal(set_symmetric_difference_cursor const & that) const - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires forward_range && forward_range) { // does not support comparing iterators from different ranges: @@ -836,7 +851,8 @@ namespace ranges struct set_symmetric_difference_base_fn { template(typename Rng1, typename Rng2, typename C = less, - typename P1 = identity, typename P2 = identity)( // + typename P1 = identity, typename P2 = identity)( + /// \pre requires // viewable_range AND input_range AND viewable_range AND input_range AND @@ -847,7 +863,7 @@ namespace ranges range_rvalue_reference_t> AND indirect_relation, P1>, - projected, P2>>) // + projected, P2>>) set_symmetric_difference_view, all_t, C, P1, P2> operator()(Rng1 && rng1, Rng2 && rng2, @@ -868,7 +884,8 @@ namespace ranges using set_symmetric_difference_base_fn::operator(); template(typename Rng2, typename C = less, typename P1 = identity, - typename P2 = identity)( // + typename P2 = identity)( + /// \pre requires viewable_range AND input_range AND (!range)) constexpr auto operator()(Rng2 && rng2, C && pred = C{}, diff --git a/include/range/v3/view/single.hpp b/include/range/v3/view/single.hpp index 3225ce3afb..d9a4740326 100644 --- a/include/range/v3/view/single.hpp +++ b/include/range/v3/view/single.hpp @@ -61,8 +61,9 @@ namespace ranges constexpr explicit single_view(T && t) : value_(std::move(t)) {} - template(class... Args)( // - requires constructible_from) // + template(class... Args)( + /// \pre + requires constructible_from) constexpr single_view(in_place_t, Args &&... args) : single_view{in_place, meta::bool_<(bool)semiregular>{}, @@ -108,8 +109,9 @@ namespace ranges { struct single_fn { - template(typename Val)( // - requires copy_constructible) // + template(typename Val)( + /// \pre + requires copy_constructible) single_view operator()(Val value) const { return single_view{std::move(value)}; @@ -127,7 +129,8 @@ namespace ranges { using ranges::views::single; } - template(typename T)( // + template(typename T)( + /// \pre requires std::is_object::value) // using single_view = ranges::single_view; } // namespace cpp20 diff --git a/include/range/v3/view/slice.hpp b/include/range/v3/view/slice.hpp index 2380623397..6da83595ce 100644 --- a/include/range/v3/view/slice.hpp +++ b/include/range/v3/view/slice.hpp @@ -144,15 +144,17 @@ namespace ranges rng_, from_, range_tag_of{}, is_infinite{}) + count_; } - template(typename BaseRng = Rng)( // - requires range) // + template(typename BaseRng = Rng)( + /// \pre + requires range) iterator_t begin() const { return detail::pos_at_( rng_, from_, range_tag_of{}, is_infinite{}); } - template(typename BaseRng = Rng)( // - requires range) // + template(typename BaseRng = Rng)( + /// \pre + requires range) iterator_t end() const { return detail::pos_at_( @@ -202,8 +204,9 @@ namespace ranges { return {all(static_cast(rng)), from, count}; } - template(typename Rng)( // - requires borrowed_range) // + template(typename Rng)( + /// \pre + requires borrowed_range) static subrange> impl_(Rng && rng, range_difference_t from, range_difference_t count, @@ -217,7 +220,8 @@ namespace ranges public: // slice(rng, 2, 4) - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range) constexpr auto operator()(Rng && rng, range_difference_t from, @@ -230,7 +234,8 @@ namespace ranges // slice(rng, 4, end-2) // TODO Support Forward, non-Sized ranges by returning a range that // doesn't know it's size? - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range AND sized_range) auto operator()(Rng && rng, range_difference_t from, @@ -246,7 +251,8 @@ namespace ranges range_tag_of{}); } // slice(rng, end-4, end-2) - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND (forward_range || (input_range && sized_range))) auto operator()(Rng && rng, @@ -263,7 +269,8 @@ namespace ranges common_range_tag_of{}); } // slice(rng, 4, end) - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range) auto operator()(Rng && rng, range_difference_t from, end_fn) const { @@ -271,7 +278,8 @@ namespace ranges return ranges::views::drop_exactly(static_cast(rng), from); } // slice(rng, end-4, end) - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND (forward_range || (input_range && sized_range))) auto operator()(Rng && rng, @@ -293,33 +301,38 @@ namespace ranges using slice_base_fn::operator(); // Overloads for the pipe syntax: rng | views::slice(from,to) - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int from, Int to) const { return make_view_closure(bind_back(slice_base_fn{}, from, to)); } - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int from, detail::from_end_ to) const { return make_view_closure(bind_back(slice_base_fn{}, from, to)); } - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(detail::from_end_ from, detail::from_end_ to) const { return make_view_closure(bind_back(slice_base_fn{}, from, to)); } - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int from, end_fn) const { return make_view_closure( bind_back(ranges::views::drop_exactly_base_fn{}, from)); } - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(detail::from_end_ from, end_fn to) const { diff --git a/include/range/v3/view/sliding.hpp b/include/range/v3/view/sliding.hpp index 6c8381324a..2bcc7866a3 100644 --- a/include/range/v3/view/sliding.hpp +++ b/include/range/v3/view/sliding.hpp @@ -86,7 +86,8 @@ namespace ranges } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { --it_; @@ -137,7 +138,8 @@ namespace ranges return count < n ? 0 : count - n + 1; } CPP_member - auto CPP_fun(size)()( // + auto CPP_fun(size)()( + /// \pre requires sized_range) { auto const count = ranges::size(this->base()); @@ -213,7 +215,8 @@ namespace ranges } CPP_member auto prev(iterator_t & it) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { base_t::prev(); @@ -221,7 +224,8 @@ namespace ranges } CPP_member auto advance(iterator_t & it, range_difference_t n) - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires random_access_range) { it += n; @@ -313,7 +317,8 @@ namespace ranges adaptor(range_difference_t n) : n_(n) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // adaptor(adaptor that) : n_(that.n_) @@ -337,7 +342,8 @@ namespace ranges } CPP_member auto begin_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires range) { return {this->n_}; @@ -348,7 +354,8 @@ namespace ranges } CPP_member auto end_adaptor() const // - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires range) { return {this->n_}; @@ -364,7 +371,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - sliding_view(Rng &&, range_difference_t) // + sliding_view(Rng &&, range_difference_t) -> sliding_view>; #endif @@ -374,8 +381,9 @@ namespace ranges // Out: range>, where each inner range has $n$ elements. struct sliding_base_fn { - template(typename Rng)( // - requires viewable_range AND forward_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND forward_range) constexpr sliding_view> // operator()(Rng && rng, range_difference_t n) const { diff --git a/include/range/v3/view/span.hpp b/include/range/v3/view/span.hpp index 061f52e486..96f98e843b 100644 --- a/include/range/v3/view/span.hpp +++ b/include/range/v3/view/span.hpp @@ -48,8 +48,9 @@ namespace ranges /// \cond namespace detail { - template(typename To, typename From)( // - requires integral AND integral) // + template(typename To, typename From)( + /// \pre + requires integral AND integral) constexpr To narrow_cast(From from) noexcept { using C = common_type_t; @@ -167,19 +168,21 @@ namespace ranges : span{first, last - first} {} - template(typename Rng)( // - requires (!same_as>) AND // - span_compatible_range AND // - span_dynamic_conversion) // + template(typename Rng)( + /// \pre + requires (!same_as>) AND + span_compatible_range AND + span_dynamic_conversion) constexpr span(Rng && rng) noexcept(noexcept(ranges::data(rng), ranges::size(rng))) : span{ranges::data(rng), detail::narrow_cast(ranges::size(rng))} {} - template(typename Rng)( // - requires (!same_as>) AND // - span_compatible_range AND // - span_static_conversion) // + template(typename Rng)( + /// \pre + requires (!same_as>) AND + span_compatible_range AND + span_static_conversion) constexpr span(Rng && rng) noexcept(noexcept(ranges::data(rng))) : span{ranges::data(rng), N} {} @@ -304,43 +307,49 @@ namespace ranges return reverse_iterator{begin()}; } - template(typename U, index_type M)( // - requires equality_comparable_with) // + template(typename U, index_type M)( + /// \pre + requires equality_comparable_with) bool operator==(span const & that) const { RANGES_EXPECT(!size() || data()); RANGES_EXPECT(!that.size() || that.data()); return ranges::equal(*this, that); } - template(typename U, index_type M)( // - requires equality_comparable_with) // + template(typename U, index_type M)( + /// \pre + requires equality_comparable_with) bool operator!=(span const & that) const { return !(*this == that); } - template(typename U, index_type M)( // - requires totally_ordered_with) // + template(typename U, index_type M)( + /// \pre + requires totally_ordered_with) bool operator<(span const & that) const { RANGES_EXPECT(!size() || data()); RANGES_EXPECT(!that.size() || that.data()); return ranges::lexicographical_compare(*this, that); } - template(typename U, index_type M)( // - requires totally_ordered_with) // + template(typename U, index_type M)( + /// \pre + requires totally_ordered_with) bool operator>(span const & that) const { return that < *this; } - template(typename U, index_type M)( // - requires totally_ordered_with) // + template(typename U, index_type M)( + /// \pre + requires totally_ordered_with) bool operator<=(span const & that) const { return !(that < *this); } - template(typename U, index_type M)( // - requires totally_ordered_with) // + template(typename U, index_type M)( + /// \pre + requires totally_ordered_with) bool operator>=(span const & that) const { return !(*this < that); @@ -357,8 +366,9 @@ namespace ranges constexpr detail::span_index_t span::extent; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng)( // - requires contiguous_range) // + template(typename Rng)( + /// \pre + requires contiguous_range) span(Rng && rng) ->span, (range_cardinality::value < cardinality() ? dynamic_extent @@ -389,7 +399,8 @@ namespace ranges { return span{first, last}; } - template(typename Rng)( // + template(typename Rng)( + /// \pre requires contiguous_range AND (range_cardinality::value < cardinality())) // constexpr span> make_span(Rng && rng) noexcept( @@ -398,7 +409,8 @@ namespace ranges return {ranges::data(rng), detail::narrow_cast(ranges::size(rng))}; } - template(typename Rng)( // + template(typename Rng)( + /// \pre requires contiguous_range AND (range_cardinality::value >= cardinality())) // constexpr span< diff --git a/include/range/v3/view/split.hpp b/include/range/v3/view/split.hpp index b21eb306f8..facf1b37f1 100644 --- a/include/range/v3/view/split.hpp +++ b/include/range/v3/view/split.hpp @@ -245,7 +245,8 @@ namespace ranges CPP_broken_friend_member friend constexpr auto operator==(split_inner_iterator const & x, split_inner_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires forward_range) { return x.i_.curr_ == y.i_.curr_; @@ -253,7 +254,8 @@ namespace ranges CPP_broken_friend_member friend constexpr auto operator!=(split_inner_iterator const & x, split_inner_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires forward_range) { return x.i_.curr_ != y.i_.curr_; @@ -304,7 +306,8 @@ namespace ranges split_inner_iterator const & x, split_inner_iterator const & y) noexcept(noexcept(ranges::iter_swap(x.current_(), y.current_()))) - -> CPP_broken_friend_ret(void)( // + -> CPP_broken_friend_ret(void)( + /// \pre requires indirectly_swappable>) { ranges::iter_swap(x.current_(), y.current_()); @@ -386,22 +389,25 @@ namespace ranges split_outer_iterator() = default; CPP_member - constexpr explicit CPP_ctor(split_outer_iterator)(Parent & parent)( // + constexpr explicit CPP_ctor(split_outer_iterator)(Parent & parent)( + /// \pre requires (!forward_range)) : parent_(&parent) {} CPP_member constexpr CPP_ctor(split_outer_iterator)(Parent & parent, - iterator_t current)( // + iterator_t current)( + /// \pre requires forward_range) : Current{std::move(current)} , parent_(&parent) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other) AND - convertible_to, iterator_t>) // + convertible_to, iterator_t>) constexpr split_outer_iterator( split_outer_iterator, Other> i) : Current{std::move(i.curr_)} @@ -455,7 +461,8 @@ namespace ranges CPP_broken_friend_member friend constexpr auto operator==(split_outer_iterator const & x, split_outer_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires forward_range) { return x.curr_ == y.curr_; @@ -463,7 +470,8 @@ namespace ranges CPP_broken_friend_member friend constexpr auto operator!=(split_outer_iterator const & x, split_outer_iterator const & y) - -> CPP_broken_friend_ret(bool)( // + -> CPP_broken_friend_ret(bool)( + /// \pre requires forward_range) { return x.curr_ != y.curr_; @@ -557,6 +565,7 @@ namespace ranges CPP_member constexpr CPP_ctor(split_view)(V base, range_value_t e)( + /// \pre requires constructible_from>) : base_(std::move(base)) , pattern_(e) @@ -583,14 +592,16 @@ namespace ranges } CPP_member constexpr auto begin() const // - -> CPP_ret(outer_iterator)( // + -> CPP_ret(outer_iterator)( + /// \pre requires forward_range && forward_range) { return {*this, ranges::begin(base_)}; } CPP_member constexpr auto end() // - -> CPP_ret(outer_iterator()>)( // + -> CPP_ret(outer_iterator()>)( + /// \pre requires forward_range && common_range) { return outer_iterator()>{*this, ranges::end(base_)}; @@ -611,7 +622,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename R, typename P)( // + template(typename R, typename P)( + /// \pre requires input_range AND forward_range

AND viewable_range AND viewable_range

AND indirectly_comparable, iterator_t

, ranges::equal_to> AND @@ -619,8 +631,9 @@ namespace ranges split_view(R &&, P &&) ->split_view, views::all_t

>; - template(typename R)( // - requires input_range) // + template(typename R)( + /// \pre + requires input_range) split_view(R &&, range_value_t) ->split_view, single_view>>; #endif @@ -629,18 +642,20 @@ namespace ranges { struct split_base_fn { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range AND indirectly_comparable, range_value_t const *, - ranges::equal_to>) // + ranges::equal_to>) constexpr split_view, single_view>> // operator()(Rng && rng, range_value_t val) const { return {all(static_cast(rng)), single(std::move(val))}; } - template(typename Rng, typename Pattern)( // + template(typename Rng, typename Pattern)( + /// \pre requires viewable_range AND input_range AND viewable_range AND forward_range AND indirectly_comparable< @@ -677,9 +692,10 @@ namespace ranges { using ranges::views::split; } - template(typename Rng, typename Pattern)( // + template(typename Rng, typename Pattern)( + /// \pre requires input_range AND forward_range AND view_ AND - view_ AND // + view_ AND indirectly_comparable< iterator_t, iterator_t, diff --git a/include/range/v3/view/split_when.hpp b/include/range/v3/view/split_when.hpp index 4e9925f146..21f55aa783 100644 --- a/include/range/v3/view/split_when.hpp +++ b/include/range/v3/view/split_when.hpp @@ -126,7 +126,8 @@ namespace ranges public: cursor() = default; - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) // cursor(cursor that) : cursor{std::move(that.cur_), std::move(that.last_), std::move(that.fun_)} @@ -136,10 +137,11 @@ namespace ranges { return {fun_, ranges::begin(rng_), ranges::end(rng_)}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND invocable>, - sentinel_t>>) // + sentinel_t>>) cursor begin_cursor() const { return {fun_, ranges::begin(rng_), ranges::end(rng_)}; @@ -154,7 +156,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires copy_constructible) split_when_view(Rng &&, Fun) -> split_when_view, Fun>; @@ -170,8 +173,9 @@ namespace ranges { semiregular_box_t pred_; - template(typename I, typename S)( // - requires sentinel_for) // + template(typename I, typename S)( + /// \pre + requires sentinel_for) std::pair operator()(I cur, S last) const { auto where = ranges::find_if_not(cur, last, std::ref(pred_)); @@ -180,22 +184,24 @@ namespace ranges }; public: - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires viewable_range AND forward_range AND invocable, sentinel_t> AND invocable, iterator_t> AND copy_constructible AND convertible_to< invoke_result_t, sentinel_t>, - std::pair>>) // + std::pair>>) split_when_view, Fun> operator()(Rng && rng, Fun fun) const // { return {all(static_cast(rng)), std::move(fun)}; } - template(typename Rng, typename Fun)( // - requires viewable_range AND forward_range AND // + template(typename Rng, typename Fun)( + /// \pre + requires viewable_range AND forward_range AND predicate> AND - copy_constructible) // + copy_constructible) split_when_view, predicate_pred_> // operator()(Rng && rng, Fun fun) const { diff --git a/include/range/v3/view/stride.hpp b/include/range/v3/view/stride.hpp index f602e4a6e2..bf0edb9e32 100644 --- a/include/range/v3/view/stride.hpp +++ b/include/range/v3/view/stride.hpp @@ -169,7 +169,8 @@ namespace ranges constexpr adaptor(stride_view_t * rng) noexcept : rng_(rng) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // adaptor(adaptor that) : rng_(that.rng_) @@ -186,7 +187,8 @@ namespace ranges } CPP_member constexpr auto prev(iterator_t & it) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range) { RANGES_EXPECT(it != ranges::begin(rng_->base())); @@ -198,8 +200,9 @@ namespace ranges } ranges::advance(it, delta); } - template(typename Other)( // - requires sized_sentinel_for>) // + template(typename Other)( + /// \pre + requires sized_sentinel_for>) constexpr range_difference_t distance_to(iterator_t const & here, Other const & there) const { @@ -212,7 +215,8 @@ namespace ranges } CPP_member constexpr auto advance(iterator_t & it, range_difference_t n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires random_access_range) { if(0 == n) @@ -252,7 +256,8 @@ namespace ranges } CPP_member constexpr auto begin_adaptor() const noexcept - -> CPP_ret(adaptor)( // + -> CPP_ret(adaptor)( + /// \pre requires(const_iterable())) { return adaptor{this}; @@ -265,7 +270,8 @@ namespace ranges } CPP_member constexpr auto end_adaptor() const noexcept // - -> CPP_ret(meta::if_c(), adaptor, adaptor_base>)( // + -> CPP_ret(meta::if_c(), adaptor, adaptor_base>)( + /// \pre requires (const_iterable())) { return {this}; @@ -277,7 +283,8 @@ namespace ranges : detail::stride_view_base{std::move(rng), stride} {} CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires sized_range) { using size_type = range_size_t; @@ -298,7 +305,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - stride_view(Rng &&, range_difference_t) // + stride_view(Rng &&, range_difference_t) -> stride_view>; #endif @@ -306,8 +313,9 @@ namespace ranges { struct stride_base_fn { - template(typename Rng)( // - requires viewable_range AND input_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range) constexpr stride_view> // operator()(Rng && rng, range_difference_t step) const { @@ -319,7 +327,8 @@ namespace ranges { using stride_base_fn::operator(); - template(typename Difference)( // + template(typename Difference)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Difference step) const { diff --git a/include/range/v3/view/subrange.hpp b/include/range/v3/view/subrange.hpp index 45a966d3c4..79f096a05d 100644 --- a/include/range/v3/view/subrange.hpp +++ b/include/range/v3/view/subrange.hpp @@ -81,8 +81,8 @@ namespace ranges template(typename T)( // concept (pair_like_)(T), // - is_complete_> AND // - derived_from, meta::size_t<2>> AND // + is_complete_> AND + derived_from, meta::size_t<2>> AND detail::pair_like_impl_); template @@ -121,8 +121,9 @@ namespace ranges CPP_concept_ref(detail::range_convertible_to_impl_, R, I, S); // clang-format on - template(typename S, typename I)( // - requires sentinel_for) // + template(typename S, typename I)( + /// \pre + requires sentinel_for) constexpr bool is_sized_sentinel_() noexcept { return (bool)sized_sentinel_for; @@ -151,13 +152,15 @@ namespace ranges struct adl_hook {}; - template(std::size_t N, typename I, typename S, subrange_kind K)( // + template(std::size_t N, typename I, typename S, subrange_kind K)( + /// \pre requires (N == 0)) // constexpr I get(subrange const & r) { return r.begin(); } - template(std::size_t N, typename I, typename S, subrange_kind K)( // + template(std::size_t N, typename I, typename S, subrange_kind K)( + /// \pre requires (N == 1)) // constexpr S get(subrange const & r) { @@ -185,15 +188,17 @@ namespace ranges subrange() = default; - template(typename I2)( // - requires detail::convertible_to_not_slicing_ AND // + template(typename I2)( + /// \pre + requires detail::convertible_to_not_slicing_ AND (!detail::store_size_())) // constexpr subrange(I2 && i, S s) : data_{static_cast(i), std::move(s)} {} - template(typename I2)( // - requires detail::convertible_to_not_slicing_ AND // + template(typename I2)( + /// \pre + requires detail::convertible_to_not_slicing_ AND (detail::store_size_())) // constexpr subrange(I2 && i, S s, size_type n) : data_{static_cast(i), std::move(s), n} @@ -205,9 +210,10 @@ namespace ranges RANGES_EXPECT(ranges::next(first_(), (D)n) == last_()); } } - template(typename I2)( // - requires detail::convertible_to_not_slicing_ AND // - sized_sentinel_for) // + template(typename I2)( + /// \pre + requires detail::convertible_to_not_slicing_ AND + sized_sentinel_for) constexpr subrange(I2 && i, S s, size_type n) : data_{static_cast(i), std::move(s)} { @@ -215,25 +221,28 @@ namespace ranges } template(typename R)( - requires (!same_as, subrange>) AND // - detail::range_convertible_to_ AND // + /// \pre + requires (!same_as, subrange>) AND + detail::range_convertible_to_ AND (!detail::store_size_())) constexpr subrange(R && r) : subrange{ranges::begin(r), ranges::end(r)} {} - template(typename R)( // - requires (!same_as, subrange>) AND // - detail::range_convertible_to_ AND // - (detail::store_size_()) AND // - sized_range) // + template(typename R)( + /// \pre + requires (!same_as, subrange>) AND + detail::range_convertible_to_ AND + (detail::store_size_()) AND + sized_range) constexpr subrange(R && r) : subrange{ranges::begin(r), ranges::end(r), ranges::size(r)} {} - template(typename R)( // - requires (K == subrange_kind::sized) AND // - detail::range_convertible_to_) // + template(typename R)( + /// \pre + requires (K == subrange_kind::sized) AND + detail::range_convertible_to_) constexpr subrange(R && r, size_type n) // : subrange{ranges::begin(r), ranges::end(r), n} { @@ -243,9 +252,10 @@ namespace ranges } } - template(typename PairLike)( // - requires (!same_as) AND // - detail::pair_like_convertible_from_) // + template(typename PairLike)( + /// \pre + requires (!same_as) AND + detail::pair_like_convertible_from_) constexpr operator PairLike() const { return PairLike(first_(), last_()); @@ -266,7 +276,8 @@ namespace ranges CPP_member constexpr auto size() const // - -> CPP_ret(size_type)( // + -> CPP_ret(size_type)( + /// \pre requires (K == subrange_kind::sized)) { return get_size_(); @@ -282,7 +293,8 @@ namespace ranges CPP_member RANGES_NODISCARD constexpr auto prev(iter_difference_t n = 1) const - -> CPP_ret(subrange)( // + -> CPP_ret(subrange)( + /// \pre requires bidirectional_iterator) { auto tmp = *this; @@ -323,14 +335,16 @@ namespace ranges } CPP_member constexpr auto get_size_() const // - -> CPP_ret(size_type)( // + -> CPP_ret(size_type)( + /// \pre requires sized_sentinel_for) { return static_cast(last_() - first_()); } CPP_member constexpr auto get_size_() const noexcept // - -> CPP_ret(size_type)( // + -> CPP_ret(size_type)( + /// \pre requires (detail::store_size_())) { return std::get<2>(data_); @@ -339,7 +353,8 @@ namespace ranges {} CPP_member constexpr auto set_size_(size_type n) noexcept // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires (detail::store_size_())) { std::get<2>(data_) = n; @@ -351,13 +366,15 @@ namespace ranges subrange(I, S) // -> subrange; - template(typename I, typename S)( // - requires input_or_output_iterator AND sentinel_for) // - subrange(I, S, detail::iter_size_t) // + template(typename I, typename S)( + /// \pre + requires input_or_output_iterator AND sentinel_for) + subrange(I, S, detail::iter_size_t) -> subrange; - template(typename R)( // - requires borrowed_range) // + template(typename R)( + /// \pre + requires borrowed_range) subrange(R &&) // -> subrange, sentinel_t, (sized_range || @@ -365,9 +382,10 @@ namespace ranges ? subrange_kind::sized : subrange_kind::unsized>; - template(typename R)( // - requires borrowed_range) // - subrange(R &&, detail::iter_size_t>) // + template(typename R)( + /// \pre + requires borrowed_range) + subrange(R &&, detail::iter_size_t>) -> subrange, sentinel_t, subrange_kind::sized>; #endif @@ -379,15 +397,17 @@ namespace ranges { return {i, s}; } - template(typename I, typename S)( // - requires input_or_output_iterator AND sentinel_for) // + template(typename I, typename S)( + /// \pre + requires input_or_output_iterator AND sentinel_for) constexpr subrange // operator()(I i, S s, detail::iter_size_t n) const { return {i, s, n}; } - template(typename R)( // - requires borrowed_range) // + template(typename R)( + /// \pre + requires borrowed_range) constexpr auto operator()(R && r) const -> subrange, sentinel_t, (sized_range || sized_sentinel_for, iterator_t>) @@ -396,8 +416,9 @@ namespace ranges { return {(R &&) r}; } - template(typename R)( // - requires borrowed_range) // + template(typename R)( + /// \pre + requires borrowed_range) constexpr subrange, sentinel_t, subrange_kind::sized> // operator()(R && r, detail::iter_size_t> n) const { @@ -420,8 +441,9 @@ namespace ranges typename S = I, // subrange_kind K = // static_cast( // - detail::is_sized_sentinel_()))( // - requires input_or_output_iterator AND sentinel_for AND // + detail::is_sized_sentinel_()))( + /// \pre + requires input_or_output_iterator AND sentinel_for AND (K == subrange_kind::sized || !sized_sentinel_for)) // using subrange = ranges::subrange; diff --git a/include/range/v3/view/tail.hpp b/include/range/v3/view/tail.hpp index f9b1fbcae3..512d35731d 100644 --- a/include/range/v3/view/tail.hpp +++ b/include/range/v3/view/tail.hpp @@ -65,8 +65,9 @@ namespace ranges { return next(ranges::begin(rng_), 1, ranges::end(rng_)); } - template(bool Const = true)( // - requires Const AND range>) // + template(bool Const = true)( + /// \pre + requires Const AND range>) iterator_t> begin() const { return next(ranges::begin(rng_), 1, ranges::end(rng_)); @@ -75,15 +76,17 @@ namespace ranges { return ranges::end(rng_); } - template(bool Const = true)( // - requires Const AND range>) // + template(bool Const = true)( + /// \pre + requires Const AND range>) sentinel_t> end() const { return ranges::end(rng_); } // Strange cast to bool in the requires clause is to work around gcc bug. CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires(bool(sized_range))) { using size_type = range_size_t; @@ -111,8 +114,9 @@ namespace ranges enable_borrowed_range; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng)( // - requires viewable_range) // + template(typename Rng)( + /// \pre + requires viewable_range) tail_view(Rng &&) ->tail_view>; #endif @@ -121,8 +125,9 @@ namespace ranges { struct tail_fn { - template(typename Rng)( // - requires viewable_range AND input_range) // + template(typename Rng)( + /// \pre + requires viewable_range AND input_range) meta::if_c::value == 0, all_t, tail_view>> // diff --git a/include/range/v3/view/take.hpp b/include/range/v3/view/take.hpp index 8137c0ac38..283a27bd5c 100644 --- a/include/range/v3/view/take.hpp +++ b/include/range/v3/view/take.hpp @@ -52,10 +52,11 @@ namespace ranges constexpr explicit sentinel(sentinel_t last) : end_(std::move(last)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other) AND convertible_to, - sentinel_t>) // + sentinel_t>) constexpr sentinel(sentinel that) : end_(std::move(that.end_)) {} @@ -161,7 +162,8 @@ namespace ranges } CPP_member - constexpr auto CPP_fun(begin)()( // + constexpr auto CPP_fun(begin)()( + /// \pre requires(!simple_view())) { #if RANGES_CXX_IF_CONSTEXPR >= RANGES_CXX_IF_CONSTEXPR_17 @@ -208,7 +210,8 @@ namespace ranges } CPP_member - constexpr auto CPP_fun(end)()( // + constexpr auto CPP_fun(end)()( + /// \pre requires(!simple_view())) { #if RANGES_CXX_IF_CONSTEXPR >= RANGES_CXX_IF_CONSTEXPR_17 @@ -251,7 +254,8 @@ namespace ranges } CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires sized_range) { auto n = ranges::size(base_); @@ -272,7 +276,7 @@ namespace ranges #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template - take_view(Rng &&, range_difference_t) // + take_view(Rng &&, range_difference_t) -> take_view>; #endif @@ -280,8 +284,9 @@ namespace ranges { struct take_base_fn { - template(typename Rng)( // - requires viewable_range) // + template(typename Rng)( + /// \pre + requires viewable_range) take_view> operator()(Rng && rng, range_difference_t n) const { return {all(static_cast(rng)), n}; @@ -292,7 +297,8 @@ namespace ranges { using take_base_fn::operator(); - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { @@ -311,8 +317,9 @@ namespace ranges { using ranges::views::take; } - template(typename Rng)( // - requires view_) // + template(typename Rng)( + /// \pre + requires view_) using take_view = ranges::take_view; } // namespace cpp20 /// @} diff --git a/include/range/v3/view/take_exactly.hpp b/include/range/v3/view/take_exactly.hpp index f8d44b0eed..c38e56c7c4 100644 --- a/include/range/v3/view/take_exactly.hpp +++ b/include/range/v3/view/take_exactly.hpp @@ -68,8 +68,9 @@ namespace ranges { return {ranges::begin(rng_), n_}; } - template(typename BaseRng = Rng)( // - requires range) // + template(typename BaseRng = Rng)( + /// \pre + requires range) counted_iterator> begin() const { return {ranges::begin(rng_), n_}; @@ -158,8 +159,9 @@ namespace ranges { return {all(static_cast(rng)), n}; } - template(typename Rng)( // - requires borrowed_range) // + template(typename Rng)( + /// \pre + requires borrowed_range) static constexpr subrange> impl_(Rng && rng, range_difference_t n, random_access_range_tag) @@ -168,7 +170,8 @@ namespace ranges } public: - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND input_range) constexpr auto operator()(Rng && rng, range_difference_t n) const { @@ -181,7 +184,8 @@ namespace ranges { using take_exactly_base_fn::operator(); - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { diff --git a/include/range/v3/view/take_last.hpp b/include/range/v3/view/take_last.hpp index b6da09b5ae..fb5c02ba50 100644 --- a/include/range/v3/view/take_last.hpp +++ b/include/range/v3/view/take_last.hpp @@ -31,7 +31,8 @@ namespace ranges { struct take_last_base_fn { - template(typename Rng)( // + template(typename Rng)( + /// \pre requires viewable_range AND sized_range) auto operator()(Rng && rng, range_difference_t n) const { @@ -44,7 +45,8 @@ namespace ranges { using take_last_base_fn::operator(); - template(typename Int)( // + template(typename Int)( + /// \pre requires detail::integer_like_) constexpr auto operator()(Int n) const { diff --git a/include/range/v3/view/take_while.hpp b/include/range/v3/view/take_while.hpp index aef22f77db..e04eacdcdd 100644 --- a/include/range/v3/view/take_while.hpp +++ b/include/range/v3/view/take_while.hpp @@ -60,7 +60,8 @@ namespace ranges sentinel_adaptor(semiregular_box_ref_or_val_t pred) : pred_(std::move(pred)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) // sentinel_adaptor(sentinel_adaptor that) : pred_(std::move(that.pred_)) @@ -74,9 +75,10 @@ namespace ranges { return {pred_}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND - invocable>>) // + invocable>>) sentinel_adaptor end_adaptor() const { return {pred_}; @@ -101,7 +103,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires copy_constructible) take_while_view(Rng &&, Fun) -> take_while_view, Fun>; @@ -111,9 +114,10 @@ namespace ranges { struct iter_take_while_base_fn { - template(typename Rng, typename Pred)( // - requires viewable_range AND input_range AND // - predicate> AND copy_constructible) // + template(typename Rng, typename Pred)( + /// \pre + requires viewable_range AND input_range AND + predicate> AND copy_constructible) constexpr iter_take_while_view, Pred> // operator()(Rng && rng, Pred pred) const { @@ -135,17 +139,19 @@ namespace ranges struct take_while_base_fn { - template(typename Rng, typename Pred)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate>) // + template(typename Rng, typename Pred)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate>) constexpr take_while_view, Pred> // operator()(Rng && rng, Pred pred) const { return {all(static_cast(rng)), std::move(pred)}; } - template(typename Rng, typename Pred, typename Proj)( // - requires viewable_range AND input_range AND // - indirect_unary_predicate &, iterator_t>) // + template(typename Rng, typename Pred, typename Proj)( + /// \pre + requires viewable_range AND input_range AND + indirect_unary_predicate &, iterator_t>) constexpr take_while_view, composed> // operator()(Rng && rng, Pred pred, Proj proj) const { @@ -162,7 +168,8 @@ namespace ranges return make_view_closure( bind_back(take_while_base_fn{}, std::move(pred))); } - template(typename Pred, typename Proj)( // + template(typename Pred, typename Proj)( + /// \pre requires (!range)) // TODO: underconstrained constexpr auto operator()(Pred && pred, Proj proj) const @@ -194,9 +201,10 @@ namespace ranges { using ranges::views::take_while; } - template(typename Rng, typename Pred)( // + template(typename Rng, typename Pred)( + /// \pre requires viewable_range AND input_range AND - predicate> AND copy_constructible) // + predicate> AND copy_constructible) using take_while_view = ranges::take_while_view; } // namespace cpp20 /// @} diff --git a/include/range/v3/view/tokenize.hpp b/include/range/v3/view/tokenize.hpp index ce22726330..a264bccbd3 100644 --- a/include/range/v3/view/tokenize.hpp +++ b/include/range/v3/view/tokenize.hpp @@ -68,8 +68,9 @@ namespace ranges meta::const_if_c(), Rng> & rng = rng_; return {ranges::begin(rng), ranges::end(rng), rex_, subs_, flags_}; } - template(bool Const = true)( // - requires range) // + template(bool Const = true)( + /// \pre + requires range) iterator_t begin() const { return {ranges::begin(rng_), ranges::end(rng_), rex_, subs_, flags_}; @@ -78,8 +79,9 @@ namespace ranges { return {}; } - template(bool Const = true)( // - requires range) // + template(bool Const = true)( + /// \pre + requires range) iterator_t end() const { return {}; @@ -91,7 +93,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Regex, typename SubMatchRange)( // + template(typename Rng, typename Regex, typename SubMatchRange)( + /// \pre requires copy_constructible AND copy_constructible) tokenize_view(Rng &&, Regex, SubMatchRange) ->tokenize_view, Regex, SubMatchRange>; @@ -101,11 +104,12 @@ namespace ranges { struct tokenize_base_fn { - template(typename Rng, typename Regex)( // - requires bidirectional_range AND common_range AND // + template(typename Rng, typename Regex)( + /// \pre + requires bidirectional_range AND common_range AND same_as< // range_value_t, // - typename detail::decay_t::value_type>) // + typename detail::decay_t::value_type>) tokenize_view, detail::decay_t, int> // operator()(Rng && rng, Regex && rex, @@ -119,10 +123,11 @@ namespace ranges flags}; } - template(typename Rng, typename Regex)( // - requires bidirectional_range AND common_range AND // + template(typename Rng, typename Regex)( + /// \pre + requires bidirectional_range AND common_range AND same_as, - typename detail::decay_t::value_type>) // + typename detail::decay_t::value_type>) tokenize_view, detail::decay_t, std::vector> // operator()(Rng && rng, Regex && rex, @@ -136,10 +141,11 @@ namespace ranges flags}; } - template(typename Rng, typename Regex)( // - requires bidirectional_range AND common_range AND // + template(typename Rng, typename Regex)( + /// \pre + requires bidirectional_range AND common_range AND same_as, - typename detail::decay_t::value_type>) // + typename detail::decay_t::value_type>) tokenize_view, detail::decay_t, std::initializer_list> // diff --git a/include/range/v3/view/transform.hpp b/include/range/v3/view/transform.hpp index 25afc661bd..e5f40f6553 100644 --- a/include/range/v3/view/transform.hpp +++ b/include/range/v3/view/transform.hpp @@ -125,7 +125,8 @@ namespace ranges adaptor(fun_ref_ fun) : fun_(std::move(fun)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires IsConst AND CPP_NOT(Other)) // adaptor(adaptor that) : fun_(std::move(that.fun_)) @@ -147,10 +148,11 @@ namespace ranges { return {fun_}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND detail::iter_transform_1_readable>) // + meta::const_if_c>) adaptor begin_adaptor() const { return {fun_}; @@ -159,10 +161,11 @@ namespace ranges { return {fun_}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND detail::iter_transform_1_readable>) // + meta::const_if_c>) meta::if_, adaptor_base, adaptor> end_adaptor() const { return {fun_}; @@ -175,7 +178,8 @@ namespace ranges , fun_(std::move(fun)) {} CPP_member - constexpr auto CPP_fun(size)()( // + constexpr auto CPP_fun(size)()( + /// \pre requires sized_range) { return ranges::size(this->base()); @@ -199,7 +203,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Rng, typename Fun)( // + template(typename Rng, typename Fun)( + /// \pre requires copy_constructible) transform_view(Rng &&, Fun) -> transform_view, Fun>; @@ -240,7 +245,8 @@ namespace ranges : end1_(end(parent->rng1_)) , end2_(end(parent->rng2_)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // sentinel(sentinel that) : end1_(std::move(that.end1_)) @@ -275,7 +281,8 @@ namespace ranges , it1_(begin_end(parent->rng1_)) , it2_(begin_end(parent->rng2_)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // cursor(cursor that) : fun_(std::move(that.fun_)) @@ -295,7 +302,8 @@ namespace ranges } CPP_member auto equal(cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires forward_range && forward_range) { // By returning true if *any* of the iterators are equal, we allow @@ -312,14 +320,16 @@ namespace ranges } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires bidirectional_range && bidirectional_range) { --it1_; --it2_; } CPP_member - auto advance(difference_type n) -> CPP_ret(void)( // + auto advance(difference_type n) -> CPP_ret(void)( + /// \pre requires random_access_range && random_access_range) { ranges::advance(it1_, n); @@ -327,7 +337,8 @@ namespace ranges } CPP_member auto distance_to(cursor const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires sized_sentinel_for, iterator_t> && sized_sentinel_for, iterator_t>) { @@ -360,24 +371,26 @@ namespace ranges { return {this, ranges::end}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND - range> AND // + range> AND detail::iter_transform_2_readable< // Fun const, // meta::const_if_c, // - meta::const_if_c>) // + meta::const_if_c>) cursor begin_cursor() const { return {this, ranges::begin}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND range> AND - range> AND // + range> AND detail::iter_transform_2_readable< // Fun const, // meta::const_if_c, // - meta::const_if_c>) // + meta::const_if_c>) end_cursor_t end_cursor() const { return {this, ranges::end}; @@ -404,22 +417,25 @@ namespace ranges {} CPP_member static constexpr auto size() // - -> CPP_ret(std::size_t)( // + -> CPP_ret(std::size_t)( + /// \pre requires (my_cardinality >= 0)) { return static_cast(my_cardinality); } - template(bool True = true)( // + template(bool True = true)( + /// \pre requires (my_cardinality < 0) AND sized_range AND sized_range AND - common_with>, range_size_t>>) // + common_with>, range_size_t>>) constexpr auto size() const { return size_(*this); } - template(bool True = true)( // + template(bool True = true)( + /// \pre requires (my_cardinality < 0) AND sized_range AND sized_range AND - common_with>, range_size_t>>) // + common_with>, range_size_t>>) constexpr auto size() { return size_(*this); @@ -441,22 +457,24 @@ namespace ranges { struct iter_transform_base_fn { - template(typename Rng, typename Fun)( // - requires viewable_range AND input_range AND // - copy_constructible AND // - detail::iter_transform_1_readable) // + template(typename Rng, typename Fun)( + /// \pre + requires viewable_range AND input_range AND + copy_constructible AND + detail::iter_transform_1_readable) constexpr iter_transform_view, Fun> // operator()(Rng && rng, Fun fun) const { return {all(static_cast(rng)), std::move(fun)}; } - template(typename Rng1, typename Rng2, typename Fun)( // + template(typename Rng1, typename Rng2, typename Fun)( + /// \pre requires viewable_range AND input_range AND viewable_range AND input_range AND copy_constructible AND common_with, range_difference_t> AND - detail::iter_transform_2_readable) // + detail::iter_transform_2_readable) constexpr iter_transform2_view, all_t, Fun> // operator()(Rng1 && rng1, Rng2 && rng2, Fun fun) const { @@ -512,16 +530,18 @@ namespace ranges struct transform_base_fn { - template(typename Rng, typename Fun)( // - requires transformable_range) // + template(typename Rng, typename Fun)( + /// \pre + requires transformable_range) constexpr transform_view, Fun> operator()(Rng && rng, Fun fun) const { return {all(static_cast(rng)), std::move(fun)}; } - template(typename Rng1, typename Rng2, typename Fun)( // - requires transformable_ranges) // + template(typename Rng1, typename Rng2, typename Fun)( + /// \pre + requires transformable_ranges) constexpr transform2_view, all_t, Fun> // operator()(Rng1 && rng1, Rng2 && rng2, Fun fun) const { @@ -553,10 +573,11 @@ namespace ranges { using ranges::views::transform; } - template(typename Rng, typename F)( // + template(typename Rng, typename F)( + /// \pre requires input_range AND copy_constructible AND view_ AND std::is_object::value AND - regular_invocable>>) // + regular_invocable>>) using transform_view = ranges::transform_view; } // namespace cpp20 /// @} diff --git a/include/range/v3/view/trim.hpp b/include/range/v3/view/trim.hpp index d770d1abfd..e63f2148c7 100644 --- a/include/range/v3/view/trim.hpp +++ b/include/range/v3/view/trim.hpp @@ -104,19 +104,21 @@ namespace ranges { struct trim_base_fn { - template(typename Rng, typename Pred)( // - requires viewable_range AND bidirectional_range AND // - indirect_unary_predicate> AND // - common_range) // + template(typename Rng, typename Pred)( + /// \pre + requires viewable_range AND bidirectional_range AND + indirect_unary_predicate> AND + common_range) constexpr trim_view, Pred> // operator()(Rng && rng, Pred pred) const // { return {all(static_cast(rng)), std::move(pred)}; } - template(typename Rng, typename Pred, typename Proj)( // - requires viewable_range AND bidirectional_range AND // - indirect_unary_predicate, iterator_t> AND // - common_range) // + template(typename Rng, typename Pred, typename Proj)( + /// \pre + requires viewable_range AND bidirectional_range AND + indirect_unary_predicate, iterator_t> AND + common_range) constexpr trim_view, composed> // operator()(Rng && rng, Pred pred, Proj proj) const { @@ -132,7 +134,8 @@ namespace ranges { return make_view_closure(bind_back(trim_base_fn{}, std::move(pred))); } - template(typename Pred, typename Proj)( // + template(typename Pred, typename Proj)( + /// \pre requires (!range)) // TODO: underconstrained constexpr auto operator()(Pred && pred, Proj proj) const { diff --git a/include/range/v3/view/unbounded.hpp b/include/range/v3/view/unbounded.hpp index 4220d48991..92f9c99885 100644 --- a/include/range/v3/view/unbounded.hpp +++ b/include/range/v3/view/unbounded.hpp @@ -52,8 +52,9 @@ namespace ranges { struct unbounded_fn { - template(typename I)( // - requires input_iterator) // + template(typename I)( + /// \pre + requires input_iterator) constexpr unbounded_view operator()(I it) const { return unbounded_view{detail::move(it)}; diff --git a/include/range/v3/view/unique.hpp b/include/range/v3/view/unique.hpp index 8c7e236b58..e24b398e42 100644 --- a/include/range/v3/view/unique.hpp +++ b/include/range/v3/view/unique.hpp @@ -37,9 +37,10 @@ namespace ranges { struct unique_base_fn { - template(typename Rng, typename C = equal_to)( // - requires viewable_range AND forward_range AND // - indirect_relation>) // + template(typename Rng, typename C = equal_to)( + /// \pre + requires viewable_range AND forward_range AND + indirect_relation>) constexpr adjacent_filter_view, logical_negate> // operator()(Rng && rng, C pred = {}) const { @@ -51,7 +52,8 @@ namespace ranges { using unique_base_fn::operator(); - template(typename C)( // + template(typename C)( + /// \pre requires (!range)) constexpr auto operator()(C && pred) const { diff --git a/include/range/v3/view/view.hpp b/include/range/v3/view/view.hpp index 96b5ebdfe8..b24cf0bc7c 100644 --- a/include/range/v3/view/view.hpp +++ b/include/range/v3/view/view.hpp @@ -103,9 +103,10 @@ namespace ranges { // Piping requires viewable_ranges. Pipeing a value into a closure // should not yield another closure. - template(typename Rng, typename ViewFn)( // - requires viewable_range AND // - invocable_view_closure) // + template(typename Rng, typename ViewFn)( + /// \pre + requires viewable_range AND + invocable_view_closure) friend constexpr auto operator|(Rng && rng, view_closure vw) { return static_cast(vw)(static_cast(rng)); @@ -133,6 +134,7 @@ namespace ranges template friend constexpr auto operator|(view_closure vw, Pipeable pipe) -> CPP_broken_friend_ret(view_closure>)( + /// \pre requires (is_pipeable_v)) { return make_view_closure( @@ -229,7 +231,8 @@ namespace ranges friend pipeable_access; // Piping requires range arguments or lvalue containers. - template(typename Rng, typename Vw)( // + template(typename Rng, typename Vw)( + /// \pre requires viewable_range AND invocable) static constexpr auto pipe(Rng && rng, Vw && v) { @@ -245,7 +248,8 @@ namespace ranges {} // Calling directly requires a viewable_range. - template(typename Rng, typename... Rest)( // + template(typename Rng, typename... Rest)( + /// \pre requires viewable_range AND invocable) constexpr invoke_result_t // operator()(Rng && rng, Rest &&... rest) const diff --git a/include/range/v3/view/zip.hpp b/include/range/v3/view/zip.hpp index bee43a2ed2..c836458387 100644 --- a/include/range/v3/view/zip.hpp +++ b/include/range/v3/view/zip.hpp @@ -38,7 +38,8 @@ namespace ranges struct indirect_zip_fn_ { // tuple value - template(typename... Its)( // + template(typename... Its)( + /// \pre requires (sizeof...(Its) != 2) AND and_v...>) std::tuple...> operator()(copy_tag, Its...) const { @@ -46,7 +47,8 @@ namespace ranges } // tuple reference - template(typename... Its)( // + template(typename... Its)( + /// \pre requires (sizeof...(Its) != 2) AND and_v...>) common_tuple...> operator()(Its const &... its) const // @@ -56,7 +58,8 @@ namespace ranges } // tuple rvalue reference - template(typename... Its)( // + template(typename... Its)( + /// \pre requires (sizeof...(Its) != 2) AND and_v...>) common_tuple...> // operator()(move_tag, Its const &... its) const // @@ -67,8 +70,9 @@ namespace ranges } // pair value - template(typename It1, typename It2)( // - requires indirectly_readable AND indirectly_readable) // + template(typename It1, typename It2)( + /// \pre + requires indirectly_readable AND indirectly_readable) std::pair, iter_value_t> // operator()(copy_tag, It1, It2) const { @@ -76,8 +80,9 @@ namespace ranges } // pair reference - template(typename It1, typename It2)( // - requires indirectly_readable AND indirectly_readable) // + template(typename It1, typename It2)( + /// \pre + requires indirectly_readable AND indirectly_readable) common_pair, iter_reference_t> operator()(It1 const & it1, It2 const & it2) const // noexcept( // @@ -88,8 +93,9 @@ namespace ranges } // pair rvalue reference - template(typename It1, typename It2)( // - requires indirectly_readable AND indirectly_readable) // + template(typename It1, typename It2)( + /// \pre + requires indirectly_readable AND indirectly_readable) common_pair, iter_rvalue_reference_t> operator()(move_tag, It1 const & it1, It2 const & it2) const noexcept(noexcept(iter_rvalue_reference_t(iter_move(it1))) && @@ -134,24 +140,27 @@ namespace ranges { return {}; } - template(typename... Rngs)( // - requires and_v...> AND // - and_v...> AND // + template(typename... Rngs)( + /// \pre + requires and_v...> AND + and_v...> AND (sizeof...(Rngs) != 0)) // zip_view...> operator()(Rngs &&... rngs) const { return zip_view...>{all(static_cast(rngs))...}; } #if defined(_MSC_VER) - template(typename Rng0)( // - requires input_range AND viewable_range) // + template(typename Rng0)( + /// \pre + requires input_range AND viewable_range) constexpr zip_view> operator()(Rng0 && rng0) const { return zip_view>{all(static_cast(rng0))}; } - template(typename Rng0, typename Rng1)( // - requires input_range AND viewable_range AND // - input_range AND viewable_range) // + template(typename Rng0, typename Rng1)( + /// \pre + requires input_range AND viewable_range AND + input_range AND viewable_range) constexpr zip_view, all_t> // operator()(Rng0 && rng0, Rng1 && rng1) const { @@ -159,10 +168,11 @@ namespace ranges all(static_cast(rng0)), // all(static_cast(rng1))}; } - template(typename Rng0, typename Rng1, typename Rng2)( // - requires input_range AND viewable_range AND // - input_range AND viewable_range AND // - input_range AND viewable_range) // + template(typename Rng0, typename Rng1, typename Rng2)( + /// \pre + requires input_range AND viewable_range AND + input_range AND viewable_range AND + input_range AND viewable_range) constexpr zip_view, all_t, all_t> // operator()(Rng0 && rng0, Rng1 && rng1, Rng2 && rng2) const { diff --git a/include/range/v3/view/zip_with.hpp b/include/range/v3/view/zip_with.hpp index fd7231c5a5..f93b9dfa3a 100644 --- a/include/range/v3/view/zip_with.hpp +++ b/include/range/v3/view/zip_with.hpp @@ -77,8 +77,9 @@ namespace ranges struct _advance_ { - template(typename I, typename Diff)( // - requires input_or_output_iterator AND integer_like_) // + template(typename I, typename Diff)( + /// \pre + requires input_or_output_iterator AND integer_like_) void operator()(I & i, Diff n) const { advance(i, static_cast>(n)); @@ -186,7 +187,8 @@ namespace ranges std::tuple>...> ends) : ends_(std::move(ends)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // sentinel(sentinel that) : ends_(std::move(that.ends_)) @@ -216,7 +218,8 @@ namespace ranges : fun_(std::move(fun)) , its_(std::move(its)) {} - template(bool Other)( // + template(bool Other)( + /// \pre requires Const AND CPP_NOT(Other)) // cursor(cursor that) : fun_(std::move(that.fun_)) @@ -234,7 +237,8 @@ namespace ranges } CPP_member auto equal(cursor const & that) const // - -> CPP_ret(bool)( // + -> CPP_ret(bool)( + /// \pre requires and_v< sentinel_for>, iterator_t>>...>) @@ -257,21 +261,24 @@ namespace ranges } CPP_member auto prev() // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires and_v>...>) { tuple_for_each(its_, detail::dec); } CPP_member auto advance(difference_type n) // - -> CPP_ret(void)( // + -> CPP_ret(void)( + /// \pre requires and_v>...>) { tuple_for_each(its_, bind_back(detail::advance_, n)); } CPP_member auto distance_to(cursor const & that) const // - -> CPP_ret(difference_type)( // + -> CPP_ret(difference_type)( + /// \pre requires and_v< sized_sentinel_for>, iterator_t>>...>) @@ -319,16 +326,18 @@ namespace ranges { return {fun_, tuple_transform(rngs_, ranges::end)}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND and_v...> AND - views::zippable_with...>) // + views::zippable_with...>) cursor begin_cursor() const { return {fun_, tuple_transform(rngs_, ranges::begin)}; } - template(bool Const = true)( // + template(bool Const = true)( + /// \pre requires Const AND and_v...> AND - views::zippable_with...>) // + views::zippable_with...>) end_cursor_t end_cursor() const { return {fun_, tuple_transform(rngs_, ranges::end)}; @@ -377,7 +386,8 @@ namespace ranges }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 - template(typename Fun, typename... Rng)( // + template(typename Fun, typename... Rng)( + /// \pre requires copy_constructible) zip_with_view(Fun, Rng &&...) -> zip_with_view...>; @@ -387,8 +397,9 @@ namespace ranges { struct iter_zip_with_fn { - template(typename... Rngs, typename Fun)( // - requires and_v...> AND // + template(typename... Rngs, typename Fun)( + /// \pre + requires and_v...> AND zippable_with AND (sizeof...(Rngs) != 0)) // iter_zip_with_view...> // operator()(Fun fun, Rngs &&... rngs) const @@ -397,8 +408,9 @@ namespace ranges std::move(fun), all(static_cast(rngs))...}; } - template(typename Fun)( // - requires zippable_with) // + template(typename Fun)( + /// \pre + requires zippable_with) constexpr empty_view> operator()(Fun) const noexcept { return {}; @@ -411,7 +423,8 @@ namespace ranges struct zip_with_fn { - template(typename... Rngs, typename Fun)( // + template(typename... Rngs, typename Fun)( + /// \pre requires and_v...> AND and_v...> AND copy_constructible AND invocable...> AND @@ -422,8 +435,9 @@ namespace ranges std::move(fun), all(static_cast(rngs))...}; } - template(typename Fun)( // - requires copy_constructible AND invocable) // + template(typename Fun)( + /// \pre + requires copy_constructible AND invocable) constexpr empty_view> operator()(Fun) const noexcept { return {}; diff --git a/test/debug_view.hpp b/test/debug_view.hpp index 3399ac9caf..940098e72f 100644 --- a/test/debug_view.hpp +++ b/test/debug_view.hpp @@ -138,7 +138,9 @@ struct debug_input_view : ranges::view_base } CPP_member friend auto operator-(sentinel const& s, iterator const& i) -> - CPP_ret(difference_type)(requires Sized) + CPP_ret(difference_type)( + /// \pre + requires Sized) { RANGES_ENSURE(i.view_ == s.view_); RANGES_ENSURE(i.version_ == s.version_); @@ -147,7 +149,9 @@ struct debug_input_view : ranges::view_base } CPP_member friend auto operator-(iterator const& i, sentinel const& s) -> - CPP_ret(difference_type)(requires Sized) + CPP_ret(difference_type)( + /// \pre + requires Sized) { return -(s - i); } @@ -165,7 +169,9 @@ struct debug_input_view : ranges::view_base return sentinel{*this}; } CPP_member - auto size() const noexcept -> CPP_ret(std::size_t)(requires Sized) + auto size() const noexcept -> CPP_ret(std::size_t)( + /// \pre + requires Sized) { RANGES_ENSURE(data_); RANGES_ENSURE(data_->offset_ == -1); diff --git a/test/iterator/basic_iterator.cpp b/test/iterator/basic_iterator.cpp index e72659a5e7..ca2c04ff9b 100644 --- a/test/iterator/basic_iterator.cpp +++ b/test/iterator/basic_iterator.cpp @@ -47,7 +47,8 @@ namespace test_weak_input explicit cursor(I i) : it_(i) {} - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::convertible_to) // cursor(cursor that) : it_(std::move(that.it_)) @@ -118,7 +119,8 @@ namespace test_random_access explicit cursor(I i) : it_(i) {} - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::convertible_to) // cursor(cursor that) : it_(std::move(that.it_)) @@ -128,7 +130,8 @@ namespace test_random_access { return *it_; } - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::sentinel_for) // bool equal(cursor const & that) const { @@ -146,7 +149,8 @@ namespace test_random_access { it_ += n; } - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::sized_sentinel_for) // ranges::iter_difference_t distance_to(cursor const & that) const { @@ -281,7 +285,8 @@ namespace test_random_access explicit cursor(I i) : it_(i) {} - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::convertible_to) // cursor(cursor that) : it_(std::move(that.it_)) @@ -380,7 +385,8 @@ namespace test_random_access explicit zip1_cursor(I i) : it_(i) {} - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::convertible_to) // zip1_cursor(zip1_cursor that) : it_(std::move(that.it_)) @@ -462,7 +468,8 @@ namespace test_random_access explicit cursor(I i) : it_(i) {} - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::convertible_to) // cursor(cursor that) : it_(std::move(that.it_)) @@ -472,7 +479,8 @@ namespace test_random_access { return *it_; } - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::sentinel_for) // bool equal(cursor const & that) const { @@ -482,7 +490,8 @@ namespace test_random_access { ++it_; } - CPP_template(class J)( // + CPP_template(class J)( + /// \pre requires ranges::sized_sentinel_for) // ranges::iter_difference_t distance_to(cursor const & that) const { diff --git a/test/test_utils.hpp b/test/test_utils.hpp index c4e84c6d82..e9ab0ceb86 100644 --- a/test/test_utils.hpp +++ b/test/test_utils.hpp @@ -84,7 +84,8 @@ CPP_concept both_ranges = ranges::input_range && ranges::input_range; struct check_equal_fn { - CPP_template(typename T, typename U)( // + CPP_template(typename T, typename U)( + /// \pre requires(!both_ranges)) // void operator()( T && actual, U && expected, @@ -93,8 +94,9 @@ struct check_equal_fn CHECK_SLOC(sloc, (T &&) actual == (U &&) expected); } - CPP_template(typename Rng1, typename Rng2)( // - requires both_ranges) // + CPP_template(typename Rng1, typename Rng2)( + /// \pre + requires both_ranges) void operator()( Rng1 && actual, Rng2 && expected, source_location sloc = source_location::current()) const @@ -109,8 +111,9 @@ struct check_equal_fn CHECK_SLOC(sloc, begin1 == end1); } - CPP_template(typename Rng, typename Val)( // - requires ranges::input_range) // + CPP_template(typename Rng, typename Val)( + /// \pre + requires ranges::input_range) void operator()( Rng && actual, std::initializer_list && expected, source_location sloc = source_location::current()) const