From cce476a07346540811e09b53e7be90dfdf0d0c4e Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 12 Dec 2021 20:12:13 +0700 Subject: [PATCH 1/8] common_iterator should be completely constexpr-able --- stl/inc/iterator | 52 +++++++++---------- .../tests/P0896R4_common_iterator/test.cpp | 9 +++- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/stl/inc/iterator b/stl/inc/iterator index 2aeb23824cc..5daa5298405 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -557,7 +557,7 @@ public: // clang-format off template requires _Not_same_as<_Variantish<_OIter, _OSe>, _Variantish> - _Variantish(const _Variantish<_OIter, _OSe>& _That) noexcept( + constexpr _Variantish(const _Variantish<_OIter, _OSe>& _That) noexcept( is_nothrow_constructible_v<_It, const _OIter&> && is_nothrow_constructible_v<_Se, const _OSe&>) : _Contains{_That._Contains} { // clang-format on @@ -594,11 +594,11 @@ public: } // clang-format off - _Variantish(_Variantish&&) requires is_trivially_move_constructible_v<_It> + constexpr _Variantish(_Variantish&&) requires is_trivially_move_constructible_v<_It> && is_trivially_move_constructible_v<_Se> = default; // clang-format on - _Variantish(_Variantish&& _That) noexcept( + constexpr _Variantish(_Variantish&& _That) noexcept( is_nothrow_move_constructible_v<_It>&& is_nothrow_move_constructible_v<_Se>) : _Contains{_That._Contains} { switch (_Contains) { @@ -617,12 +617,12 @@ public: ~_Variantish() requires is_trivially_destructible_v<_It> && is_trivially_destructible_v<_Se> = default; // clang-format on - ~_Variantish() { + constexpr ~_Variantish() { _Raw_clear(); } // clang-format off - _Variantish& operator=(const _Variantish&) requires is_trivially_destructible_v<_It> + constexpr _Variantish& operator=(const _Variantish&) requires is_trivially_destructible_v<_It> && is_trivially_destructible_v<_Se> && is_trivially_copy_constructible_v<_It> && is_trivially_copy_constructible_v<_Se> @@ -630,7 +630,7 @@ public: && is_trivially_copy_assignable_v<_Se> = default; // clang-format on - _Variantish& operator=(const _Variantish& _That) noexcept( + constexpr _Variantish& operator=(const _Variantish& _That) noexcept( is_nothrow_copy_constructible_v<_It>&& is_nothrow_copy_constructible_v<_Se>&& is_nothrow_copy_assignable_v<_It>&& is_nothrow_copy_assignable_v<_Se>) { if (_Contains == _That._Contains) { @@ -667,7 +667,7 @@ public: } // clang-format off - _Variantish& operator=(_Variantish&&) requires is_trivially_destructible_v<_It> + constexpr _Variantish& operator=(_Variantish&&) requires is_trivially_destructible_v<_It> && is_trivially_destructible_v<_Se> && is_trivially_move_constructible_v<_It> && is_trivially_move_constructible_v<_Se> @@ -675,7 +675,7 @@ public: && is_trivially_move_assignable_v<_Se> = default; // clang-format on - _Variantish& operator=(_Variantish&& _That) noexcept( + constexpr _Variantish& operator=(_Variantish&& _That) noexcept( is_nothrow_move_constructible_v<_It>&& is_nothrow_move_constructible_v<_Se>&& is_nothrow_move_assignable_v<_It>&& is_nothrow_move_assignable_v<_Se>) { if (_Contains == _That._Contains) { @@ -714,7 +714,7 @@ public: // clang-format off template requires _Not_same_as<_Variantish<_OIter, _OSe>, _Variantish> - _Variantish& operator=(const _Variantish<_OIter, _OSe>& _That) noexcept( + constexpr _Variantish& operator=(const _Variantish<_OIter, _OSe>& _That) noexcept( is_nothrow_constructible_v<_It, const _OIter&> && is_nothrow_constructible_v<_Se, const _OSe&> && is_nothrow_assignable_v<_It&, const _OIter&> && is_nothrow_assignable_v<_Se&, const _OSe&>) { // clang-format on @@ -777,7 +777,7 @@ public: _Right = _STD move(_Tmp); } - void _Raw_clear() noexcept { + constexpr void _Raw_clear() noexcept { switch (_Contains) { case _Variantish_state::_Holds_iter: _Iterator.~_It(); @@ -790,7 +790,7 @@ public: } } - void _Clear() noexcept { + constexpr void _Clear() noexcept { _Raw_clear(); _Contains = _Variantish_state::_Nothing; } @@ -818,7 +818,7 @@ private: struct _Proxy_base { iter_value_t<_Iter> _Keep; - explicit _Proxy_base(iter_reference_t<_Iter>&& _Right) noexcept( + constexpr explicit _Proxy_base(iter_reference_t<_Iter>&& _Right) noexcept( is_nothrow_constructible_v, iter_reference_t<_Iter>>) // strengthened : _Keep(_STD forward>(_Right)) {} }; @@ -846,7 +846,7 @@ public: template requires convertible_to && convertible_to && assignable_from<_Iter&, const _OIter&> && assignable_from<_Se&, const _OSe&> - common_iterator& operator=(const common_iterator<_OIter, _OSe>& _Right) noexcept( + constexpr common_iterator& operator=(const common_iterator<_OIter, _OSe>& _Right) noexcept( is_nothrow_constructible_v<_Iter, const _OIter&> && is_nothrow_constructible_v<_Se, const _OSe&> && is_nothrow_assignable_v<_Iter&, const _OIter&> && is_nothrow_assignable_v<_Se&, const _OSe&>) /* strengthened */ { @@ -855,7 +855,7 @@ public: return *this; } - _NODISCARD decltype(auto) operator*() { + _NODISCARD constexpr decltype(auto) operator*() { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Val._Contains == _Variantish_state::_Holds_iter, "common_iterator can only be dereferenced if it holds an iterator"); @@ -863,7 +863,7 @@ public: return *_Val._Iterator; } - _NODISCARD decltype(auto) operator*() const requires _Dereferenceable { + _NODISCARD constexpr decltype(auto) operator*() const requires _Dereferenceable { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Val._Contains == _Variantish_state::_Holds_iter, "common_iterator can only be dereferenced if it holds an iterator"); @@ -872,7 +872,7 @@ public: } // clang-format off - _NODISCARD decltype(auto) operator->() const + _NODISCARD constexpr decltype(auto) operator->() const requires indirectly_readable && (_Has_member_arrow || is_reference_v> || constructible_from, iter_reference_t<_Iter>>) { @@ -893,7 +893,7 @@ public: using _Proxy_base::_Proxy_base; - _NODISCARD const iter_value_t<_Iter>* operator->() const noexcept /* strengthened */ { + _NODISCARD constexpr const iter_value_t<_Iter>* operator->() const noexcept /* strengthened */ { return _STD addressof(this->_Keep); } }; @@ -902,7 +902,7 @@ public: } } - common_iterator& operator++() { + constexpr common_iterator& operator++() { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Val._Contains == _Variantish_state::_Holds_iter, "common_iterator can only be incremented if it holds an iterator"); @@ -911,7 +911,7 @@ public: return *this; } - decltype(auto) operator++(int) { + constexpr decltype(auto) operator++(int) { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Val._Contains == _Variantish_state::_Holds_iter, "common_iterator can only be incremented if it holds an iterator"); @@ -927,7 +927,7 @@ public: using _Proxy_base::_Proxy_base; - _NODISCARD const iter_value_t<_Iter>& operator*() const noexcept /* strengthened */ { + _NODISCARD constexpr const iter_value_t<_Iter>& operator*() const noexcept /* strengthened */ { return this->_Keep; } }; @@ -943,7 +943,7 @@ public: // clang-format off template _OSe> requires sentinel_for<_Se, _OIter> - _NODISCARD friend bool operator==(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) { + _NODISCARD constexpr friend bool operator==(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) { // clang-format on auto& _Right_val = _Right._Get_val(); #if _ITERATOR_DEBUG_LEVEL != 0 @@ -974,7 +974,7 @@ public: // clang-format off template _OIter, sized_sentinel_for<_Iter> _OSe> requires sized_sentinel_for<_Se, _OIter> - _NODISCARD friend iter_difference_t<_OIter> operator-( + _NODISCARD constexpr friend iter_difference_t<_OIter> operator-( const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) { // clang-format on auto& _Right_val = _Right._Get_val(); @@ -999,7 +999,7 @@ public: } } - _NODISCARD friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& _Right) noexcept( + _NODISCARD constexpr friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& _Right) noexcept( noexcept(_RANGES iter_move(_Right._Val._Iterator))) requires input_iterator<_Iter> { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Right._Val._Contains == _Variantish_state::_Holds_iter, @@ -1009,7 +1009,7 @@ public: } template _OIter, class _OSe> - friend void iter_swap(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) noexcept( + friend constexpr void iter_swap(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) noexcept( noexcept(_RANGES iter_swap(_Left._Val._Iterator, _Right._Get_val()._Iterator))) { auto& _Right_val = _Right._Get_val(); #if _ITERATOR_DEBUG_LEVEL != 0 @@ -1020,10 +1020,10 @@ public: return _RANGES iter_swap(_Left._Val._Iterator, _Right_val._Iterator); } - _NODISCARD _Variantish<_Iter, _Se>& _Get_val() noexcept { + _NODISCARD constexpr _Variantish<_Iter, _Se>& _Get_val() noexcept { return _Val; } - _NODISCARD const _Variantish<_Iter, _Se>& _Get_val() const noexcept { + _NODISCARD constexpr const _Variantish<_Iter, _Se>& _Get_val() const noexcept { return _Val; } diff --git a/tests/std/tests/P0896R4_common_iterator/test.cpp b/tests/std/tests/P0896R4_common_iterator/test.cpp index 8018ebda7c2..640afb03673 100644 --- a/tests/std/tests/P0896R4_common_iterator/test.cpp +++ b/tests/std/tests/P0896R4_common_iterator/test.cpp @@ -172,7 +172,7 @@ struct instantiator { } }; -bool test_operator_arrow() { +constexpr bool test_operator_arrow() { P input[3] = {{0, 1}, {0, 2}, {0, 3}}; using pointerTest = common_iterator; @@ -242,7 +242,7 @@ struct poor_sentinel { } }; -void test_gh_2065() { // Guard against regression of GH-2065, for which we previously stumbled over CWG-1699. +constexpr bool test_gh_2065() { // Guard against regression of GH-2065, for which we previously stumbled over CWG-1699. { int x = 42; common_iterator it1{&x}; @@ -256,12 +256,17 @@ void test_gh_2065() { // Guard against regression of GH-2065, for which we previ common_iterator it2{&i}; assert(it1 - it2 == 0); } + + return true; } int main() { with_writable_iterators::call(); + static_assert((with_writable_iterators::call(), true)); test_operator_arrow(); + static_assert(test_operator_arrow()); test_gh_2065(); + static_assert(test_gh_2065()); } From ae6a077882011f6f342237b5c8641797b9ba0ac3 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 12 Dec 2021 20:33:09 +0700 Subject: [PATCH 2/8] too long line --- stl/inc/iterator | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stl/inc/iterator b/stl/inc/iterator index 5daa5298405..db6d3252ec8 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -943,7 +943,8 @@ public: // clang-format off template _OSe> requires sentinel_for<_Se, _OIter> - _NODISCARD constexpr friend bool operator==(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) { + _NODISCARD constexpr friend + bool operator==(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) { // clang-format on auto& _Right_val = _Right._Get_val(); #if _ITERATOR_DEBUG_LEVEL != 0 From fc81dc9befc54d11f7a082d009e249791661b3e3 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 13 Dec 2021 22:19:13 -0800 Subject: [PATCH 3/8] More constexpr! More tests! --- stl/inc/iterator | 6 +-- .../tests/P0896R4_common_iterator/test.cpp | 49 +++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/stl/inc/iterator b/stl/inc/iterator index db6d3252ec8..35c63118a20 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -574,11 +574,11 @@ public: } // clang-format off - _Variantish(const _Variantish&) requires is_trivially_copy_constructible_v<_It> + constexpr _Variantish(const _Variantish&) requires is_trivially_copy_constructible_v<_It> && is_trivially_copy_constructible_v<_Se> = default; // clang-format on - _Variantish(const _Variantish& _That) noexcept( + constexpr _Variantish(const _Variantish& _That) noexcept( is_nothrow_copy_constructible_v<_It>&& is_nothrow_copy_constructible_v<_Se>) : _Contains{_That._Contains} { switch (_Contains) { @@ -614,7 +614,7 @@ public: } // clang-format off - ~_Variantish() requires is_trivially_destructible_v<_It> && is_trivially_destructible_v<_Se> = default; + constexpr ~_Variantish() requires is_trivially_destructible_v<_It> && is_trivially_destructible_v<_Se> = default; // clang-format on constexpr ~_Variantish() { diff --git a/tests/std/tests/P0896R4_common_iterator/test.cpp b/tests/std/tests/P0896R4_common_iterator/test.cpp index 640afb03673..3b56bf1a793 100644 --- a/tests/std/tests/P0896R4_common_iterator/test.cpp +++ b/tests/std/tests/P0896R4_common_iterator/test.cpp @@ -226,6 +226,10 @@ using ICID = iterator_traits); struct poor_sentinel { + poor_sentinel() = default; + poor_sentinel(const poor_sentinel&) {} // non-trivial copy constructor, to test _Variantish behavior + poor_sentinel& operator=(const poor_sentinel&) = default; + template [[nodiscard]] constexpr bool operator==(const Winc&) const noexcept { return true; @@ -260,6 +264,48 @@ constexpr bool test_gh_2065() { // Guard against regression of GH-2065, for whic return true; } +constexpr bool test_lwg_3574() { + int arr[]{11, 22, 33}; + + { + common_iterator x{arr}; + common_iterator y{arr + 2}; + assert(y - x == 2); + } + + { // test that copy construction is constexpr, even when the sentinel isn't trivially copy constructible + common_iterator a{arr}; + common_iterator b{a}; + assert(b - a == 0); + } + + common_iterator i{arr}; + common_iterator ci{arr + 1}; + + assert(*ci == 22); + assert(*as_const(ci) == 22); + assert(ci.operator->() == arr + 1); + + ci = i; + assert(*ci == 11); + assert(ci == i); + + assert(*++ci == 22); + assert(ci != i); + + assert(*ci++ == 22); + assert(*ci == 33); + + assert(iter_move(i) == 11); + + common_iterator k{arr + 2}; + iter_swap(i, k); + assert(arr[0] == 33); + assert(arr[2] == 11); + + return true; +} + int main() { with_writable_iterators::call(); static_assert((with_writable_iterators::call(), true)); @@ -269,4 +315,7 @@ int main() { test_gh_2065(); static_assert(test_gh_2065()); + + test_lwg_3574(); + static_assert(test_lwg_3574()); } From 3e83405ee1969d79691ec8b50a40cbbfd02481d1 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 14 Dec 2021 23:18:05 +0700 Subject: [PATCH 4/8] remove `strengthened` comment per LWG-3595 --- stl/inc/iterator | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/iterator b/stl/inc/iterator index db6d3252ec8..9575320608e 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -893,7 +893,7 @@ public: using _Proxy_base::_Proxy_base; - _NODISCARD constexpr const iter_value_t<_Iter>* operator->() const noexcept /* strengthened */ { + _NODISCARD constexpr const iter_value_t<_Iter>* operator->() const noexcept { return _STD addressof(this->_Keep); } }; @@ -927,7 +927,7 @@ public: using _Proxy_base::_Proxy_base; - _NODISCARD constexpr const iter_value_t<_Iter>& operator*() const noexcept /* strengthened */ { + _NODISCARD constexpr const iter_value_t<_Iter>& operator*() const noexcept { return this->_Keep; } }; From b4e27c6d32b908d2ca478509afc58773d96c9d1c Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Wed, 15 Dec 2021 00:24:09 +0700 Subject: [PATCH 5/8] CaseyCarter review comments --- stl/inc/iterator | 8 ++++---- tests/std/include/range_algorithm_support.hpp | 3 ++- tests/std/tests/P0896R4_common_iterator/test.cpp | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/stl/inc/iterator b/stl/inc/iterator index b2d2e214a86..2680618cd32 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -752,7 +752,7 @@ public: } // clang-format off - constexpr friend void swap(_Variantish& _Left, _Variantish& _Right) noexcept( + friend constexpr void swap(_Variantish& _Left, _Variantish& _Right) noexcept( is_nothrow_move_constructible_v<_It> && is_nothrow_move_constructible_v<_Se> && is_nothrow_swappable_v<_It> && is_nothrow_swappable_v<_Se>) requires (!_Is_trivially_swappable_v<_It> || !_Is_trivially_swappable_v<_Se>) { @@ -943,7 +943,7 @@ public: // clang-format off template _OSe> requires sentinel_for<_Se, _OIter> - _NODISCARD constexpr friend + _NODISCARD friend constexpr bool operator==(const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) { // clang-format on auto& _Right_val = _Right._Get_val(); @@ -975,7 +975,7 @@ public: // clang-format off template _OIter, sized_sentinel_for<_Iter> _OSe> requires sized_sentinel_for<_Se, _OIter> - _NODISCARD constexpr friend iter_difference_t<_OIter> operator-( + _NODISCARD friend constexpr iter_difference_t<_OIter> operator-( const common_iterator& _Left, const common_iterator<_OIter, _OSe>& _Right) { // clang-format on auto& _Right_val = _Right._Get_val(); @@ -1000,7 +1000,7 @@ public: } } - _NODISCARD constexpr friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& _Right) noexcept( + _NODISCARD friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& _Right) noexcept( noexcept(_RANGES iter_move(_Right._Val._Iterator))) requires input_iterator<_Iter> { #if _ITERATOR_DEBUG_LEVEL != 0 _STL_VERIFY(_Right._Val._Contains == _Variantish_state::_Holds_iter, diff --git a/tests/std/include/range_algorithm_support.hpp b/tests/std/include/range_algorithm_support.hpp index 9a8594c753e..70fad0ab870 100644 --- a/tests/std/include/range_algorithm_support.hpp +++ b/tests/std/include/range_algorithm_support.hpp @@ -891,7 +891,7 @@ struct with_output_iterators { template struct with_writable_iterators { template - static constexpr void call() { + static constexpr bool call() { using namespace test; using test::iterator; @@ -902,6 +902,7 @@ struct with_writable_iterators { iterator>(); with_output_iterators::template call(); + return true; } }; diff --git a/tests/std/tests/P0896R4_common_iterator/test.cpp b/tests/std/tests/P0896R4_common_iterator/test.cpp index 3b56bf1a793..6c0437c949b 100644 --- a/tests/std/tests/P0896R4_common_iterator/test.cpp +++ b/tests/std/tests/P0896R4_common_iterator/test.cpp @@ -227,7 +227,7 @@ STATIC_ASSERT(same_as); struct poor_sentinel { poor_sentinel() = default; - poor_sentinel(const poor_sentinel&) {} // non-trivial copy constructor, to test _Variantish behavior + constexpr poor_sentinel(const poor_sentinel&) {} // non-trivial copy constructor, to test _Variantish behavior poor_sentinel& operator=(const poor_sentinel&) = default; template @@ -308,7 +308,7 @@ constexpr bool test_lwg_3574() { int main() { with_writable_iterators::call(); - static_assert((with_writable_iterators::call(), true)); + static_assert(with_writable_iterators::call()); test_operator_arrow(); static_assert(test_operator_arrow()); From ec13e77aea8f88fc715df270b0b7bb0e4dd20096 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Wed, 15 Dec 2021 00:37:11 +0700 Subject: [PATCH 6/8] no need to mofify swap, new line before return --- stl/inc/iterator | 2 +- tests/std/include/range_algorithm_support.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/stl/inc/iterator b/stl/inc/iterator index 2680618cd32..aad0a295795 100644 --- a/stl/inc/iterator +++ b/stl/inc/iterator @@ -752,7 +752,7 @@ public: } // clang-format off - friend constexpr void swap(_Variantish& _Left, _Variantish& _Right) noexcept( + constexpr friend void swap(_Variantish& _Left, _Variantish& _Right) noexcept( is_nothrow_move_constructible_v<_It> && is_nothrow_move_constructible_v<_Se> && is_nothrow_swappable_v<_It> && is_nothrow_swappable_v<_Se>) requires (!_Is_trivially_swappable_v<_It> || !_Is_trivially_swappable_v<_Se>) { diff --git a/tests/std/include/range_algorithm_support.hpp b/tests/std/include/range_algorithm_support.hpp index 70fad0ab870..0fb34fcc77e 100644 --- a/tests/std/include/range_algorithm_support.hpp +++ b/tests/std/include/range_algorithm_support.hpp @@ -902,6 +902,7 @@ struct with_writable_iterators { iterator>(); with_output_iterators::template call(); + return true; } }; From 8b1d5e91cce8b927350420885ce9c0c48ddc35b7 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 14 Dec 2021 17:35:40 -0800 Subject: [PATCH 7/8] Update `with_writable_iterators` usage. --- tests/std/tests/P0896R4_counted_iterator/test.cpp | 2 +- tests/std/tests/P0896R4_views_counted/test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/std/tests/P0896R4_counted_iterator/test.cpp b/tests/std/tests/P0896R4_counted_iterator/test.cpp index 715d5a99d53..1eafd539e17 100644 --- a/tests/std/tests/P0896R4_counted_iterator/test.cpp +++ b/tests/std/tests/P0896R4_counted_iterator/test.cpp @@ -343,7 +343,7 @@ void test_P2259() { } int main() { - STATIC_ASSERT((with_writable_iterators::call(), true)); + STATIC_ASSERT(with_writable_iterators::call()); with_writable_iterators::call(); { // Validate unwrapping diff --git a/tests/std/tests/P0896R4_views_counted/test.cpp b/tests/std/tests/P0896R4_views_counted/test.cpp index fdd610947c2..bd7b5e5e343 100644 --- a/tests/std/tests/P0896R4_views_counted/test.cpp +++ b/tests/std/tests/P0896R4_views_counted/test.cpp @@ -47,6 +47,6 @@ struct instantiator { }; int main() { - STATIC_ASSERT((with_writable_iterators::call(), true)); + STATIC_ASSERT(with_writable_iterators::call()); with_writable_iterators::call(); } From 1d6eae0cce6b66455e699ea29fa28d358b820db9 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 14 Dec 2021 17:43:36 -0800 Subject: [PATCH 8/8] Update tests/std/tests/P0896R4_common_iterator/test.cpp Test constexpr copy construction with a stored sentinel whose copy constructor is constexpr but not trivial --- tests/std/tests/P0896R4_common_iterator/test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/std/tests/P0896R4_common_iterator/test.cpp b/tests/std/tests/P0896R4_common_iterator/test.cpp index 6c0437c949b..f7153063959 100644 --- a/tests/std/tests/P0896R4_common_iterator/test.cpp +++ b/tests/std/tests/P0896R4_common_iterator/test.cpp @@ -275,7 +275,9 @@ constexpr bool test_lwg_3574() { { // test that copy construction is constexpr, even when the sentinel isn't trivially copy constructible common_iterator a{arr}; - common_iterator b{a}; + common_iterator b{a}; // copy-construct with a stored iterator + common_iterator x{poor_sentinel{}}; + common_iterator y{x}; // copy-construct with a stored sentinel assert(b - a == 0); }