[libcxx] r303281 - Make next/prev/advance/distance operations on iterators be constexpr. I missed this when I implemented the rest of P0031R0
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Wed May 17 11:51:37 PDT 2017
Author: marshall
Date: Wed May 17 13:51:36 2017
New Revision: 303281
URL: http://llvm.org/viewvc/llvm-project?rev=303281&view=rev
Log:
Make next/prev/advance/distance operations on iterators be constexpr. I missed this when I implemented the rest of P0031R0
Modified:
libcxx/trunk/include/iterator
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
libcxx/trunk/test/support/test_iterators.h
Modified: libcxx/trunk/include/iterator
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=303281&r1=303280&r2=303281&view=diff
==============================================================================
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Wed May 17 13:51:36 2017
@@ -64,14 +64,23 @@ struct forward_iterator_tag : publ
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+// 27.4.3, iterator operations
// extension: second argument not conforming to C++03
-template <class InputIterator>
-void advance(InputIterator& i,
+template <class InputIterator> // constexpr in C++17
+ constexpr void advance(InputIterator& i,
typename iterator_traits<InputIterator>::difference_type n);
-template <class InputIterator>
-typename iterator_traits<InputIterator>::difference_type
-distance(InputIterator first, InputIterator last);
+template <class InputIterator> // constexpr in C++17
+ constexpr typename iterator_traits<InputIterator>::difference_type
+ distance(InputIterator first, InputIterator last);
+
+template <class InputIterator> // constexpr in C++17
+ constexpr InputIterator next(InputIterator x,
+typename iterator_traits<InputIterator>::difference_type n = 1);
+
+template <class BidirectionalIterator> // constexpr in C++17
+ constexpr BidirectionalIterator prev(BidirectionalIterator x,
+ typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
template <class Iterator>
class reverse_iterator
@@ -529,7 +538,7 @@ struct _LIBCPP_TEMPLATE_VIS iterator
};
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
{
@@ -538,7 +547,7 @@ void __advance(_InputIter& __i,
}
template <class _BiDirIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_BiDirIter& __i,
typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
{
@@ -551,7 +560,7 @@ void __advance(_BiDirIter& __i,
}
template <class _RandIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_RandIter& __i,
typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
{
@@ -559,7 +568,7 @@ void __advance(_RandIter& __i,
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n)
{
@@ -567,7 +576,7 @@ void advance(_InputIter& __i,
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_InputIter>::difference_type
__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
{
@@ -578,7 +587,7 @@ __distance(_InputIter __first, _InputIte
}
template <class _RandIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_RandIter>::difference_type
__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
{
@@ -586,7 +595,7 @@ __distance(_RandIter __first, _RandIter
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_InputIter>::difference_type
distance(_InputIter __first, _InputIter __last)
{
@@ -594,7 +603,7 @@ distance(_InputIter __first, _InputIter
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_InputIter
next(_InputIter __x,
typename iterator_traits<_InputIter>::difference_type __n = 1,
@@ -605,7 +614,7 @@ next(_InputIter __x,
}
template <class _BidiretionalIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_BidiretionalIter
prev(_BidiretionalIter __x,
typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,
Modified: libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp?rev=303281&r1=303280&r2=303281&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp Wed May 17 13:51:36 2017
@@ -9,14 +9,16 @@
// <iterator>
+// All of these became constexpr in C++17
+//
// template <InputIterator Iter>
-// void advance(Iter& i, Iter::difference_type n);
+// constexpr void advance(Iter& i, Iter::difference_type n);
//
// template <BidirectionalIterator Iter>
-// void advance(Iter& i, Iter::difference_type n);
+// constexpr void advance(Iter& i, Iter::difference_type n);
//
// template <RandomAccessIterator Iter>
-// void advance(Iter& i, Iter::difference_type n);
+// constexpr void advance(Iter& i, Iter::difference_type n);
#include <iterator>
#include <cassert>
@@ -31,8 +33,19 @@ test(It i, typename std::iterator_traits
assert(i == x);
}
+#if TEST_STD_VER > 14
+template <class It>
+constexpr bool
+constepxr_test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::advance(i, n);
+ return i == x;
+}
+#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));
@@ -42,4 +55,18 @@ int main()
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( constepxr_test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)), "" );
+ static_assert( constepxr_test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10)), "" );
+ static_assert( constepxr_test(bidirectional_iterator<const char*>(s+5), 5, bidirectional_iterator<const char*>(s+10)), "" );
+ static_assert( constepxr_test(bidirectional_iterator<const char*>(s+5), -5, bidirectional_iterator<const char*>(s)), "" );
+ static_assert( constepxr_test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10)), "" );
+ static_assert( constepxr_test(random_access_iterator<const char*>(s+5), -5, random_access_iterator<const char*>(s)), "" );
+ static_assert( constepxr_test(s+5, 5, s+10), "" );
+ static_assert( constepxr_test(s+5, -5, s), "" );
+ }
+#endif
}
Modified: libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp?rev=303281&r1=303280&r2=303281&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp Wed May 17 13:51:36 2017
@@ -29,12 +29,33 @@ test(It first, It last, typename std::it
assert(std::distance(first, last) == x);
}
+#if TEST_STD_VER > 14
+template <class It>
+constexpr bool
+constexpr_test(It first, It last, typename std::iterator_traits<It>::difference_type x)
+{
+ return std::distance(first, last) == x;
+}
+#endif
+
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);
+ }
+#if TEST_STD_VER > 14
+ {
+ constexpr const char* s = "1234567890";
+ static_assert( constexpr_test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10), "");
+ static_assert( constexpr_test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+10), 10), "");
+ static_assert( constexpr_test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+10), 10), "");
+ static_assert( constexpr_test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10), "");
+ static_assert( constexpr_test(s, s+10, 10), "");
+ }
+#endif
}
Modified: libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp?rev=303281&r1=303280&r2=303281&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp Wed May 17 13:51:36 2017
@@ -33,8 +33,25 @@ test(It i, It x)
assert(std::next(i) == x);
}
+#if TEST_STD_VER > 14
+template <class It>
+constexpr bool
+constexpr_test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ return std::next(i, n) == x;
+}
+
+template <class It>
+constexpr bool
+constexpr_test(It i, It x)
+{
+ return std::next(i) == x;
+}
+#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));
@@ -47,4 +64,21 @@ int main()
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( constexpr_test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)), "" );
+ static_assert( constexpr_test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10)), "" );
+ static_assert( constexpr_test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10)), "" );
+ static_assert( constexpr_test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10)), "" );
+ static_assert( constexpr_test(s, 10, s+10), "" );
+
+ static_assert( constexpr_test(input_iterator<const char*>(s), input_iterator<const char*>(s+1)), "" );
+ static_assert( constexpr_test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1)), "" );
+ static_assert( constexpr_test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1)), "" );
+ static_assert( constexpr_test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1)), "" );
+ static_assert( constexpr_test(s, s+1), "" );
+ }
+#endif
}
Modified: libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp?rev=303281&r1=303280&r2=303281&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp Wed May 17 13:51:36 2017
@@ -31,8 +31,25 @@ test(It i, It x)
assert(std::prev(i) == x);
}
+#if TEST_STD_VER > 14
+template <class It>
+constexpr bool
+constexpr_test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ return std::prev(i, n) == x;
+}
+
+template <class It>
+constexpr bool
+constexpr_test(It i, It x)
+{
+ return std::prev(i) == x;
+}
+#endif
+
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));
@@ -41,4 +58,18 @@ int main()
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);
+ }
+#if TEST_STD_VER > 14
+ {
+ constexpr const char* s = "1234567890";
+ static_assert( constexpr_test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s)), "" );
+ static_assert( constexpr_test(random_access_iterator<const char*>(s+10), 10, random_access_iterator<const char*>(s)), "" );
+ static_assert( constexpr_test(s+10, 10, s), "" );
+
+ static_assert( constexpr_test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s)), "" );
+ static_assert( constexpr_test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s)), "" );
+ static_assert( constexpr_test(s+1, s), "" );
+ }
+#endif
+
}
Modified: libcxx/trunk/test/support/test_iterators.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_iterators.h?rev=303281&r1=303280&r2=303281&view=diff
==============================================================================
--- libcxx/trunk/test/support/test_iterators.h (original)
+++ libcxx/trunk/test/support/test_iterators.h Wed May 17 13:51:36 2017
@@ -68,23 +68,23 @@ public:
typedef It pointer;
typedef typename Traits::reference reference;
- It base() const {return it_;}
+ TEST_CONSTEXPR_CXX14 It base() const {return it_;}
- input_iterator() : it_() {}
- explicit input_iterator(It it) : it_(it) {}
+ TEST_CONSTEXPR_CXX14 input_iterator() : it_() {}
+ explicit TEST_CONSTEXPR_CXX14 input_iterator(It it) : it_(it) {}
template <class U, class T>
- input_iterator(const input_iterator<U, T>& u) :it_(u.it_) {}
+ TEST_CONSTEXPR_CXX14 input_iterator(const input_iterator<U, T>& u) :it_(u.it_) {}
- reference operator*() const {return *it_;}
- pointer operator->() const {return it_;}
+ TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
+ TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
- input_iterator& operator++() {++it_; return *this;}
- input_iterator operator++(int)
+ TEST_CONSTEXPR_CXX14 input_iterator& operator++() {++it_; return *this;}
+ TEST_CONSTEXPR_CXX14 input_iterator operator++(int)
{input_iterator tmp(*this); ++(*this); return tmp;}
- friend bool operator==(const input_iterator& x, const input_iterator& y)
+ friend TEST_CONSTEXPR_CXX14 bool operator==(const input_iterator& x, const input_iterator& y)
{return x.it_ == y.it_;}
- friend bool operator!=(const input_iterator& x, const input_iterator& y)
+ friend TEST_CONSTEXPR_CXX14 bool operator!=(const input_iterator& x, const input_iterator& y)
{return !(x == y);}
template <class T>
@@ -120,23 +120,23 @@ public:
typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference;
- It base() const {return it_;}
+ TEST_CONSTEXPR_CXX14 It base() const {return it_;}
- forward_iterator() : it_() {}
- explicit forward_iterator(It it) : it_(it) {}
+ TEST_CONSTEXPR_CXX14 forward_iterator() : it_() {}
+ explicit TEST_CONSTEXPR_CXX14 forward_iterator(It it) : it_(it) {}
template <class U>
- forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+ TEST_CONSTEXPR_CXX14 forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
- reference operator*() const {return *it_;}
- pointer operator->() const {return it_;}
+ TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
+ TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
- forward_iterator& operator++() {++it_; return *this;}
- forward_iterator operator++(int)
+ TEST_CONSTEXPR_CXX14 forward_iterator& operator++() {++it_; return *this;}
+ TEST_CONSTEXPR_CXX14 forward_iterator operator++(int)
{forward_iterator tmp(*this); ++(*this); return tmp;}
- friend bool operator==(const forward_iterator& x, const forward_iterator& y)
+ friend TEST_CONSTEXPR_CXX14 bool operator==(const forward_iterator& x, const forward_iterator& y)
{return x.it_ == y.it_;}
- friend bool operator!=(const forward_iterator& x, const forward_iterator& y)
+ friend TEST_CONSTEXPR_CXX14 bool operator!=(const forward_iterator& x, const forward_iterator& y)
{return !(x == y);}
template <class T>
@@ -145,7 +145,7 @@ public:
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
{
return x.base() == y.base();
@@ -153,7 +153,7 @@ operator==(const forward_iterator<T>& x,
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
{
return !(x == y);
@@ -172,22 +172,22 @@ public:
typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference;
- It base() const {return it_;}
+ TEST_CONSTEXPR_CXX14 It base() const {return it_;}
- bidirectional_iterator() : it_() {}
- explicit bidirectional_iterator(It it) : it_(it) {}
+ TEST_CONSTEXPR_CXX14 bidirectional_iterator() : it_() {}
+ explicit TEST_CONSTEXPR_CXX14 bidirectional_iterator(It it) : it_(it) {}
template <class U>
- bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+ TEST_CONSTEXPR_CXX14 bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
- reference operator*() const {return *it_;}
- pointer operator->() const {return it_;}
+ TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
+ TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
- bidirectional_iterator& operator++() {++it_; return *this;}
- bidirectional_iterator operator++(int)
+ TEST_CONSTEXPR_CXX14 bidirectional_iterator& operator++() {++it_; return *this;}
+ TEST_CONSTEXPR_CXX14 bidirectional_iterator operator++(int)
{bidirectional_iterator tmp(*this); ++(*this); return tmp;}
- bidirectional_iterator& operator--() {--it_; return *this;}
- bidirectional_iterator operator--(int)
+ TEST_CONSTEXPR_CXX14 bidirectional_iterator& operator--() {--it_; return *this;}
+ TEST_CONSTEXPR_CXX14 bidirectional_iterator operator--(int)
{bidirectional_iterator tmp(*this); --(*this); return tmp;}
template <class T>
@@ -196,7 +196,7 @@ public:
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
{
return x.base() == y.base();
@@ -204,7 +204,7 @@ operator==(const bidirectional_iterator<
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
{
return !(x == y);
@@ -223,34 +223,34 @@ public:
typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference;
- It base() const {return it_;}
+ TEST_CONSTEXPR_CXX14 It base() const {return it_;}
- random_access_iterator() : it_() {}
- explicit random_access_iterator(It it) : it_(it) {}
- template <class U>
- random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+ TEST_CONSTEXPR_CXX14 random_access_iterator() : it_() {}
+ explicit TEST_CONSTEXPR_CXX14 random_access_iterator(It it) : it_(it) {}
+ template <class U>
+ TEST_CONSTEXPR_CXX14 random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
- reference operator*() const {return *it_;}
- pointer operator->() const {return it_;}
+ TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
+ TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
- random_access_iterator& operator++() {++it_; return *this;}
- random_access_iterator operator++(int)
+ TEST_CONSTEXPR_CXX14 random_access_iterator& operator++() {++it_; return *this;}
+ TEST_CONSTEXPR_CXX14 random_access_iterator operator++(int)
{random_access_iterator tmp(*this); ++(*this); return tmp;}
- random_access_iterator& operator--() {--it_; return *this;}
- random_access_iterator operator--(int)
+ TEST_CONSTEXPR_CXX14 random_access_iterator& operator--() {--it_; return *this;}
+ TEST_CONSTEXPR_CXX14 random_access_iterator operator--(int)
{random_access_iterator tmp(*this); --(*this); return tmp;}
- random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
- random_access_iterator operator+(difference_type n) const
+ TEST_CONSTEXPR_CXX14 random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+ TEST_CONSTEXPR_CXX14 random_access_iterator operator+(difference_type n) const
{random_access_iterator tmp(*this); tmp += n; return tmp;}
- friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+ friend TEST_CONSTEXPR_CXX14 random_access_iterator operator+(difference_type n, random_access_iterator x)
{x += n; return x;}
- random_access_iterator& operator-=(difference_type n) {return *this += -n;}
- random_access_iterator operator-(difference_type n) const
+ TEST_CONSTEXPR_CXX14 random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+ TEST_CONSTEXPR_CXX14 random_access_iterator operator-(difference_type n) const
{random_access_iterator tmp(*this); tmp -= n; return tmp;}
- reference operator[](difference_type n) const {return it_[n];}
+ TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const {return it_[n];}
template <class T>
void operator,(T const &) DELETE_FUNCTION;
@@ -258,7 +258,7 @@ public:
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{
return x.base() == y.base();
@@ -266,7 +266,7 @@ operator==(const random_access_iterator<
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{
return !(x == y);
@@ -274,7 +274,7 @@ operator!=(const random_access_iterator<
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{
return x.base() < y.base();
@@ -282,7 +282,7 @@ operator<(const random_access_iterator<T
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{
return !(y < x);
@@ -290,7 +290,7 @@ operator<=(const random_access_iterator<
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{
return y < x;
@@ -298,14 +298,14 @@ operator>(const random_access_iterator<T
template <class T, class U>
inline
-bool
+bool TEST_CONSTEXPR_CXX14
operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{
return !(x < y);
}
template <class T, class U>
-inline
+inline TEST_CONSTEXPR_CXX14
typename std::iterator_traits<T>::difference_type
operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{
@@ -313,22 +313,22 @@ operator-(const random_access_iterator<T
}
template <class Iter>
-inline Iter base(output_iterator<Iter> i) { return i.base(); }
+inline TEST_CONSTEXPR_CXX14 Iter base(output_iterator<Iter> i) { return i.base(); }
template <class Iter>
-inline Iter base(input_iterator<Iter> i) { return i.base(); }
+inline TEST_CONSTEXPR_CXX14 Iter base(input_iterator<Iter> i) { return i.base(); }
template <class Iter>
-inline Iter base(forward_iterator<Iter> i) { return i.base(); }
+inline TEST_CONSTEXPR_CXX14 Iter base(forward_iterator<Iter> i) { return i.base(); }
template <class Iter>
-inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
+inline TEST_CONSTEXPR_CXX14 Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
template <class Iter>
-inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
+inline TEST_CONSTEXPR_CXX14 Iter base(random_access_iterator<Iter> i) { return i.base(); }
template <class Iter> // everything else
-inline Iter base(Iter i) { return i; }
+inline TEST_CONSTEXPR_CXX14 Iter base(Iter i) { return i; }
template <typename T>
struct ThrowingIterator {
More information about the cfe-commits
mailing list