lefticus updated this revision to Diff 65390. lefticus added a comment. Fixed syntax errors in test files.
https://reviews.llvm.org/D22584 Files: include/array include/iterator test/std/containers/sequences/array/at.pass.cpp test/std/containers/sequences/array/begin.pass.cpp test/std/containers/sequences/array/front_back.pass.cpp test/std/containers/sequences/array/indexing.pass.cpp test/std/containers/sequences/array/iterators.pass.cpp test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
Index: test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp +++ test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp @@ -33,12 +33,21 @@ int main() { - const char* s = "1234567890"; - test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s)); - test(random_access_iterator<const char*>(s+10), 10, random_access_iterator<const char*>(s)); - test(s+10, 10, s); - - test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s)); - test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s)); - test(s+1, s); + { + const char* s = "1234567890"; + test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s)); + test(random_access_iterator<const char*>(s+10), 10, random_access_iterator<const char*>(s)); + test(s+10, 10, s); + + test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s)); + test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s)); + test(s+1, s); + } + + { + constexpr const char* s = "1234567890"; + static_assert(std::prev(s+10, 10) == s); + static_assert(std::prev(s+1) == s); + } + } Index: test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp +++ test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp @@ -35,16 +35,27 @@ int main() { - const char* s = "1234567890"; - test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)); - test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10)); - test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10)); - test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10)); - test(s, 10, s+10); - - test(input_iterator<const char*>(s), input_iterator<const char*>(s+1)); - test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1)); - test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1)); - test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1)); - test(s, s+1); + { + const char* s = "1234567890"; + test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)); + test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10)); + test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10)); + test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10)); + test(s, 10, s+10); + + test(input_iterator<const char*>(s), input_iterator<const char*>(s+1)); + test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1)); + test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1)); + test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1)); + test(s, s+1); + } + +#if TEST_STD_VER > 14 + { + constexpr const char* s = "1234567890"; + static_assert(std::next(s, 10) == s+10); + static_assert(std::next(s) == s+1); + } +#endif + } Index: test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp +++ test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp @@ -31,10 +31,21 @@ int main() { - const char* s = "1234567890"; - test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10); - test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+10), 10); - test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+10), 10); - test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10); - test(s, s+10, 10); + { + const char* s = "1234567890"; + test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10); + test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+10), 10); + test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+10), 10); + test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10); + test(s, s+10, 10); + } + + +#if TEST_STD_VER > 14 + { + constexpr const char* s = "1234567890"; + static_assert(std::distance(s, s+10) == 10); + } +#endif + } Index: test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp +++ test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp @@ -31,15 +31,39 @@ assert(i == x); } + +#if TEST_STD_VER > 14 +template <class It> +constexpr +auto +static_test(It i, typename std::iterator_traits<It>::difference_type n) +{ + std::advance(i, n); + return i; +} +#endif + int main() { - const char* s = "1234567890"; - test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)); - test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10)); - test(bidirectional_iterator<const char*>(s+5), 5, bidirectional_iterator<const char*>(s+10)); - test(bidirectional_iterator<const char*>(s+5), -5, bidirectional_iterator<const char*>(s)); - test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10)); - test(random_access_iterator<const char*>(s+5), -5, random_access_iterator<const char*>(s)); - test(s+5, 5, s+10); - test(s+5, -5, s); + { + const char* s = "1234567890"; + test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)); + test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10)); + test(bidirectional_iterator<const char*>(s+5), 5, bidirectional_iterator<const char*>(s+10)); + test(bidirectional_iterator<const char*>(s+5), -5, bidirectional_iterator<const char*>(s)); + test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10)); + test(random_access_iterator<const char*>(s+5), -5, random_access_iterator<const char*>(s)); + test(s+5, 5, s+10); + test(s+5, -5, s); + } + +#if TEST_STD_VER > 14 + { + constexpr const char* s = "1234567890"; + static_assert(static_test(s, 10) == s+10); + static_assert(static_test(s+5, 5) == s+10); + static_assert(static_test(s+5, -5) == s); + } +#endif } + Index: test/std/containers/sequences/array/iterators.pass.cpp =================================================================== --- test/std/containers/sequences/array/iterators.pass.cpp +++ test/std/containers/sequences/array/iterators.pass.cpp @@ -14,6 +14,7 @@ #include <array> #include <iterator> #include <cassert> +#include "test_macros.h" int main() { @@ -107,4 +108,68 @@ } } #endif + + +#if TEST_STD_VER > 14 + { // P0031 testing conextpr versions of iterators + { + typedef std::array<int, 5> C; + + constexpr C c{}; + static_assert ( c.begin() == std::begin(c)); + static_assert ( c.cbegin() == std::cbegin(c)); + static_assert ( c.rbegin() == std::rbegin(c)); + static_assert ( c.crbegin() == std::crbegin(c)); + static_assert ( c.end() == std::end(c)); + static_assert ( c.cend() == std::cend(c)); + static_assert ( c.rend() == std::rend(c)); + static_assert ( c.crend() == std::crend(c)); + + static_assert ( std::begin(c) != std::end(c)); + static_assert ( std::rbegin(c) != std::rend(c)); + static_assert ( std::cbegin(c) != std::cend(c)); + static_assert ( std::crbegin(c) != std::crend(c)); + } + { + typedef std::array<int, 0> C; + constexpr C::iterator ii1{}, ii2{}; + constexpr C::iterator ii4 = ii1; + constexpr C::const_iterator cii{}; + static_assert ( ii1 == ii2 ); + static_assert ( ii1 == ii4 ); + + static_assert (!(ii1 != ii2 )); + + static_assert ( (ii1 == cii )); + static_assert ( (cii == ii1 )); + static_assert (!(ii1 != cii )); + static_assert (!(cii != ii1 )); + static_assert (!(ii1 < cii )); + static_assert (!(cii < ii1 )); + static_assert ( (ii1 <= cii )); + static_assert ( (cii <= ii1 )); + static_assert (!(ii1 > cii )); + static_assert (!(cii > ii1 )); + static_assert ( (ii1 >= cii )); + static_assert ( (cii >= ii1 )); + static_assert (cii - ii1 == 0); + static_assert (ii1 - cii == 0); + + constexpr C c{}; + static_assert ( c.begin() == std::begin(c)); + static_assert ( c.cbegin() == std::cbegin(c)); + static_assert ( c.rbegin() == std::rbegin(c)); + static_assert ( c.crbegin() == std::crbegin(c)); + static_assert ( c.end() == std::end(c)); + static_assert ( c.cend() == std::cend(c)); + static_assert ( c.rend() == std::rend(c)); + static_assert ( c.crend() == std::crend(c)); + + static_assert ( std::begin(c) == std::end(c)); + static_assert ( std::rbegin(c) == std::rend(c)); + static_assert ( std::cbegin(c) == std::cend(c)); + static_assert ( std::crbegin(c) == std::crend(c)); + } + } +#endif } Index: test/std/containers/sequences/array/indexing.pass.cpp =================================================================== --- test/std/containers/sequences/array/indexing.pass.cpp +++ test/std/containers/sequences/array/indexing.pass.cpp @@ -9,9 +9,9 @@ // <array> -// reference operator[] (size_type) +// reference operator[] (size_type); // constexpr in C++1z // const_reference operator[] (size_type); // constexpr in C++14 -// reference at (size_type) +// reference at (size_type); // constexpr in C++1z // const_reference at (size_type); // constexpr in C++14 #include <array> @@ -23,6 +23,24 @@ // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" + +#if TEST_STD_VER > 14 +constexpr auto constexpr_array_usage() +{ + typedef double T; + typedef std::array<T, 3> C; + C c = {1, 2, 3.5}; + + T &t1 = c[0]; + t1 = 0; + + T &t2 = c[2]; + t2 = 2.5; + return c; +} +#endif + + int main() { { @@ -63,4 +81,12 @@ } #endif +#if TEST_STD_VER > 14 + { + constexpr auto c = constexpr_array_usage(); + static_assert (c[0] == 0); + static_assert (c[2] == 2.5); + } +#endif + } Index: test/std/containers/sequences/array/front_back.pass.cpp =================================================================== --- test/std/containers/sequences/array/front_back.pass.cpp +++ test/std/containers/sequences/array/front_back.pass.cpp @@ -9,8 +9,8 @@ // <array> -// reference front(); -// reference back(); +// reference front(); // constexpr in C++1z +// reference back(); // constexpr in C++1z // const_reference front(); // constexpr in C++14 // const_reference back(); // constexpr in C++14 @@ -23,6 +23,22 @@ // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +#if TEST_STD_VER > 14 +constexpr auto constexpr_array_usage() +{ + typedef double T; + typedef std::array<T, 3> C; + C c = {1, 2, 3.5}; + + T &t1 = c.front(); + t1 = 0; + T &t2 = c.back(); + t2 = 2.5; + return c; +} +#endif + + int main() { { @@ -65,4 +81,13 @@ } #endif +#if TEST_STD_VER > 14 + { + constexpr auto c = constexpr_array_usage(); + static_assert (c.front() == 0); + static_assert (c.back() == 2.5); + } +#endif + + } Index: test/std/containers/sequences/array/begin.pass.cpp =================================================================== --- test/std/containers/sequences/array/begin.pass.cpp +++ test/std/containers/sequences/array/begin.pass.cpp @@ -18,6 +18,19 @@ // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" + +#if TEST_STD_VER > 14 +constexpr auto constexpr_array_usage() +{ + typedef double T; + typedef std::array<T, 3> C; + C c = {1, 2, 3.5}; + C::iterator i = c.begin(); + *i = 5.5; + return c; +} +#endif + int main() { { @@ -31,4 +44,12 @@ *i = 5.5; assert(c[0] == 5.5); } + + +#if TEST_STD_VER > 14 + { + constexpr c = constexpr_array_usage(); + static_assert(c[0] == 5.5); + } +#endif } Index: test/std/containers/sequences/array/at.pass.cpp =================================================================== --- test/std/containers/sequences/array/at.pass.cpp +++ test/std/containers/sequences/array/at.pass.cpp @@ -10,9 +10,9 @@ // XFAIL: libcpp-no-exceptions // <array> -// reference operator[] (size_type) +// reference operator[] (size_type); // constexpr in C++1z // const_reference operator[] (size_type); // constexpr in C++14 -// reference at (size_type) +// reference at (size_type); // constexpr in C++1z // const_reference at (size_type); // constexpr in C++14 #include <array> @@ -24,6 +24,22 @@ // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +#if TEST_STD_VER > 14 +constexpr auto constexpr_array_usage() +{ + typedef double T; + typedef std::array<T, 3> C; + C c = {1, 2, 3.5}; + + T &t1 = c.at(0); + t1 = 0; + + T &t2 = c.at(2); + t2 = 2.5; + return c; +} +#endif + int main() { { @@ -71,4 +87,13 @@ } #endif +#if TEST_STD_VER > 14 + { + constexpr auto c = constexpr_array_usage(); + static_assert (c.at(0) == 0); + static_assert (c.at(2) == 2.5); + } +#endif + + } Index: include/iterator =================================================================== --- include/iterator +++ include/iterator @@ -372,25 +372,25 @@ bool failed() const noexcept; }; -template <class C> auto begin(C& c) -> decltype(c.begin()); -template <class C> auto begin(const C& c) -> decltype(c.begin()); -template <class C> auto end(C& c) -> decltype(c.end()); -template <class C> auto end(const C& c) -> decltype(c.end()); -template <class T, size_t N> T* begin(T (&array)[N]); -template <class T, size_t N> T* end(T (&array)[N]); - -template <class C> auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 -template <class C> auto cend(const C& c) -> decltype(std::end(c)); // C++14 -template <class C> auto rbegin(C& c) -> decltype(c.rbegin()); // C++14 -template <class C> auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14 -template <class C> auto rend(C& c) -> decltype(c.rend()); // C++14 -template <class C> auto rend(const C& c) -> decltype(c.rend()); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto begin(C& c) -> decltype(c.begin()); +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto begin(const C& c) -> decltype(c.begin()); +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto end(C& c) -> decltype(c.end()); +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto end(const C& c) -> decltype(c.end()); +template <class T, size_t N> _LIBCPP_CONSTEXPR_AFTER_CXX14 T* begin(T (&array)[N]); +template <class T, size_t N> _LIBCPP_CONSTEXPR_AFTER_CXX14 T* end(T (&array)[N]); + +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto cend(const C& c) -> decltype(std::end(c)); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rbegin(C& c) -> decltype(c.rbegin()); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rend(C& c) -> decltype(c.rend()); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rend(const C& c) -> decltype(c.rend()); // C++14 template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14 template <class E> reverse_iterator<const E*> rend(initializer_list<E> il); // C++14 -template <class T, size_t N> reverse_iterator<T*> rbegin(T (&array)[N]); // C++14 -template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); // C++14 -template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 -template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14 +template <class T, size_t N> _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<T*> rbegin(T (&array)[N]); // C++14 +template <class T, size_t N> _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<T*> rend(T (&array)[N]); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 +template <class C> _LIBCPP_CONSTEXPR_AFTER_CXX14 auto crend(const C& c) -> decltype(std::rend(c)); // C++14 // 24.8, container access: template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17 @@ -524,6 +524,7 @@ template <class _InputIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) { @@ -533,6 +534,7 @@ template <class _BiDirIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) { @@ -546,6 +548,7 @@ template <class _RandIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) { @@ -554,6 +557,7 @@ template <class _InputIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 void advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n) { @@ -562,6 +566,7 @@ template <class _InputIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 typename iterator_traits<_InputIter>::difference_type __distance(_InputIter __first, _InputIter __last, input_iterator_tag) { @@ -573,6 +578,7 @@ template <class _RandIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 typename iterator_traits<_RandIter>::difference_type __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) { @@ -581,6 +587,7 @@ template <class _InputIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 typename iterator_traits<_InputIter>::difference_type distance(_InputIter __first, _InputIter __last) { @@ -589,6 +596,7 @@ template <class _InputIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 _InputIter next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1, @@ -600,6 +608,7 @@ template <class _BidiretionalIter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 _BidiretionalIter prev(_BidiretionalIter __x, typename iterator_traits<_BidiretionalIter>::difference_type __n = 1, @@ -627,33 +636,34 @@ typedef typename iterator_traits<_Iter>::reference reference; typedef typename iterator_traits<_Iter>::pointer pointer; - _LIBCPP_INLINE_VISIBILITY reverse_iterator() : current() {} - _LIBCPP_INLINE_VISIBILITY explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} - template <class _Up> _LIBCPP_INLINE_VISIBILITY reverse_iterator(const reverse_iterator<_Up>& __u) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator() : current() {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} + template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) {} - _LIBCPP_INLINE_VISIBILITY _Iter base() const {return current;} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {_Iter __tmp = current; return *--__tmp;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return _VSTD::addressof(operator*());} - _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator++() {--current; return *this;} - _LIBCPP_INLINE_VISIBILITY reverse_iterator operator++(int) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return current;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference operator*() const {_Iter __tmp = current; return *--__tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 pointer operator->() const {return _VSTD::addressof(operator*());} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator++() {--current; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} - _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator--() {++current; return *this;} - _LIBCPP_INLINE_VISIBILITY reverse_iterator operator--(int) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator--() {++current; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} - _LIBCPP_INLINE_VISIBILITY reverse_iterator operator+ (difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} - _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator+=(difference_type __n) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} - _LIBCPP_INLINE_VISIBILITY reverse_iterator operator- (difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} - _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator-=(difference_type __n) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference operator[](difference_type __n) const {return *(*this + __n);} }; template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { @@ -662,6 +672,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { @@ -670,6 +681,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { @@ -678,6 +690,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { @@ -686,6 +699,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { @@ -694,6 +708,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { @@ -703,6 +718,7 @@ #ifndef _LIBCPP_CXX03_LANG template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 auto operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -> decltype(__y.base() - __x.base()) @@ -712,6 +728,7 @@ #else template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 typename reverse_iterator<_Iter1>::difference_type operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { @@ -721,6 +738,7 @@ template <class _Iter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Iter> operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) { @@ -730,6 +748,7 @@ #if _LIBCPP_STD_VER > 11 template <class _Iter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) { return reverse_iterator<_Iter>(__i); @@ -1040,30 +1059,30 @@ typedef typename iterator_traits<iterator_type>::reference reference; #endif - _LIBCPP_INLINE_VISIBILITY move_iterator() : __i() {} - _LIBCPP_INLINE_VISIBILITY explicit move_iterator(_Iter __x) : __i(__x) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator() : __i() {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 explicit move_iterator(_Iter __x) : __i(__x) {} template <class _Up> _LIBCPP_INLINE_VISIBILITY move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} - _LIBCPP_INLINE_VISIBILITY _Iter base() const {return __i;} - _LIBCPP_INLINE_VISIBILITY reference operator*() const { + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference operator*() const { return static_cast<reference>(*__i); } - _LIBCPP_INLINE_VISIBILITY pointer operator->() const { return __i;} - _LIBCPP_INLINE_VISIBILITY move_iterator& operator++() {++__i; return *this;} - _LIBCPP_INLINE_VISIBILITY move_iterator operator++(int) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 pointer operator->() const { return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator& operator++() {++__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} - _LIBCPP_INLINE_VISIBILITY move_iterator& operator--() {--__i; return *this;} - _LIBCPP_INLINE_VISIBILITY move_iterator operator--(int) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator& operator--() {--__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} - _LIBCPP_INLINE_VISIBILITY move_iterator operator+ (difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} - _LIBCPP_INLINE_VISIBILITY move_iterator& operator+=(difference_type __n) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} - _LIBCPP_INLINE_VISIBILITY move_iterator operator- (difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} - _LIBCPP_INLINE_VISIBILITY move_iterator& operator-=(difference_type __n) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); } @@ -1071,6 +1090,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -1079,6 +1099,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -1087,6 +1108,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -1095,6 +1117,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -1103,6 +1126,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -1111,6 +1135,7 @@ template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -1120,6 +1145,7 @@ #ifndef _LIBCPP_CXX03_LANG template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -> decltype(__x.base() - __y.base()) @@ -1129,6 +1155,7 @@ #else template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 typename move_iterator<_Iter1>::difference_type operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -1138,6 +1165,7 @@ template <class _Iter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator<_Iter> operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) { @@ -1146,6 +1174,7 @@ template <class _Iter> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator<_Iter> make_move_iterator(_Iter __i) { @@ -1569,7 +1598,7 @@ #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto begin(_Cp& __c) -> decltype(__c.begin()) { @@ -1577,7 +1606,7 @@ } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto begin(const _Cp& __c) -> decltype(__c.begin()) { @@ -1585,7 +1614,7 @@ } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto end(_Cp& __c) -> decltype(__c.end()) { @@ -1593,7 +1622,7 @@ } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto end(const _Cp& __c) -> decltype(__c.end()) { @@ -1603,14 +1632,14 @@ #if _LIBCPP_STD_VER > 11 template <class _Tp, size_t _Np> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) { return reverse_iterator<_Tp*>(__array + _Np); } template <class _Tp, size_t _Np> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) { return reverse_iterator<_Tp*>(__array); @@ -1645,42 +1674,42 @@ } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) { return __c.rbegin(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) { return __c.rbegin(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rend(_Cp& __c) -> decltype(__c.rend()) { return __c.rend(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rend(const _Cp& __c) -> decltype(__c.rend()) { return __c.rend(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto crbegin(const _Cp& __c) -> decltype(rbegin(__c)) { return rbegin(__c); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto crend(const _Cp& __c) -> decltype(rend(__c)) { return rend(__c); Index: include/array =================================================================== --- include/array +++ include/array @@ -37,20 +37,20 @@ void swap(array& a) noexcept(is_nothrow_swappable_v<T>); // iterators: - iterator begin() noexcept; - const_iterator begin() const noexcept; - iterator end() noexcept; - const_iterator end() const noexcept; + iterator begin() noexcept; // constexpr in C++17 + const_iterator begin() const noexcept; // constexpr in C++17 + iterator end() noexcept; // constexpr in C++17 + const_iterator end() const noexcept; // constexpr in C++17 - reverse_iterator rbegin() noexcept; - const_reverse_iterator rbegin() const noexcept; - reverse_iterator rend() noexcept; - const_reverse_iterator rend() const noexcept; + reverse_iterator rbegin() noexcept; // constexpr in C++17 + const_reverse_iterator rbegin() const noexcept; // constexpr in C++17 + reverse_iterator rend() noexcept; // constexpr in C++17 + const_reverse_iterator rend() const noexcept; // constexpr in C++17 - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - const_reverse_iterator crbegin() const noexcept; - const_reverse_iterator crend() const noexcept; + const_iterator cbegin() const noexcept; // constexpr in C++17 + const_iterator cend() const noexcept; // constexpr in C++17 + const_reverse_iterator crbegin() const noexcept; // constexpr in C++17 + const_reverse_iterator crend() const noexcept; // constexpr in C++17 // capacity: constexpr size_type size() const noexcept; @@ -58,18 +58,18 @@ constexpr bool empty() const noexcept; // element access: - reference operator[](size_type n); + reference operator[](size_type n); // constexpr in C++17 const_reference operator[](size_type n) const; // constexpr in C++14 const_reference at(size_type n) const; // constexpr in C++14 - reference at(size_type n); + reference at(size_type n); // constexpr in C++17 - reference front(); + reference front(); // constexpr in C++17 const_reference front() const; // constexpr in C++14 - reference back(); + reference back(); // constexpr in C++17 const_reference back() const; // constexpr in C++14 - T* data() noexcept; - const T* data() const noexcept; + T* data() noexcept; // constexpr in C++17 + const T* data() const noexcept; // constexpr in C++17 }; template <class T, size_t N> @@ -153,31 +153,31 @@ // iterators: _LIBCPP_INLINE_VISIBILITY - iterator begin() _NOEXCEPT {return iterator(__elems_);} + _LIBCPP_CONSTEXPR_AFTER_CXX14 iterator begin() _NOEXCEPT {return iterator(__elems_);} _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);} _LIBCPP_INLINE_VISIBILITY - iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);} + _LIBCPP_CONSTEXPR_AFTER_CXX14 iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);} _LIBCPP_INLINE_VISIBILITY - const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);} _LIBCPP_INLINE_VISIBILITY - reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} + _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY - reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} + _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY - const_iterator cbegin() const _NOEXCEPT {return begin();} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator cbegin() const _NOEXCEPT {return begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator cend() const _NOEXCEPT {return end();} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator cend() const _NOEXCEPT {return end();} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator crend() const _NOEXCEPT {return rend();} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator crend() const _NOEXCEPT {return rend();} // capacity: _LIBCPP_INLINE_VISIBILITY @@ -188,23 +188,24 @@ _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;} // element access: - _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __elems_[__n];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference operator[](size_type __n) {return __elems_[__n];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference operator[](size_type __n) const {return __elems_[__n];} - reference at(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n); _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const; - _LIBCPP_INLINE_VISIBILITY reference front() {return __elems_[0];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];} - _LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY - value_type* data() _NOEXCEPT {return __elems_;} + _LIBCPP_CONSTEXPR_AFTER_CXX14 value_type* data() _NOEXCEPT {return __elems_;} _LIBCPP_INLINE_VISIBILITY - const value_type* data() const _NOEXCEPT {return __elems_;} + _LIBCPP_CONSTEXPR_AFTER_CXX14 const value_type* data() const _NOEXCEPT {return __elems_;} }; template <class _Tp, size_t _Size> +_LIBCPP_CONSTEXPR_AFTER_CXX14 typename array<_Tp, _Size>::reference array<_Tp, _Size>::at(size_type __n) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits