mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-29 03:57:17 +02:00
Updated constexpr tests for all affected modules. Added conditional constexpr to equal, which uses std::distance.
This commit is contained in:
@ -30,23 +30,23 @@ public:
|
||||
typedef It pointer;
|
||||
typedef typename std::iterator_traits<It>::reference reference;
|
||||
|
||||
It base() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR It base() const {return it_;}
|
||||
|
||||
input_iterator() : it_() {}
|
||||
explicit input_iterator(It it) : it_(it) {}
|
||||
BOOST_CXX14_CONSTEXPR input_iterator() : it_() {}
|
||||
BOOST_CXX14_CONSTEXPR explicit input_iterator(It it) : it_(it) {}
|
||||
|
||||
template <typename U>
|
||||
input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
|
||||
BOOST_CXX14_CONSTEXPR input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
|
||||
|
||||
reference operator*() const {return *it_;}
|
||||
pointer operator->() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR reference operator*() const {return *it_;}
|
||||
BOOST_CXX14_CONSTEXPR pointer operator->() const {return it_;}
|
||||
|
||||
input_iterator& operator++() {++it_; return *this;}
|
||||
input_iterator operator++(int) {input_iterator tmp(*this); ++(*this); return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR input_iterator& operator++() {++it_; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR input_iterator operator++(int) {input_iterator tmp(*this); ++(*this); return tmp;}
|
||||
|
||||
friend bool operator==(const input_iterator& x, const input_iterator& y)
|
||||
BOOST_CXX14_CONSTEXPR friend 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)
|
||||
BOOST_CXX14_CONSTEXPR friend bool operator!=(const input_iterator& x, const input_iterator& y)
|
||||
{return !(x == y);}
|
||||
|
||||
private:
|
||||
@ -55,14 +55,14 @@ private:
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator==(const input_iterator<T>& x, const input_iterator<U>& y)
|
||||
{
|
||||
return x.base() == y.base();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
@ -79,22 +79,22 @@ public:
|
||||
typedef It pointer;
|
||||
typedef typename std::iterator_traits<It>::reference reference;
|
||||
|
||||
It base() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR It base() const {return it_;}
|
||||
|
||||
forward_iterator() : it_() {}
|
||||
explicit forward_iterator(It it) : it_(it) {}
|
||||
BOOST_CXX14_CONSTEXPR forward_iterator() : it_() {}
|
||||
BOOST_CXX14_CONSTEXPR explicit forward_iterator(It it) : it_(it) {}
|
||||
template <typename U>
|
||||
forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
|
||||
BOOST_CXX14_CONSTEXPR forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
|
||||
|
||||
reference operator*() const {return *it_;}
|
||||
pointer operator->() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR reference operator*() const {return *it_;}
|
||||
BOOST_CXX14_CONSTEXPR pointer operator->() const {return it_;}
|
||||
|
||||
forward_iterator& operator++() {++it_; return *this;}
|
||||
forward_iterator operator++(int) {forward_iterator tmp(*this); ++(*this); return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR forward_iterator& operator++() {++it_; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR forward_iterator operator++(int) {forward_iterator tmp(*this); ++(*this); return tmp;}
|
||||
|
||||
friend bool operator==(const forward_iterator& x, const forward_iterator& y)
|
||||
BOOST_CXX14_CONSTEXPR friend 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)
|
||||
BOOST_CXX14_CONSTEXPR friend bool operator!=(const forward_iterator& x, const forward_iterator& y)
|
||||
{return !(x == y);}
|
||||
private:
|
||||
It it_;
|
||||
@ -103,14 +103,14 @@ private:
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
|
||||
{
|
||||
return x.base() == y.base();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
@ -127,35 +127,35 @@ public:
|
||||
typedef It pointer;
|
||||
typedef typename std::iterator_traits<It>::reference reference;
|
||||
|
||||
It base() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR It base() const {return it_;}
|
||||
|
||||
bidirectional_iterator() : it_() {}
|
||||
explicit bidirectional_iterator(It it) : it_(it) {}
|
||||
BOOST_CXX14_CONSTEXPR bidirectional_iterator() : it_() {}
|
||||
BOOST_CXX14_CONSTEXPR explicit bidirectional_iterator(It it) : it_(it) {}
|
||||
template <typename U>
|
||||
bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
|
||||
BOOST_CXX14_CONSTEXPR bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
|
||||
|
||||
reference operator*() const {return *it_;}
|
||||
pointer operator->() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR reference operator*() const {return *it_;}
|
||||
BOOST_CXX14_CONSTEXPR pointer operator->() const {return it_;}
|
||||
|
||||
bidirectional_iterator& operator++() {++it_; return *this;}
|
||||
bidirectional_iterator operator++(int) {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR bidirectional_iterator& operator++() {++it_; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR bidirectional_iterator operator++(int) {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
|
||||
|
||||
bidirectional_iterator& operator--() {--it_; return *this;}
|
||||
bidirectional_iterator operator--(int) {bidirectional_iterator tmp(*this); --(*this); return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR bidirectional_iterator& operator--() {--it_; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR bidirectional_iterator operator--(int) {bidirectional_iterator tmp(*this); --(*this); return tmp;}
|
||||
private:
|
||||
It it_;
|
||||
template <typename U> friend class bidirectional_iterator;
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
|
||||
{
|
||||
return x.base() == y.base();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
@ -172,30 +172,30 @@ public:
|
||||
typedef It pointer;
|
||||
typedef typename std::iterator_traits<It>::reference reference;
|
||||
|
||||
It base() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR It base() const {return it_;}
|
||||
|
||||
random_access_iterator() : it_() {}
|
||||
explicit random_access_iterator(It it) : it_(it) {}
|
||||
BOOST_CXX14_CONSTEXPR random_access_iterator() : it_() {}
|
||||
BOOST_CXX14_CONSTEXPR explicit random_access_iterator(It it) : it_(it) {}
|
||||
template <typename U>
|
||||
random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
|
||||
BOOST_CXX14_CONSTEXPR random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
|
||||
|
||||
reference operator*() const {return *it_;}
|
||||
pointer operator->() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR reference operator*() const {return *it_;}
|
||||
BOOST_CXX14_CONSTEXPR pointer operator->() const {return it_;}
|
||||
|
||||
random_access_iterator& operator++() {++it_; return *this;}
|
||||
random_access_iterator operator++(int) {random_access_iterator tmp(*this); ++(*this); return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR random_access_iterator& operator++() {++it_; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR 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) {random_access_iterator tmp(*this); --(*this); return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR random_access_iterator& operator--() {--it_; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR 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 {random_access_iterator tmp(*this); tmp += n; return tmp;}
|
||||
friend random_access_iterator operator+(difference_type n, random_access_iterator x) {x += n; return x;}
|
||||
BOOST_CXX14_CONSTEXPR random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR random_access_iterator operator+ (difference_type n) const {random_access_iterator tmp(*this); tmp += n; return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR friend 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 {random_access_iterator tmp(*this); tmp -= n; return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR random_access_iterator& operator-=(difference_type n) {return *this += -n;}
|
||||
BOOST_CXX14_CONSTEXPR 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];}
|
||||
BOOST_CXX14_CONSTEXPR reference operator[](difference_type n) const {return it_[n];}
|
||||
private:
|
||||
It it_;
|
||||
|
||||
@ -203,49 +203,49 @@ private:
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
|
||||
{
|
||||
return x.base() == y.base();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
|
||||
{
|
||||
return x.base() < y.base();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
|
||||
{
|
||||
return !(y < x);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
|
||||
{
|
||||
return y < x;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool
|
||||
BOOST_CXX14_CONSTEXPR inline bool
|
||||
operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
|
||||
{
|
||||
return !(x < y);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline typename std::iterator_traits<T>::difference_type
|
||||
BOOST_CXX14_CONSTEXPR inline typename std::iterator_traits<T>::difference_type
|
||||
operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
|
||||
{
|
||||
return x.base() - y.base();
|
||||
@ -262,18 +262,18 @@ public:
|
||||
typedef It pointer;
|
||||
typedef typename std::iterator_traits<It>::reference reference;
|
||||
|
||||
It base() const {return it_;}
|
||||
BOOST_CXX14_CONSTEXPR It base() const {return it_;}
|
||||
|
||||
output_iterator () {}
|
||||
explicit output_iterator(It it) : it_(it) {}
|
||||
BOOST_CXX14_CONSTEXPR output_iterator () {}
|
||||
BOOST_CXX14_CONSTEXPR explicit output_iterator(It it) : it_(it) {}
|
||||
|
||||
template <typename U>
|
||||
output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
|
||||
BOOST_CXX14_CONSTEXPR output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
|
||||
|
||||
reference operator*() const {return *it_;}
|
||||
BOOST_CXX14_CONSTEXPR reference operator*() const {return *it_;}
|
||||
|
||||
output_iterator& operator++() {++it_; return *this;}
|
||||
output_iterator operator++(int) {output_iterator tmp(*this); ++(*this); return tmp;}
|
||||
BOOST_CXX14_CONSTEXPR output_iterator& operator++() {++it_; return *this;}
|
||||
BOOST_CXX14_CONSTEXPR output_iterator operator++(int) {output_iterator tmp(*this); ++(*this); return tmp;}
|
||||
|
||||
private:
|
||||
It it_;
|
||||
@ -285,21 +285,21 @@ private:
|
||||
|
||||
// == Get the base of an iterator; used for comparisons ==
|
||||
template <typename Iter>
|
||||
inline Iter base(output_iterator<Iter> i) { return i.base(); }
|
||||
BOOST_CXX14_CONSTEXPR inline Iter base(output_iterator<Iter> i) { return i.base(); }
|
||||
|
||||
template <typename Iter>
|
||||
inline Iter base(input_iterator<Iter> i) { return i.base(); }
|
||||
BOOST_CXX14_CONSTEXPR inline Iter base(input_iterator<Iter> i) { return i.base(); }
|
||||
|
||||
template <typename Iter>
|
||||
inline Iter base(forward_iterator<Iter> i) { return i.base(); }
|
||||
BOOST_CXX14_CONSTEXPR inline Iter base(forward_iterator<Iter> i) { return i.base(); }
|
||||
|
||||
template <typename Iter>
|
||||
inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
|
||||
BOOST_CXX14_CONSTEXPR inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
|
||||
|
||||
template <typename Iter>
|
||||
inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
|
||||
BOOST_CXX14_CONSTEXPR inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
|
||||
|
||||
template <typename Iter> // everything else
|
||||
inline Iter base(Iter i) { return i; }
|
||||
BOOST_CXX14_CONSTEXPR inline Iter base(Iter i) { return i; }
|
||||
|
||||
#endif // ITERATORS_H
|
||||
|
Reference in New Issue
Block a user