diff --git a/libcxx/docs/Cxx2aStatusIssuesStatus.csv b/libcxx/docs/Cxx2aStatusIssuesStatus.csv --- a/libcxx/docs/Cxx2aStatusIssuesStatus.csv +++ b/libcxx/docs/Cxx2aStatusIssuesStatus.csv @@ -246,7 +246,7 @@ "`3323 `__","``*has-tuple-element*``\ helper concept needs ``convertible_to``\ ","Prague","","" "`3324 `__","Special-case ``std::strong/weak/partial_order``\ for pointers","Prague","","" "`3325 `__","Constrain return type of transformation function for ``transform_view``\ ","Prague","","" -"`3326 `__","``enable_view``\ has false positives","Prague","","" +"`3326 `__","``enable_view``\ has false positives","Prague","|In progress|","" "`3327 `__","Format alignment specifiers vs. text direction","Prague","|Nothing To Do|","" "`3328 `__","Clarify that ``std::string``\ is not good for UTF-8","Prague","","" "`3329 `__","``totally_ordered_with``\ both directly and indirectly requires ``common_reference_with``\ ","Prague","|Complete|","13.0" diff --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv b/libcxx/docs/Cxx2aStatusPaperStatus.csv --- a/libcxx/docs/Cxx2aStatusPaperStatus.csv +++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv @@ -194,3 +194,4 @@ "`P2106 `__","LWG","Alternative wording for GB315 and GB316","Prague","* *","" "`P2116 `__","LWG","Remove tuple-like protocol support from fixed-extent span","Prague","|Complete|","11.0" "`P2231 `__","LWG","Missing constexpr in std::optional and std::variant","February 2021","|In progress|","13.0" +"`P2325 `__","LWG","Views should not be required to be default constructible","June Telecon","|In progress|","" diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -71,7 +71,6 @@ template concept weakly_incrementable = - default_initializable<_Ip> && movable<_Ip> && requires(_Ip __i) { typename iter_difference_t<_Ip>; diff --git a/libcxx/include/__ranges/concepts.h b/libcxx/include/__ranges/concepts.h --- a/libcxx/include/__ranges/concepts.h +++ b/libcxx/include/__ranges/concepts.h @@ -73,7 +73,6 @@ concept view = range<_Tp> && movable<_Tp> && - default_initializable<_Tp> && enable_view<_Tp>; template diff --git a/libcxx/include/__ranges/enable_view.h b/libcxx/include/__ranges/enable_view.h --- a/libcxx/include/__ranges/enable_view.h +++ b/libcxx/include/__ranges/enable_view.h @@ -13,7 +13,6 @@ #include <__config> #include - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif diff --git a/libcxx/include/iterator b/libcxx/include/iterator --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -254,7 +254,6 @@ typedef void reference; typedef void pointer; - constexpr back_insert_iterator() noexcept = default; // since C++20 explicit back_insert_iterator(Container& x); // constexpr in C++20 back_insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20 back_insert_iterator& operator*(); // constexpr in C++20 @@ -278,7 +277,6 @@ typedef void reference; typedef void pointer; - constexpr front_insert_iterator() noexcept = default; // since C++20 explicit front_insert_iterator(Container& x); // constexpr in C++20 front_insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20 front_insert_iterator& operator*(); // constexpr in C++20 @@ -303,7 +301,6 @@ typedef void reference; typedef void pointer; - insert_iterator() = default; // since C++20 insert_iterator(Container& x, typename Container::iterator i); // constexpr in C++20 insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20 insert_iterator& operator*(); // constexpr in C++20 @@ -436,7 +433,6 @@ typedef traits traits_type; typedef basic_ostream ostream_type; - constexpr ostream_iterator() noexcept = default; // since C++20 ostream_iterator(ostream_type& s); ostream_iterator(ostream_type& s, const charT* delimiter); ostream_iterator(const ostream_iterator& x); @@ -502,7 +498,6 @@ typedef basic_streambuf streambuf_type; typedef basic_ostream ostream_type; - constexpr ostreambuf_iterator() noexcept = default; // since C++20 ostreambuf_iterator(ostream_type& s) noexcept; ostreambuf_iterator(streambuf_type* s) noexcept; ostreambuf_iterator& operator=(charT c); @@ -849,9 +844,6 @@ typedef void reference; typedef _Container container_type; -#if _LIBCPP_STD_VER > 17 - _LIBCPP_INLINE_VISIBILITY constexpr back_insert_iterator() noexcept = default; -#endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) {container->push_back(__value_); return *this;} @@ -894,9 +886,6 @@ typedef void reference; typedef _Container container_type; -#if _LIBCPP_STD_VER > 17 - _LIBCPP_INLINE_VISIBILITY constexpr front_insert_iterator() noexcept = default; -#endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_) {container->push_front(__value_); return *this;} @@ -927,7 +916,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP protected: _Container* container; - typename _Container::iterator iter; + typename _Container::iterator iter; // FIXME: `ranges::iterator_t` in C++20 mode public: typedef output_iterator_tag iterator_category; typedef void value_type; @@ -940,9 +929,6 @@ typedef void reference; typedef _Container container_type; -#if _LIBCPP_STD_VER > 17 - _LIBCPP_INLINE_VISIBILITY insert_iterator() = default; -#endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, typename _Container::iterator __i) : container(_VSTD::addressof(__x)), iter(__i) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) @@ -1061,9 +1047,6 @@ ostream_type* __out_stream_; const char_type* __delim_; public: -#if _LIBCPP_STD_VER > 17 - _LIBCPP_INLINE_VISIBILITY constexpr ostream_iterator() noexcept = default; -#endif _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {} _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT @@ -1186,9 +1169,6 @@ private: streambuf_type* __sbuf_; public: -#if _LIBCPP_STD_VER > 17 - _LIBCPP_INLINE_VISIBILITY constexpr ostreambuf_iterator() noexcept = default; -#endif _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT : __sbuf_(__s.rdbuf()) {} _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT diff --git a/libcxx/include/span b/libcxx/include/span --- a/libcxx/include/span +++ b/libcxx/include/span @@ -22,6 +22,9 @@ template class span; +template + inline constexpr bool ranges::enable_view> = true; + template inline constexpr bool ranges::enable_borrowed_range> = true; @@ -127,6 +130,7 @@ #include <__config> #include <__debug> #include <__ranges/enable_borrowed_range.h> +#include <__ranges/enable_view.h> #include // for array #include // for byte #include // for iterators @@ -531,6 +535,9 @@ #if !defined(_LIBCPP_HAS_NO_RANGES) template inline constexpr bool ranges::enable_borrowed_range > = true; + +template +inline constexpr bool ranges::enable_view> = true; #endif // !defined(_LIBCPP_HAS_NO_RANGES) // as_bytes & as_writable_bytes diff --git a/libcxx/include/string_view b/libcxx/include/string_view --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -19,6 +19,9 @@ template> class basic_string_view; + template + inline constexpr bool ranges::enable_view> = true; + template inline constexpr bool ranges::enable_borrowed_range> = true; // C++20 @@ -184,6 +187,7 @@ #include <__config> #include <__debug> #include <__ranges/enable_borrowed_range.h> +#include <__ranges/enable_view.h> #include <__string> #include #include @@ -654,6 +658,9 @@ }; #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +template +inline constexpr bool ranges::enable_view> = true; + template inline constexpr bool ranges::enable_borrowed_range > = true; #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) diff --git a/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp @@ -23,13 +23,13 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); static_assert(stdr::random_access_range); -static_assert(!stdr::view); +static_assert(stdr::view && stdr::enable_view); static_assert(stdr::sized_range); static_assert(stdr::borrowed_range); static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); static_assert(stdr::random_access_range); -static_assert(!stdr::view); +static_assert(!stdr::view && !stdr::enable_view); static_assert(stdr::sized_range); static_assert(stdr::borrowed_range); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/subsumption.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/subsumption.compile.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/subsumption.compile.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 -// UNSUPPORTED: libcpp-no-concepts -// UNSUPPORTED: gcc-10 - -// template -// concept weakly_incrementable; - -#include - -#include - -// clang-format off -template -requires std::movable -[[nodiscard]] constexpr bool check_subsumption() { - return false; -} - -template -[[nodiscard]] constexpr bool check_subsumption() { - return true; -} -// clang-format on - -static_assert(check_subsumption()); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp --- a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp @@ -58,10 +58,10 @@ static_assert(!std::weakly_incrementable); static_assert(!std::weakly_incrementable); static_assert(!std::weakly_incrementable); -static_assert(!std::weakly_incrementable); static_assert(!std::weakly_incrementable); static_assert(!std::weakly_incrementable); static_assert(!std::weakly_incrementable); +static_assert(std::weakly_incrementable); static_assert(std::weakly_incrementable); static_assert(std::weakly_incrementable); static_assert(std::weakly_incrementable); diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/default.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/default.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/default.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// class back_insert_iterator - -// constexpr back_insert_iterator() noexcept = default; - -#include -#include - -#include "test_macros.h" - -struct T { }; -using Container = std::vector; - -constexpr bool test() { - std::back_insert_iterator it; - (void)it; - return true; -} - -int main(int, char**) { - ASSERT_NOEXCEPT(std::back_insert_iterator()); - - test(); - static_assert(test()); - - return 0; -} diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/default.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/default.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/default.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// class front_insert_iterator - -// constexpr front_insert_iterator() noexcept = default; - -#include -#include - -#include "test_macros.h" - -struct T { }; -using Container = std::vector; - -constexpr bool test() { - std::front_insert_iterator it; - (void)it; - return true; -} - -int main(int, char**) { - ASSERT_NOEXCEPT(std::front_insert_iterator()); - - test(); - static_assert(test()); - - return 0; -} diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/default.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/default.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/default.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// class insert_iterator - -// insert_iterator() = default; - -#include -#include - -struct T { }; -using Container = std::vector; - -int main(int, char**) { - std::insert_iterator it; (void)it; - return 0; -} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/default.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/default.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/default.pass.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// class ostream_iterator - -// constexpr ostream_iterator() noexcept = default; - -#include -#include // char_traits - -#include "test_macros.h" - -struct MyTraits : std::char_traits { - MyTraits(); // This should not be called. -}; - -constexpr bool test() { - std::ostream_iterator it; - (void)it; - std::ostream_iterator wit; - (void)wit; - return true; -} - -int main(int, char**) { - ASSERT_NOEXCEPT(std::ostream_iterator()); - ASSERT_NOEXCEPT(std::ostream_iterator()); - - test(); - static_assert(test()); - - return 0; -} diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/default.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/default.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/default.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// class ostreambuf_iterator - -// constexpr ostreambuf_iterator() noexcept = default; - -#include - -#include "test_macros.h" - -constexpr bool test() { - std::ostreambuf_iterator it; - (void)it; - std::ostreambuf_iterator wit; - (void)wit; - return true; -} - -int main(int, char**) { - ASSERT_NOEXCEPT(std::ostreambuf_iterator()); - ASSERT_NOEXCEPT(std::ostreambuf_iterator()); - - test(); - static_assert(test()); - - return 0; -} diff --git a/libcxx/test/std/ranges/range.req/range.view/view.compile.pass.cpp b/libcxx/test/std/ranges/range.req/range.view/view.compile.pass.cpp --- a/libcxx/test/std/ranges/range.req/range.view/view.compile.pass.cpp +++ b/libcxx/test/std/ranges/range.req/range.view/view.compile.pass.cpp @@ -46,7 +46,7 @@ static_assert(std::movable); static_assert(!std::default_initializable); static_assert(std::ranges::enable_view); -static_assert(!std::ranges::view); +static_assert(std::ranges::view); // The type would be a view, but it doesn't enable it with enable_view struct NotExplicitlyEnabled { diff --git a/libcxx/test/std/ranges/range.req/range.view/view.subsumption.compile.pass.cpp b/libcxx/test/std/ranges/range.req/range.view/view.subsumption.compile.pass.cpp --- a/libcxx/test/std/ranges/range.req/range.view/view.subsumption.compile.pass.cpp +++ b/libcxx/test/std/ranges/range.req/range.view/view.subsumption.compile.pass.cpp @@ -43,11 +43,3 @@ constexpr bool test() { return false; } static_assert(test()); } - -namespace subsume_default_initializable { - template - constexpr bool test() { return true; } - template - constexpr bool test() { return false; } - static_assert(test()); -} diff --git a/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp @@ -22,13 +22,13 @@ static_assert(std::same_as, std::string_view::iterator>); static_assert(stdr::common_range); static_assert(stdr::random_access_range); -static_assert(!stdr::view); +static_assert(stdr::view && stdr::enable_view); static_assert(stdr::sized_range); static_assert(stdr::borrowed_range); static_assert(std::same_as, std::string_view::const_iterator>); static_assert(stdr::common_range); static_assert(stdr::random_access_range); -static_assert(!stdr::view); // FIXME: string_view needs to be patched so this is true +static_assert(!stdr::view && !stdr::enable_view); static_assert(stdr::sized_range); static_assert(stdr::borrowed_range);