Make next/prev/advance/distance operations on iterators be constexpr. I missed this when I implemented the rest of P0031R0

llvm-svn: 303281
This commit is contained in:
Marshall Clow 2017-05-17 18:51:36 +00:00
parent d38107b566
commit f51ee63247
6 changed files with 203 additions and 81 deletions

View File

@ -64,14 +64,23 @@ struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {}; struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {}; struct random_access_iterator_tag : public bidirectional_iterator_tag {};
// 27.4.3, iterator operations
// extension: second argument not conforming to C++03 // extension: second argument not conforming to C++03
template <class InputIterator> template <class InputIterator> // constexpr in C++17
void advance(InputIterator& i, constexpr void advance(InputIterator& i,
typename iterator_traits<InputIterator>::difference_type n); typename iterator_traits<InputIterator>::difference_type n);
template <class InputIterator> template <class InputIterator> // constexpr in C++17
typename iterator_traits<InputIterator>::difference_type constexpr typename iterator_traits<InputIterator>::difference_type
distance(InputIterator first, InputIterator last); 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> template <class Iterator>
class reverse_iterator class reverse_iterator
@ -529,7 +538,7 @@ struct _LIBCPP_TEMPLATE_VIS iterator
}; };
template <class _InputIter> template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_InputIter& __i, void __advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
{ {
@ -538,7 +547,7 @@ void __advance(_InputIter& __i,
} }
template <class _BiDirIter> template <class _BiDirIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_BiDirIter& __i, void __advance(_BiDirIter& __i,
typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
{ {
@ -551,7 +560,7 @@ void __advance(_BiDirIter& __i,
} }
template <class _RandIter> template <class _RandIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_RandIter& __i, void __advance(_RandIter& __i,
typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
{ {
@ -559,7 +568,7 @@ void __advance(_RandIter& __i,
} }
template <class _InputIter> template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void advance(_InputIter& __i, void advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n) typename iterator_traits<_InputIter>::difference_type __n)
{ {
@ -567,7 +576,7 @@ void advance(_InputIter& __i,
} }
template <class _InputIter> template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_InputIter>::difference_type typename iterator_traits<_InputIter>::difference_type
__distance(_InputIter __first, _InputIter __last, input_iterator_tag) __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
{ {
@ -578,7 +587,7 @@ __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
} }
template <class _RandIter> template <class _RandIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_RandIter>::difference_type typename iterator_traits<_RandIter>::difference_type
__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
{ {
@ -586,7 +595,7 @@ __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
} }
template <class _InputIter> template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_InputIter>::difference_type typename iterator_traits<_InputIter>::difference_type
distance(_InputIter __first, _InputIter __last) distance(_InputIter __first, _InputIter __last)
{ {
@ -594,7 +603,7 @@ distance(_InputIter __first, _InputIter __last)
} }
template <class _InputIter> template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_InputIter _InputIter
next(_InputIter __x, next(_InputIter __x,
typename iterator_traits<_InputIter>::difference_type __n = 1, typename iterator_traits<_InputIter>::difference_type __n = 1,
@ -605,7 +614,7 @@ next(_InputIter __x,
} }
template <class _BidiretionalIter> template <class _BidiretionalIter>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_BidiretionalIter _BidiretionalIter
prev(_BidiretionalIter __x, prev(_BidiretionalIter __x,
typename iterator_traits<_BidiretionalIter>::difference_type __n = 1, typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,

View File

@ -9,14 +9,16 @@
// <iterator> // <iterator>
// All of these became constexpr in C++17
//
// template <InputIterator Iter> // template <InputIterator Iter>
// void advance(Iter& i, Iter::difference_type n); // constexpr void advance(Iter& i, Iter::difference_type n);
// //
// template <BidirectionalIterator Iter> // template <BidirectionalIterator Iter>
// void advance(Iter& i, Iter::difference_type n); // constexpr void advance(Iter& i, Iter::difference_type n);
// //
// template <RandomAccessIterator Iter> // template <RandomAccessIterator Iter>
// void advance(Iter& i, Iter::difference_type n); // constexpr void advance(Iter& i, Iter::difference_type n);
#include <iterator> #include <iterator>
#include <cassert> #include <cassert>
@ -31,8 +33,19 @@ test(It i, typename std::iterator_traits<It>::difference_type n, It x)
assert(i == x); 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() int main()
{ {
{
const char* s = "1234567890"; const char* s = "1234567890";
test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)); 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(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(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+10);
test(s+5, -5, s); 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
} }

View File

@ -29,12 +29,33 @@ test(It first, It last, typename std::iterator_traits<It>::difference_type x)
assert(std::distance(first, last) == x); 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() int main()
{ {
{
const char* s = "1234567890"; const char* s = "1234567890";
test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10); 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(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(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(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10);
test(s, 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
} }

View File

@ -33,8 +33,25 @@ test(It i, It x)
assert(std::next(i) == 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() int main()
{ {
{
const char* s = "1234567890"; const char* s = "1234567890";
test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10)); 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(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(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(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1));
test(s, 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
} }

View File

@ -31,8 +31,25 @@ test(It i, It x)
assert(std::prev(i) == 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() int main()
{ {
{
const char* s = "1234567890"; const char* s = "1234567890";
test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s)); 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(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(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(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
test(s+1, 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
} }

View File

@ -68,23 +68,23 @@ public:
typedef It pointer; typedef It pointer;
typedef typename Traits::reference reference; typedef typename Traits::reference reference;
It base() const {return it_;} TEST_CONSTEXPR_CXX14 It base() const {return it_;}
input_iterator() : it_() {} TEST_CONSTEXPR_CXX14 input_iterator() : it_() {}
explicit input_iterator(It it) : it_(it) {} explicit TEST_CONSTEXPR_CXX14 input_iterator(It it) : it_(it) {}
template <class U, class T> 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_;} TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
pointer operator->() const {return it_;} TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
input_iterator& operator++() {++it_; return *this;} TEST_CONSTEXPR_CXX14 input_iterator& operator++() {++it_; return *this;}
input_iterator operator++(int) TEST_CONSTEXPR_CXX14 input_iterator operator++(int)
{input_iterator tmp(*this); ++(*this); return tmp;} {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_;} {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);} {return !(x == y);}
template <class T> template <class T>
@ -120,23 +120,23 @@ public:
typedef It pointer; typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference; typedef typename std::iterator_traits<It>::reference reference;
It base() const {return it_;} TEST_CONSTEXPR_CXX14 It base() const {return it_;}
forward_iterator() : it_() {} TEST_CONSTEXPR_CXX14 forward_iterator() : it_() {}
explicit forward_iterator(It it) : it_(it) {} explicit TEST_CONSTEXPR_CXX14 forward_iterator(It it) : it_(it) {}
template <class U> 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_;} TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
pointer operator->() const {return it_;} TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
forward_iterator& operator++() {++it_; return *this;} TEST_CONSTEXPR_CXX14 forward_iterator& operator++() {++it_; return *this;}
forward_iterator operator++(int) TEST_CONSTEXPR_CXX14 forward_iterator operator++(int)
{forward_iterator tmp(*this); ++(*this); return tmp;} {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_;} {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);} {return !(x == y);}
template <class T> template <class T>
@ -145,7 +145,7 @@ public:
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator==(const forward_iterator<T>& x, const forward_iterator<U>& y) operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
{ {
return x.base() == y.base(); return x.base() == y.base();
@ -153,7 +153,7 @@ operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y) operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
{ {
return !(x == y); return !(x == y);
@ -172,22 +172,22 @@ public:
typedef It pointer; typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference; typedef typename std::iterator_traits<It>::reference reference;
It base() const {return it_;} TEST_CONSTEXPR_CXX14 It base() const {return it_;}
bidirectional_iterator() : it_() {} TEST_CONSTEXPR_CXX14 bidirectional_iterator() : it_() {}
explicit bidirectional_iterator(It it) : it_(it) {} explicit TEST_CONSTEXPR_CXX14 bidirectional_iterator(It it) : it_(it) {}
template <class U> 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_;} TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
pointer operator->() const {return it_;} TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
bidirectional_iterator& operator++() {++it_; return *this;} TEST_CONSTEXPR_CXX14 bidirectional_iterator& operator++() {++it_; return *this;}
bidirectional_iterator operator++(int) TEST_CONSTEXPR_CXX14 bidirectional_iterator operator++(int)
{bidirectional_iterator tmp(*this); ++(*this); return tmp;} {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
bidirectional_iterator& operator--() {--it_; return *this;} TEST_CONSTEXPR_CXX14 bidirectional_iterator& operator--() {--it_; return *this;}
bidirectional_iterator operator--(int) TEST_CONSTEXPR_CXX14 bidirectional_iterator operator--(int)
{bidirectional_iterator tmp(*this); --(*this); return tmp;} {bidirectional_iterator tmp(*this); --(*this); return tmp;}
template <class T> template <class T>
@ -196,7 +196,7 @@ public:
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y) operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
{ {
return x.base() == y.base(); return x.base() == y.base();
@ -204,7 +204,7 @@ operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>&
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y) operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
{ {
return !(x == y); return !(x == y);
@ -223,34 +223,34 @@ public:
typedef It pointer; typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference; 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_() {} TEST_CONSTEXPR_CXX14 random_access_iterator() : it_() {}
explicit random_access_iterator(It it) : it_(it) {} explicit TEST_CONSTEXPR_CXX14 random_access_iterator(It it) : it_(it) {}
template <class U> template <class U>
random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {} TEST_CONSTEXPR_CXX14 random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
reference operator*() const {return *it_;} TEST_CONSTEXPR_CXX14 reference operator*() const {return *it_;}
pointer operator->() const {return it_;} TEST_CONSTEXPR_CXX14 pointer operator->() const {return it_;}
random_access_iterator& operator++() {++it_; return *this;} TEST_CONSTEXPR_CXX14 random_access_iterator& operator++() {++it_; return *this;}
random_access_iterator operator++(int) TEST_CONSTEXPR_CXX14 random_access_iterator operator++(int)
{random_access_iterator tmp(*this); ++(*this); return tmp;} {random_access_iterator tmp(*this); ++(*this); return tmp;}
random_access_iterator& operator--() {--it_; return *this;} TEST_CONSTEXPR_CXX14 random_access_iterator& operator--() {--it_; return *this;}
random_access_iterator operator--(int) TEST_CONSTEXPR_CXX14 random_access_iterator operator--(int)
{random_access_iterator tmp(*this); --(*this); return tmp;} {random_access_iterator tmp(*this); --(*this); return tmp;}
random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;} TEST_CONSTEXPR_CXX14 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) const
{random_access_iterator tmp(*this); tmp += n; return tmp;} {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;} {x += n; return x;}
random_access_iterator& operator-=(difference_type n) {return *this += -n;} TEST_CONSTEXPR_CXX14 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) const
{random_access_iterator tmp(*this); tmp -= n; return tmp;} {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> template <class T>
void operator,(T const &) DELETE_FUNCTION; void operator,(T const &) DELETE_FUNCTION;
@ -258,7 +258,7 @@ public:
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y) operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{ {
return x.base() == y.base(); return x.base() == y.base();
@ -266,7 +266,7 @@ operator==(const random_access_iterator<T>& x, const random_access_iterator<U>&
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y) operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{ {
return !(x == y); return !(x == y);
@ -274,7 +274,7 @@ operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>&
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y) operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{ {
return x.base() < y.base(); return x.base() < y.base();
@ -282,7 +282,7 @@ operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y) operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{ {
return !(y < x); return !(y < x);
@ -290,7 +290,7 @@ operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>&
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y) operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{ {
return y < x; return y < x;
@ -298,14 +298,14 @@ operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y
template <class T, class U> template <class T, class U>
inline inline
bool bool TEST_CONSTEXPR_CXX14
operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y) operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{ {
return !(x < y); return !(x < y);
} }
template <class T, class U> template <class T, class U>
inline inline TEST_CONSTEXPR_CXX14
typename std::iterator_traits<T>::difference_type typename std::iterator_traits<T>::difference_type
operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y) operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
{ {
@ -313,22 +313,22 @@ operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y
} }
template <class Iter> 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> 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> 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> 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> 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 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> template <typename T>
struct ThrowingIterator { struct ThrowingIterator {