diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -208,7 +208,7 @@ ------------------------------------------------- ----------------- ``__cpp_lib_constexpr_functional`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_constexpr_iterator`` *unimplemented* + ``__cpp_lib_constexpr_iterator`` ``201811L`` ------------------------------------------------- ----------------- ``__cpp_lib_constexpr_memory`` *unimplemented* ------------------------------------------------- ----------------- diff --git a/libcxx/include/iterator b/libcxx/include/iterator --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -152,14 +152,14 @@ typedef void reference; typedef void pointer; - explicit back_insert_iterator(Container& x); - back_insert_iterator& operator=(const typename Container::value_type& value); - back_insert_iterator& operator*(); - back_insert_iterator& operator++(); - back_insert_iterator operator++(int); + 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 + back_insert_iterator& operator++(); // constexpr in C++20 + back_insert_iterator operator++(int); // constexpr in C++20 }; -template back_insert_iterator back_inserter(Container& x); +template back_insert_iterator back_inserter(Container& x); // constexpr in C++20 template class front_insert_iterator @@ -173,14 +173,14 @@ typedef void reference; typedef void pointer; - explicit front_insert_iterator(Container& x); - front_insert_iterator& operator=(const typename Container::value_type& value); - front_insert_iterator& operator*(); - front_insert_iterator& operator++(); - front_insert_iterator operator++(int); + 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 + front_insert_iterator& operator++(); // constexpr in C++20 + front_insert_iterator operator++(int); // constexpr in C++20 }; -template front_insert_iterator front_inserter(Container& x); +template front_insert_iterator front_inserter(Container& x); // constexpr in C++20 template class insert_iterator @@ -195,15 +195,15 @@ typedef void reference; typedef void pointer; - insert_iterator(Container& x, typename Container::iterator i); - insert_iterator& operator=(const typename Container::value_type& value); - insert_iterator& operator*(); - insert_iterator& operator++(); - insert_iterator& operator++(int); + 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 + insert_iterator& operator++(); // constexpr in C++20 + insert_iterator& operator++(int); // constexpr in C++20 }; template -insert_iterator inserter(Container& x, Iterator i); +insert_iterator inserter(Container& x, Iterator i); // constexpr in C++20 template class move_iterator { @@ -932,20 +932,20 @@ public: typedef _Container container_type; - _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_) + _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;} #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) {container->push_back(_VSTD::move(__value_)); return *this;} #endif // _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return *this;} - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;} - _LIBCPP_INLINE_VISIBILITY back_insert_iterator operator++(int) {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator<_Container> back_inserter(_Container& __x) { @@ -965,20 +965,20 @@ public: typedef _Container container_type; - _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_) + _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;} #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_) {container->push_front(_VSTD::move(__value_)); return *this;} #endif // _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return *this;} - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++() {return *this;} - _LIBCPP_INLINE_VISIBILITY front_insert_iterator operator++(int) {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;} }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator<_Container> front_inserter(_Container& __x) { @@ -999,21 +999,21 @@ public: typedef _Container container_type; - _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, typename _Container::iterator __i) : container(_VSTD::addressof(__x)), iter(__i) {} - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) {iter = container->insert(iter, __value_); ++iter; return *this;} #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_) {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} #endif // _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*() {return *this;} - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++() {return *this;} - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++(int) {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;} }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator<_Container> inserter(_Container& __x, typename _Container::iterator __i) { diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -300,7 +300,7 @@ // # define __cpp_lib_constexpr_complex 201711L # define __cpp_lib_constexpr_dynamic_alloc 201907L # define __cpp_lib_constexpr_functional 201907L -// # define __cpp_lib_constexpr_iterator 201811L +# define __cpp_lib_constexpr_iterator 201811L // # define __cpp_lib_constexpr_memory 201811L # define __cpp_lib_constexpr_numeric 201911L // # define __cpp_lib_constexpr_string 201907L diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.compile.fail.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.compile.fail.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.compile.fail.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.compile.fail.cpp @@ -19,7 +19,8 @@ int main(int, char**) { - std::back_insert_iterator > i = std::vector(); + std::vector v; + std::back_insert_iterator > i = v; return 0; } diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.compile.fail.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.compile.fail.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.compile.fail.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.compile.fail.cpp @@ -19,7 +19,8 @@ int main(int, char**) { - std::front_insert_iterator > i = std::list(); + std::list l; + std::front_insert_iterator > i = l; return 0; } diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp @@ -146,17 +146,11 @@ # error "__cpp_lib_array_constexpr should have the value 201811L in c++20" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should be defined in c++20" -# endif -# if __cpp_lib_constexpr_iterator != 201811L -# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++20" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_constexpr_iterator +# error "__cpp_lib_constexpr_iterator should be defined in c++20" +# endif +# if __cpp_lib_constexpr_iterator != 201811L +# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++20" # endif # ifndef __cpp_lib_make_reverse_iterator @@ -209,17 +203,11 @@ # error "__cpp_lib_array_constexpr should have the value 201811L in c++2b" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should be defined in c++2b" -# endif -# if __cpp_lib_constexpr_iterator != 201811L -# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++2b" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_constexpr_iterator +# error "__cpp_lib_constexpr_iterator should be defined in c++2b" +# endif +# if __cpp_lib_constexpr_iterator != 201811L +# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++2b" # endif # ifndef __cpp_lib_make_reverse_iterator diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp @@ -2429,17 +2429,11 @@ # error "__cpp_lib_constexpr_functional should have the value 201907L in c++20" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should be defined in c++20" -# endif -# if __cpp_lib_constexpr_iterator != 201811L -# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++20" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_constexpr_iterator +# error "__cpp_lib_constexpr_iterator should be defined in c++20" +# endif +# if __cpp_lib_constexpr_iterator != 201811L +# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++20" # endif # if !defined(_LIBCPP_VERSION) @@ -3648,17 +3642,11 @@ # error "__cpp_lib_constexpr_functional should have the value 201907L in c++2b" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should be defined in c++2b" -# endif -# if __cpp_lib_constexpr_iterator != 201811L -# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++2b" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_constexpr_iterator -# error "__cpp_lib_constexpr_iterator should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_constexpr_iterator +# error "__cpp_lib_constexpr_iterator should be defined in c++2b" +# endif +# if __cpp_lib_constexpr_iterator != 201811L +# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++2b" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -199,7 +199,6 @@ "name": "__cpp_lib_constexpr_iterator", "values": { "c++20": 201811 }, "headers": ["iterator"], - "unimplemented": True, }, { "name": "__cpp_lib_constexpr_memory", "values": { "c++20": 201811 },