diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2017-05-17 18:51:36 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2017-05-17 18:51:36 +0000 |
commit | 9e6b540dad3d9793341613320a7f88aeaf43f010 (patch) | |
tree | 4f99c0bc0506a873ac1ef94b7416f7ac9a1859e3 /test/support | |
parent | 6a5647485a4e910ac67781d1a9e5782bb3f5d7e5 (diff) |
Make next/prev/advance/distance operations on iterators be constexpr. I missed this when I implemented the rest of P0031R0
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/test_iterators.h | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/test/support/test_iterators.h b/test/support/test_iterators.h index a2c22b09d..0fdb225b2 100644 --- a/test/support/test_iterators.h +++ b/test/support/test_iterators.h @@ -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, const forward_iterator<U>& y) 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<T>& x, const bidirectional_iterator<U>& 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<T>& x, const random_access_iterator<U>& 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<T>& x, const random_access_iterator<U>& 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>& x, const random_access_iterator<U>& y 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<T>& x, const random_access_iterator<U>& 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>& x, const random_access_iterator<U>& y 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>& x, const random_access_iterator<U>& y } 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 { |