diff --git a/stl/inc/concepts b/stl/inc/concepts index 20478fb5471..2cc8f904bad 100644 --- a/stl/inc/concepts +++ b/stl/inc/concepts @@ -199,7 +199,7 @@ concept _Boolean_testable_impl = convertible_to<_Ty, bool>; template concept _Boolean_testable = _Boolean_testable_impl<_Ty> - && requires (_Ty&& __t) { + && requires(_Ty&& __t) { { !static_cast<_Ty&&>(__t) } -> _Boolean_testable_impl; }; diff --git a/stl/inc/xutility b/stl/inc/xutility index bd4985cb50a..2288ddcba1f 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1909,8 +1909,9 @@ public: } #ifdef __cpp_lib_concepts + // clang-format off _NODISCARD constexpr pointer operator->() const - requires(is_pointer_v<_BidIt> || requires(const _BidIt __i) { __i.operator->(); }) { + requires (is_pointer_v<_BidIt> || requires(const _BidIt __i) { __i.operator->(); }) { _BidIt _Tmp = current; --_Tmp; if constexpr (is_pointer_v<_BidIt>) { @@ -1919,6 +1920,7 @@ public: return _Tmp.operator->(); } } + // clang-format on #else // ^^^ __cpp_lib_concepts / !__cpp_lib_concepts vvv _NODISCARD _CONSTEXPR17 pointer operator->() const { _BidIt _Tmp = current; diff --git a/tests/std/include/range_algorithm_support.hpp b/tests/std/include/range_algorithm_support.hpp index b02043749a9..c0994cd8438 100644 --- a/tests/std/include/range_algorithm_support.hpp +++ b/tests/std/include/range_algorithm_support.hpp @@ -109,15 +109,19 @@ namespace test { using unwrap = sentinel; - [[nodiscard]] constexpr auto _Unwrapped() const noexcept requires(to_bool(Wrapped)) { + // clang-format off + [[nodiscard]] constexpr auto _Unwrapped() const noexcept requires (to_bool(Wrapped)) { return unwrap{ptr_}; } + // clang-format on static constexpr bool _Unwrap_when_unverified = true; - constexpr void _Seek_to(unwrap const& s) noexcept requires(to_bool(Wrapped)) { + // clang-format off + constexpr void _Seek_to(unwrap const& s) noexcept requires (to_bool(Wrapped)) { ptr_ = s.peek(); } + // clang-format on }; // clang-format off diff --git a/tests/std/tests/P0896R4_P1614R2_comparisons/test.cpp b/tests/std/tests/P0896R4_P1614R2_comparisons/test.cpp index 04593749741..ebf0022a565 100644 --- a/tests/std/tests/P0896R4_P1614R2_comparisons/test.cpp +++ b/tests/std/tests/P0896R4_P1614R2_comparisons/test.cpp @@ -83,19 +83,21 @@ struct three_way_archetype { three_way_archetype(three_way_archetype const&) = delete; three_way_archetype& operator=(three_way_archetype const&) = delete; ~three_way_archetype() = delete; + // clang-format off // 0: not equality_comparable - bool operator==(three_way_archetype const&) const requires(I == 0) = delete; - bool operator==(three_way_archetype const&) const requires(I != 0); + bool operator==(three_way_archetype const&) const requires (I == 0) = delete; + bool operator==(three_way_archetype const&) const requires (I != 0); // 1: not totally_ordered - bool operator<(three_way_archetype const&) const requires(I == 1) = delete; - bool operator<(three_way_archetype const&) const requires(I != 1); - bool operator>(three_way_archetype const&) const requires(I != 1); - bool operator<=(three_way_archetype const&) const requires(I != 1); - bool operator>=(three_way_archetype const&) const requires(I != 1); + bool operator<(three_way_archetype const&) const requires (I == 1) = delete; + bool operator<(three_way_archetype const&) const requires (I != 1); + bool operator>(three_way_archetype const&) const requires (I != 1); + bool operator<=(three_way_archetype const&) const requires (I != 1); + bool operator>=(three_way_archetype const&) const requires (I != 1); // 2: <=> isn't defined - Category operator<=>(three_way_archetype const&) const requires(I != 2 && I != 3); + Category operator<=>(three_way_archetype const&) const requires (I != 2 && I != 3); // 3: <=> doesn't return a comparison category type - int operator<=>(three_way_archetype const&) const requires(I == 3); + int operator<=>(three_way_archetype const&) const requires (I == 3); + // clang-format on }; constexpr int three_way_archetype_max = 4; diff --git a/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.cpp index b049409901c..ff3beb645d5 100644 --- a/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.cpp @@ -61,8 +61,9 @@ template struct simple_iter_archetype { using value_type = T; - simple_reference operator*() const requires(I != 0); // 0: not indirectly_readable - + // clang-format off + simple_reference operator*() const requires (I != 0); // 0: not indirectly_readable + // clang-format on friend void iter_swap(simple_iter_archetype const&, simple_iter_archetype const&) {} }; STATIC_ASSERT(!std::indirectly_readable>); @@ -92,21 +93,23 @@ namespace indirectly_unary_invocable_test { template struct Fn : base { + // clang-format off // 1: not invocable&> - void operator()(int&) const requires(I == 1) = delete; + void operator()(int&) const requires (I == 1) = delete; // 2: not invocable> - void operator()(simple_reference) const requires(I == 2) = delete; + void operator()(simple_reference) const requires (I == 2) = delete; // 3: not invocable> - void operator()(simple_common_reference) const requires(I == 3) = delete; + void operator()(simple_common_reference) const requires (I == 3) = delete; // 4 : not common_reference_with&>, // invoke_result_t>>; - void operator()(int&) const requires(I == 4); - int operator()(simple_reference) const requires(I == 4); + void operator()(int&) const requires (I == 4); + int operator()(simple_reference) const requires (I == 4); - int operator()(int&) const requires(I != 1 && I != 4); - int operator()(simple_reference) const requires(I != 2 && I != 4); - int operator()(simple_common_reference) const requires(I != 3 && I != 4); + int operator()(int&) const requires (I != 1 && I != 4); + int operator()(simple_reference) const requires (I != 2 && I != 4); + int operator()(simple_common_reference) const requires (I != 3 && I != 4); + // clang-format on }; template @@ -141,17 +144,19 @@ namespace indirect_unary_predicate_test { template struct Fn : base { + // clang-format off // 1: not predicate&> - void operator()(int&) const requires(I == 1); + void operator()(int&) const requires (I == 1); // 2: not predicate> - void operator()(simple_reference) const requires(I == 2) = delete; + void operator()(simple_reference) const requires (I == 2) = delete; // 3: not predicate> - void operator()(simple_common_reference) const requires(I == 3) = delete; + void operator()(simple_common_reference) const requires (I == 3) = delete; // 4: all of the above - int operator()(int&) const requires(I != 1 && I != 4); - int operator()(simple_reference) const requires(I != 2 && I != 4); - int operator()(simple_common_reference) const requires(I != 3 && I != 4); + int operator()(int&) const requires (I != 1 && I != 4); + int operator()(simple_reference) const requires (I != 2 && I != 4); + int operator()(simple_common_reference) const requires (I != 3 && I != 4); + // clang-format on }; STATIC_ASSERT(!indirect_unary_predicate, simple_iter_archetype<1>>); @@ -179,22 +184,24 @@ namespace indirect_binary_predicate_test { template struct Fn : base { + // clang-format off // 1: not predicate&, iter_value_t&> - void operator()(int&, int&) const requires(I == 1); + void operator()(int&, int&) const requires (I == 1); // 2: not predicate&, iter_reference_t> - void operator()(int&, simple_reference) const requires(I == 2); + void operator()(int&, simple_reference) const requires (I == 2); // 3: not predicate, iter_value_t&> - void operator()(simple_reference, int&) const requires(I == 3); + void operator()(simple_reference, int&) const requires (I == 3); // 4: not predicate, iter_reference_t> - void operator()(simple_reference, simple_reference) const requires(I == 4); + void operator()(simple_reference, simple_reference) const requires (I == 4); // 5: not predicate, iter_common_reference_t> - void operator()(simple_common_reference, simple_common_reference) const requires(I == 5); + void operator()(simple_common_reference, simple_common_reference) const requires (I == 5); - bool operator()(int&, int&) const requires(I != 1); - int operator()(int&, simple_reference) const requires(I != 2); - int* operator()(simple_reference, int&) const requires(I != 3); - std::true_type operator()(simple_reference, simple_reference) const requires(I != 4); - std::false_type operator()(simple_common_reference, simple_common_reference) const requires(I != 5); + bool operator()(int&, int&) const requires (I != 1); + int operator()(int&, simple_reference) const requires (I != 2); + int* operator()(simple_reference, int&) const requires (I != 3); + std::true_type operator()(simple_reference, simple_reference) const requires (I != 4); + std::false_type operator()(simple_common_reference, simple_common_reference) const requires (I != 5); + // clang-format on }; template @@ -260,17 +267,19 @@ namespace indirectly_movable_test { // also covers indirectly_movable_storable template struct value_type { + // clang-format off value_type() = default; value_type(value_type&&) = default; - value_type& operator=(value_type&&) requires(I != 0) = default; // 0: not movable + value_type& operator=(value_type&&) requires (I != 0) = default; // 0: not movable // 1: not constructible_from>: template - value_type(simple_reference) requires(I == 1) = delete; + value_type(simple_reference) requires (I == 1) = delete; // 2: not assignable_from>: template - value_type& operator=(simple_reference) requires(I != 2); + value_type& operator=(simple_reference) requires (I != 2); template - void operator=(simple_reference) requires(I == 2) = delete; + void operator=(simple_reference) requires (I == 2) = delete; + // clang-format on }; // Ensure specializations of value_type have the intended properties STATIC_ASSERT(!movable>); @@ -291,11 +300,11 @@ namespace indirectly_movable_test { // also covers indirectly_movable_storable // clang-format off out_archetype& operator*() const; // 0: not indirectly_writable - void operator=(simple_reference>&&) const requires(I == 0) = delete; - void operator=(simple_reference>&&) const requires(I != 0); + void operator=(simple_reference>&&) const requires (I == 0) = delete; + void operator=(simple_reference>&&) const requires (I != 0); // 1: not indirectly_writable - void operator=(value_type&&) const requires(I == 1) = delete; - void operator=(value_type&&) const requires(I != 1); + void operator=(value_type&&) const requires (I == 1) = delete; + void operator=(value_type&&) const requires (I != 1); // clang-format on }; // Ensure specializations of out_archetype have the intended properties @@ -328,15 +337,17 @@ namespace indirectly_copyable_test { // also covers indirectly_copyable_storable struct value_type { value_type() = default; value_type(value_type const&) = default; - value_type& operator=(value_type const&) requires(I != 0) = default; // 0: not copyable + // clang-format off + value_type& operator=(value_type const&) requires (I != 0) = default; // 0: not copyable // 1: not constructible_from>: template - value_type(simple_reference) requires(I == 1) = delete; + value_type(simple_reference) requires (I == 1) = delete; // 2: not assignable_from>: template - value_type& operator=(simple_reference) requires(I != 2); + value_type& operator=(simple_reference) requires (I != 2); template - void operator=(simple_reference) requires(I == 2) = delete; + void operator=(simple_reference) requires (I == 2) = delete; + // clang-format on }; // Ensure specializations of value_type have the intended properties STATIC_ASSERT(!copyable>); @@ -357,20 +368,20 @@ namespace indirectly_copyable_test { // also covers indirectly_copyable_storable // clang-format off out_archetype& operator*() const; // 0: not indirectly_writable - void operator=(simple_reference>&&) const requires(I == 0) = delete; - void operator=(simple_reference>&&) const requires(I != 0); + void operator=(simple_reference>&&) const requires (I == 0) = delete; + void operator=(simple_reference>&&) const requires (I != 0); // 1: not indirectly_writable - void operator=(value_type&) const requires(I == 1) = delete; - void operator=(value_type&) const requires(I != 1); + void operator=(value_type&) const requires (I == 1) = delete; + void operator=(value_type&) const requires (I != 1); // 2: not indirectly_writable - void operator=(value_type&&) const requires(I == 2) = delete; - void operator=(value_type&&) const requires(I != 2); + void operator=(value_type&&) const requires (I == 2) = delete; + void operator=(value_type&&) const requires (I != 2); // 3: not indirectly_writable - void operator=(value_type const&&) const requires(I == 3) = delete; - void operator=(value_type const&&) const requires(I != 3); + void operator=(value_type const&&) const requires (I == 3) = delete; + void operator=(value_type const&&) const requires (I != 3); // 4: not indirectly_writable - void operator=(value_type const&) const requires(I == 4) = delete; - void operator=(value_type const&) const requires(I != 4); + void operator=(value_type const&) const requires (I == 4) = delete; + void operator=(value_type const&) const requires (I != 4); // clang-format on }; // Ensure specializations of out_archetype have the intended properties @@ -439,13 +450,13 @@ namespace indirectly_swappable_test { operator int() const; }; - reference operator*() const noexcept requires(I != 0); + // clang-format off + reference operator*() const noexcept requires (I != 0); - friend constexpr void iter_swap(archetype const&, archetype const&) requires(I != 1) {} + friend constexpr void iter_swap(archetype const&, archetype const&) requires (I != 1) {} - // clang-format off template - requires(I != J && I != 2 && J != 2) + requires (I != J && I != 2 && J != 2) friend constexpr void iter_swap(archetype const&, archetype const&) {} // clang-format on }; @@ -503,9 +514,11 @@ namespace indirectly_comparable_test { template struct Fn : base { + // clang-format off // 1: not predicate - void operator()(int, int) const requires(I == 1); - void* operator()(int, int) const requires(I != 1); + void operator()(int, int) const requires (I == 1); + void* operator()(int, int) const requires (I != 1); + // clang-format on }; STATIC_ASSERT(!indirectly_comparable, simple_iter_archetype<1>, Fn<0>, Proj, Proj>); @@ -711,7 +724,9 @@ namespace permutable_test { operator int() const; // 1: not indirectly_movable_storable - void operator=(int) const requires(I != 1); + // clang-format off + void operator=(int) const requires (I != 1); + // clang-format on }; proxy operator*() const; @@ -719,8 +734,10 @@ namespace permutable_test { archetype& operator++(); archetype operator++(int); + // clang-format off // 0: not forward_iterator (input only) - bool operator==(archetype const&) const requires(I != 0) = default; + bool operator==(archetype const&) const requires (I != 0) = default; + // clang-format on friend int iter_move(archetype const&) { return 42; diff --git a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp index 31143faaa0a..bdb19a25b0a 100644 --- a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp @@ -305,13 +305,15 @@ struct destructible_archetype<0> { }; inline constexpr std::size_t destructible_archetype_max = 1; -#define SEMIREGULAR_OPS(prefix) \ - prefix##_archetype() requires(I != 1); \ - prefix##_archetype(prefix##_archetype const&) requires(I != 2); \ - prefix##_archetype(prefix##_archetype&&) requires(I == 3) = delete; \ - \ - prefix##_archetype& operator=(prefix##_archetype const&) requires(I != 4); \ - prefix##_archetype& operator=(prefix##_archetype&&) requires(I == 5) = delete +// clang-format off +#define SEMIREGULAR_OPS(prefix) \ + prefix##_archetype() requires (I != 1); \ + prefix##_archetype(prefix##_archetype const&) requires (I != 2); \ + prefix##_archetype(prefix##_archetype&&) requires (I == 3) = delete; \ + \ + prefix##_archetype& operator=(prefix##_archetype const&) requires (I != 4); \ + prefix##_archetype& operator=(prefix##_archetype&&) requires (I == 5) = delete +// clang-format on template struct semiregular_archetype : destructible_archetype { @@ -337,22 +339,26 @@ struct weakly_incrementable_archetype_dt<8> { template struct increment_ops { - void operator++() requires(I == 9); - Derived operator++() requires(I == 10); - Derived& operator++() requires(I < 9 || I >= 11); - Post operator++(int) requires(I != 11); + // clang-format off + void operator++() requires (I == 9); + Derived operator++() requires (I == 10); + Derived& operator++() requires (I < 9 || I >= 11); + Post operator++(int) requires (I != 11); + // clang-format on }; template struct weakly_incrementable_archetype : destructible_archetype, weakly_incrementable_archetype_dt, increment_ops, void> { - weakly_incrementable_archetype() requires(I != 1) {} - weakly_incrementable_archetype(weakly_incrementable_archetype const&) = delete; - weakly_incrementable_archetype(weakly_incrementable_archetype&&) requires(I < 2 || I >= 4) = default; + // clang-format off + weakly_incrementable_archetype() requires (I != 1) {} + weakly_incrementable_archetype(weakly_incrementable_archetype const&) = delete; + weakly_incrementable_archetype(weakly_incrementable_archetype&&) requires (I < 2 || I >= 4) = default; weakly_incrementable_archetype& operator=(weakly_incrementable_archetype const&) = delete; - weakly_incrementable_archetype& operator=(weakly_incrementable_archetype&&) requires(I < 4 || I >= 6) = default; + weakly_incrementable_archetype& operator=(weakly_incrementable_archetype&&) requires (I < 4 || I >= 6) = default; + // clang-format on }; inline constexpr std::size_t weakly_incrementable_archetype_max = 12; @@ -363,9 +369,11 @@ struct incrementable_archetype : weakly_incrementable_archetype, SEMIREGULAR_OPS(incrementable); using increment_ops, incrementable_archetype>::operator++; - bool operator==(incrementable_archetype const&) const requires(I != weakly_incrementable_archetype_max); + // clang-format off + bool operator==(incrementable_archetype const&) const requires (I != weakly_incrementable_archetype_max); bool operator!=(incrementable_archetype const&) const - requires(I == weakly_incrementable_archetype_max + 1) = delete; + requires (I == weakly_incrementable_archetype_max + 1) = delete; + // clang-format on }; inline constexpr std::size_t incrementable_archetype_max = 14; @@ -374,11 +382,13 @@ template struct iterator_archetype : weakly_incrementable_archetype { SEMIREGULAR_OPS(iterator); - iterator_archetype& operator++() requires(I > 10); - void operator++(int) requires(I != 11); + // clang-format off + iterator_archetype& operator++() requires (I > 10); + void operator++(int) requires (I != 11); - void operator*() requires(I == 12); - int operator*() requires(I != 12); + void operator*() requires (I == 12); + int operator*() requires (I != 12); + // clang-format on }; inline constexpr std::size_t iterator_archetype_max = 13; @@ -432,12 +442,14 @@ struct output_iterator_archetype : iterator_archetype, SEMIREGULAR_OPS(output_iterator); using increment_ops, output_iterator_archetype&>::operator++; + // clang-format off // dereference ops from iterator_archetype - void operator*() requires(I == 12); - output_iterator_archetype& operator*() requires(I != 12); + void operator*() requires (I == 12); + output_iterator_archetype& operator*() requires (I != 12); // indirectly_writable requirements - void operator=(int) requires(I != 13); + void operator=(int) requires (I != 13); + // clang-format on }; inline constexpr std::size_t output_iterator_archetype_max = 14; @@ -470,9 +482,11 @@ struct input_iterator_archetype : iterator_archetype, SEMIREGULAR_OPS(input_iterator); using increment_ops, void>::operator++; + // clang-format off // dereference ops from iterator_archetype - void operator*() const requires(I == 12); - int& operator*() const requires(I != 12); + void operator*() const requires (I == 12); + int& operator*() const requires (I != 12); + // clang-format on }; inline constexpr std::size_t input_iterator_archetype_max = 17; @@ -483,18 +497,22 @@ struct forward_iterator_archetype : input_iterator_archetype, SEMIREGULAR_OPS(forward_iterator); using increment_ops, forward_iterator_archetype>::operator++; - bool operator==(forward_iterator_archetype const&) const requires(I != input_iterator_archetype_max); - bool operator!=(forward_iterator_archetype const&) const requires(I == input_iterator_archetype_max + 1) = delete; + // clang-format off + bool operator==(forward_iterator_archetype const&) const requires (I != input_iterator_archetype_max); + bool operator!=(forward_iterator_archetype const&) const requires (I == input_iterator_archetype_max + 1) = delete; + // clang-format on }; inline constexpr std::size_t forward_iterator_archetype_max = 19; template struct decrement_ops { - void operator--() requires(I == 19); - Derived operator--() requires(I == 20); - Derived& operator--() requires(I < 19 || I >= 21); - Derived operator--(int) requires(I != 21); + // clang-format off + void operator--() requires (I == 19); + Derived operator--() requires (I == 20); + Derived& operator--() requires (I < 19 || I >= 21); + Derived operator--(int) requires (I != 21); + // clang-format on }; template @@ -515,20 +533,22 @@ struct random_iterator_archetype : bidi_iterator_archetype, using increment_ops, random_iterator_archetype>::operator++; using decrement_ops>::operator--; - std::strong_ordering operator<=>(random_iterator_archetype const&) const requires(I != 22); + // clang-format off + std::strong_ordering operator<=>(random_iterator_archetype const&) const requires (I != 22); - int operator-(random_iterator_archetype const&) const requires(I != 6 && I != 23); + int operator-(random_iterator_archetype const&) const requires (I != 6 && I != 23); - random_iterator_archetype& operator+=(int) requires(I != 24); - random_iterator_archetype operator+(int) const requires(I != 25); - friend random_iterator_archetype operator+(int, random_iterator_archetype const&) requires(I != 26) {} + random_iterator_archetype& operator+=(int) requires (I != 24); + random_iterator_archetype operator+(int) const requires (I != 25); + friend random_iterator_archetype operator+(int, random_iterator_archetype const&) requires (I != 26) {} - random_iterator_archetype& operator-=(int) requires(I != 27); - random_iterator_archetype operator-(int) const requires(I != 28); + random_iterator_archetype& operator-=(int) requires (I != 27); + random_iterator_archetype operator-(int) const requires (I != 28); - void operator[](int) const requires(I == 29); - int operator[](int) const requires(I == 30); - int& operator[](int) const requires(I < 29 || I >= 31); + void operator[](int) const requires (I == 29); + int operator[](int) const requires (I == 30); + int& operator[](int) const requires (I < 29 || I >= 31); + // clang-format on }; inline constexpr std::size_t random_iterator_archetype_max = 31; @@ -561,14 +581,16 @@ struct contig_iterator_archetype : increment_ops using increment_ops, contig_iterator_archetype>::operator++; using decrement_ops>::operator--; - int operator-(contig_iterator_archetype const&) const requires(I != 6 && I != 23); + // clang-format off + int operator-(contig_iterator_archetype const&) const requires (I != 6 && I != 23); - contig_iterator_archetype& operator+=(int) requires(I != 24); - contig_iterator_archetype operator+(int) const requires(I != 25); - friend contig_iterator_archetype operator+(int, contig_iterator_archetype const&) requires(I != 26) {} + contig_iterator_archetype& operator+=(int) requires (I != 24); + contig_iterator_archetype operator+(int) const requires (I != 25); + friend contig_iterator_archetype operator+(int, contig_iterator_archetype const&) requires (I != 26) {} - contig_iterator_archetype& operator-=(int) requires(I != 27); - contig_iterator_archetype operator-(int) const requires(I != 28); + contig_iterator_archetype& operator-=(int) requires (I != 27); + contig_iterator_archetype operator-(int) const requires (I != 28); + // clang-format on }; template @@ -1873,11 +1895,13 @@ namespace iter_ops { return *this; } - constexpr trace_iterator& operator=(default_sentinel_t) requires(Assign == assign::yes) { + // clang-format off + constexpr trace_iterator& operator=(default_sentinel_t) requires (Assign == assign::yes) { ++trace_->assignments_; pos_ = sentinel_position; return *this; } + // clang-format on int operator*() const; diff --git a/tests/std/tests/P0896R4_ranges_range_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_range_machinery/test.cpp index 9829a8582d7..f74ed9425d7 100644 --- a/tests/std/tests/P0896R4_ranges_range_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_range_machinery/test.cpp @@ -1289,91 +1289,93 @@ constexpr bool test_array_ish() { // An actual runtime test! } namespace nothrow_testing { + // clang-format off template struct range { int elements_[3]; // begin/end are members for I == 0, and non-members otherwise - int* begin() noexcept(NoThrow) requires(I == 0) { + int* begin() noexcept(NoThrow) requires (I == 0) { return elements_; } - int* end() noexcept(NoThrow) requires(I == 0) { + int* end() noexcept(NoThrow) requires (I == 0) { return elements_ + 3; } - int const* begin() const noexcept(NoThrow) requires(I == 0) { + int const* begin() const noexcept(NoThrow) requires (I == 0) { return elements_; } - int const* end() const noexcept(NoThrow) requires(I == 0) { + int const* end() const noexcept(NoThrow) requires (I == 0) { return elements_ + 3; } // rbegin/rend are members for I == 0, not provided for I == 1, and non-members otherwise // (Not providing operations allows us to test the library-provided fallback behavior) - int* rbegin() noexcept(NoThrow) requires(I == 0) { + int* rbegin() noexcept(NoThrow) requires (I == 0) { return elements_; } - int* rend() noexcept(NoThrow) requires(I == 0) { + int* rend() noexcept(NoThrow) requires (I == 0) { return elements_ + 3; } - int const* rbegin() const noexcept(NoThrow) requires(I == 0) { + int const* rbegin() const noexcept(NoThrow) requires (I == 0) { return elements_; } - int const* rend() const noexcept(NoThrow) requires(I == 0) { + int const* rend() const noexcept(NoThrow) requires (I == 0) { return elements_ + 3; } // empty is not provided when I == 1 - bool empty() const noexcept(NoThrow) requires(I != 1) { + bool empty() const noexcept(NoThrow) requires (I != 1) { return false; } // data is not provided when I == 2 - int* data() noexcept(NoThrow) requires(I != 2) { + int* data() noexcept(NoThrow) requires (I != 2) { return elements_; } - int const* data() const noexcept(NoThrow) requires(I != 2) { + int const* data() const noexcept(NoThrow) requires (I != 2) { return elements_; } // size is not provided when I == 3 - std::size_t size() const noexcept(NoThrow) requires(I != 3) { + std::size_t size() const noexcept(NoThrow) requires (I != 3) { return 3; } }; template - int* begin(range& a) noexcept(NoThrow) requires(I != 0) { + int* begin(range& a) noexcept(NoThrow) requires (I != 0) { return a.elements_; } template - int* end(range& a) noexcept(NoThrow) requires(I != 0) { + int* end(range& a) noexcept(NoThrow) requires (I != 0) { return a.elements_ + 3; } template - int const* begin(range const& a) noexcept(NoThrow) requires(I != 0) { + int const* begin(range const& a) noexcept(NoThrow) requires (I != 0) { return a.elements_; } template - int const* end(range const& a) noexcept(NoThrow) requires(I != 0) { + int const* end(range const& a) noexcept(NoThrow) requires (I != 0) { return a.elements_ + 3; } template - int* rbegin(range& a) noexcept(NoThrow) requires(I > 2) { + int* rbegin(range& a) noexcept(NoThrow) requires (I > 2) { return a.elements_; } template - int* rend(range& a) noexcept(NoThrow) requires(I > 2) { + int* rend(range& a) noexcept(NoThrow) requires (I > 2) { return a.elements_ + 3; } template - int const* rbegin(range const& a) noexcept(NoThrow) requires(I > 2) { + int const* rbegin(range const& a) noexcept(NoThrow) requires (I > 2) { return a.elements_; } template - int const* rend(range const& a) noexcept(NoThrow) requires(I > 2) { + int const* rend(range const& a) noexcept(NoThrow) requires (I > 2) { return a.elements_ + 3; } + // clang-format on template constexpr bool test() { diff --git a/tests/std/tests/P0898R3_concepts/test.cpp b/tests/std/tests/P0898R3_concepts/test.cpp index 41a27ab4f63..1f3d8070820 100644 --- a/tests/std/tests/P0898R3_concepts/test.cpp +++ b/tests/std/tests/P0898R3_concepts/test.cpp @@ -180,7 +180,9 @@ template struct ConvertsFrom { ConvertsFrom() = default; constexpr ConvertsFrom(First) noexcept {} - constexpr ConvertsFrom(Second) noexcept requires(!std::is_same_v) {} + // clang-format off + constexpr ConvertsFrom(Second) noexcept requires (!std::is_same_v) {} + // clang-format on }; template