1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

fix various iterator: for C++14 constexpr support

fix tools.test: add option --std=c++XX
This commit is contained in:
bolero-MURAKAMI 2013-10-09 01:03:36 +09:00
parent 54b6a2be18
commit 3dfe41361f
7 changed files with 103 additions and 46 deletions

View file

@ -65,7 +65,7 @@ namespace sprout {
: current_(it.current_)
{}
template<typename U>
counting_iterator& operator=(counting_iterator<U> const& it) {
SPROUT_CXX14_CONSTEXPR counting_iterator& operator=(counting_iterator<U> const& it) {
counting_iterator temp(it);
temp.swap(*this);
return *this;
@ -76,20 +76,20 @@ namespace sprout {
SPROUT_CONSTEXPR pointer operator->() const {
return &current_;
}
counting_iterator& operator++() {
SPROUT_CXX14_CONSTEXPR counting_iterator& operator++() {
++current_;
return *this;
}
counting_iterator operator++(int) {
SPROUT_CXX14_CONSTEXPR counting_iterator operator++(int) {
counting_iterator result(*this);
++current_;
return result;
}
counting_iterator& operator--() {
SPROUT_CXX14_CONSTEXPR counting_iterator& operator--() {
--current_;
return *this;
}
counting_iterator operator--(int) {
SPROUT_CXX14_CONSTEXPR counting_iterator operator--(int) {
counting_iterator temp(*this);
--current_;
return temp;
@ -100,12 +100,12 @@ namespace sprout {
SPROUT_CONSTEXPR counting_iterator operator-(difference_type n) const {
return counting_iterator(current_ - n);
}
counting_iterator& operator+=(difference_type n) {
SPROUT_CXX14_CONSTEXPR counting_iterator& operator+=(difference_type n) {
counting_iterator temp(current_ + n);
temp.swap(*this);
return *this;
}
counting_iterator& operator-=(difference_type n) {
SPROUT_CXX14_CONSTEXPR counting_iterator& operator-=(difference_type n) {
counting_iterator temp(current_ - n);
temp.swap(*this);
return *this;
@ -119,7 +119,7 @@ namespace sprout {
SPROUT_CONSTEXPR counting_iterator prev() const {
return counting_iterator(current_ - 1);
}
void swap(counting_iterator& other)
SPROUT_CXX14_CONSTEXPR void swap(counting_iterator& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(current_, other.current_)))
{
sprout::swap(current_, other.current_);
@ -184,7 +184,7 @@ namespace sprout {
// swap
//
template<typename Incrementable>
inline void
inline SPROUT_CXX14_CONSTEXPR void
swap(sprout::counting_iterator<Incrementable>& lhs, sprout::counting_iterator<Incrementable>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{

View file

@ -51,7 +51,7 @@ namespace sprout {
)
: gen_(gen), index_(index)
{}
generator_type& generator() {
SPROUT_CXX14_CONSTEXPR generator_type& generator() {
return gen_;
}
SPROUT_CONSTEXPR generator_type const& generator() const {
@ -72,7 +72,7 @@ namespace sprout {
SPROUT_CONSTEXPR generator_iterator next_generator() const {
return (*this)();
}
void swap(generator_iterator& other)
SPROUT_CXX14_CONSTEXPR void swap(generator_iterator& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(gen_, other.gen_)))
{
sprout::swap(gen_, other.gen_);
@ -84,12 +84,12 @@ namespace sprout {
SPROUT_CONSTEXPR pointer operator->() const {
return &*(*this);
}
generator_iterator& operator++() {
SPROUT_CXX14_CONSTEXPR generator_iterator& operator++() {
generator_iterator temp((*this)());
temp.swap(*this);
return *this;
}
generator_iterator operator++(int) {
SPROUT_CXX14_CONSTEXPR generator_iterator operator++(int) {
generator_iterator result(*this);
++*this;
return result;
@ -136,7 +136,7 @@ namespace sprout {
// swap
//
template<typename Generator>
inline void
inline SPROUT_CXX14_CONSTEXPR void
swap(sprout::generator_iterator<Generator>& lhs, sprout::generator_iterator<Generator>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{

View file

@ -101,7 +101,7 @@ namespace sprout {
SPROUT_CONSTEXPR index_iterator(typename holder_type::param_type p, difference_type index)
: holder_(p), index_(index)
{}
operator index_iterator<const_container_type>() const {
SPROUT_CONSTEXPR operator index_iterator<const_container_type>() const {
return index_iterator<const_container_type>(holder_.get(), index_);
}
SPROUT_CONSTEXPR typename holder_type::mutable_or_const_reference base() const {
@ -116,7 +116,7 @@ namespace sprout {
SPROUT_CONSTEXPR index_iterator prev() const {
return index_iterator(holder_, index_ - 1);
}
void swap(index_iterator& other)
SPROUT_CXX14_CONSTEXPR void swap(index_iterator& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(holder_, other.holder_)))
{
sprout::swap(holder_, other.holder_);
@ -128,22 +128,22 @@ namespace sprout {
SPROUT_CONSTEXPR pointer operator->() const {
return &holder_.get()[index_];
}
index_iterator& operator++() {
SPROUT_CXX14_CONSTEXPR index_iterator& operator++() {
index_iterator temp(next());
temp.swap(*this);
return *this;
}
index_iterator operator++(int) {
SPROUT_CXX14_CONSTEXPR index_iterator operator++(int) {
index_iterator result(*this);
++*this;
return result;
}
index_iterator& operator--() {
SPROUT_CXX14_CONSTEXPR index_iterator& operator--() {
index_iterator temp(prev());
temp.swap(*this);
return *this;
}
index_iterator operator--(int) {
SPROUT_CXX14_CONSTEXPR index_iterator operator--(int) {
index_iterator result(*this);
--*this;
return result;
@ -154,12 +154,12 @@ namespace sprout {
SPROUT_CONSTEXPR index_iterator operator-(difference_type n) const {
return index_iterator(holder_, index_ - n);
}
index_iterator& operator+=(difference_type n) {
SPROUT_CXX14_CONSTEXPR index_iterator& operator+=(difference_type n) {
index_iterator temp(holder_, index_ + n);
temp.swap(*this);
return *this;
}
index_iterator& operator-=(difference_type n) {
SPROUT_CXX14_CONSTEXPR index_iterator& operator-=(difference_type n) {
index_iterator temp(holder_, index_ - n);
temp.swap(*this);
return *this;
@ -238,7 +238,7 @@ namespace sprout {
// swap
//
template<typename Container, bool C>
inline void
inline SPROUT_CXX14_CONSTEXPR void
swap(sprout::index_iterator<Container, C>& lhs, sprout::index_iterator<Container, C>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{

View file

@ -68,7 +68,7 @@ namespace sprout {
SPROUT_CONSTEXPR ptr_index_iterator(pointer p, difference_type index)
: p_(p), index_(index)
{}
operator ptr_index_iterator<const_pointer>() const {
SPROUT_CONSTEXPR operator ptr_index_iterator<const_pointer>() const {
return ptr_index_iterator<const_pointer>(p_, index_);
}
SPROUT_CONSTEXPR pointer base() const {
@ -86,7 +86,7 @@ namespace sprout {
SPROUT_CONSTEXPR ptr_index_iterator prev() const {
return ptr_index_iterator(p_, index_ - 1);
}
void swap(ptr_index_iterator& other)
SPROUT_CXX14_CONSTEXPR void swap(ptr_index_iterator& other)
SPROUT_NOEXCEPT
{
sprout::swap(p_, other.p_);
@ -98,22 +98,22 @@ namespace sprout {
SPROUT_CONSTEXPR pointer operator->() const {
return p_ + index_;
}
ptr_index_iterator& operator++() {
SPROUT_CXX14_CONSTEXPR ptr_index_iterator& operator++() {
ptr_index_iterator temp(next());
temp.swap(*this);
return *this;
}
ptr_index_iterator operator++(int) {
SPROUT_CXX14_CONSTEXPR ptr_index_iterator operator++(int) {
ptr_index_iterator result(*this);
++*this;
return result;
}
ptr_index_iterator& operator--() {
SPROUT_CXX14_CONSTEXPR ptr_index_iterator& operator--() {
ptr_index_iterator temp(prev());
temp.swap(*this);
return *this;
}
ptr_index_iterator operator--(int) {
SPROUT_CXX14_CONSTEXPR ptr_index_iterator operator--(int) {
ptr_index_iterator result(*this);
--*this;
return result;
@ -124,12 +124,12 @@ namespace sprout {
SPROUT_CONSTEXPR ptr_index_iterator operator-(difference_type n) const {
return ptr_index_iterator(p_, index_ - n);
}
ptr_index_iterator& operator+=(difference_type n) {
SPROUT_CXX14_CONSTEXPR ptr_index_iterator& operator+=(difference_type n) {
ptr_index_iterator temp(p_, index_ + n);
temp.swap(*this);
return *this;
}
ptr_index_iterator& operator-=(difference_type n) {
SPROUT_CXX14_CONSTEXPR ptr_index_iterator& operator-=(difference_type n) {
ptr_index_iterator temp(p_, index_ - n);
temp.swap(*this);
return *this;
@ -208,7 +208,7 @@ namespace sprout {
// swap
//
template<typename T>
inline void
inline SPROUT_CXX14_CONSTEXPR void
swap(sprout::ptr_index_iterator<T>& lhs, sprout::ptr_index_iterator<T>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{

View file

@ -73,7 +73,7 @@ namespace sprout {
)
: holder_(p), index_(index)
{}
operator value_iterator<const_type>() const {
SPROUT_CONSTEXPR operator value_iterator<const_type>() const {
return value_iterator<const_type>(holder_.get(), index_);
}
SPROUT_CONSTEXPR difference_type index() const {
@ -85,7 +85,7 @@ namespace sprout {
SPROUT_CONSTEXPR value_iterator prev() const {
return value_iterator(holder_, index_ + 1);
}
void swap(value_iterator& other)
SPROUT_CXX14_CONSTEXPR void swap(value_iterator& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(holder_, other.holder_)))
{
sprout::swap(holder_, other.holder_);
@ -97,22 +97,22 @@ namespace sprout {
SPROUT_CONSTEXPR pointer operator->() const {
return holder_.get_pointer();
}
value_iterator& operator++() {
SPROUT_CXX14_CONSTEXPR value_iterator& operator++() {
value_iterator temp(next());
temp.swap(*this);
return *this;
}
value_iterator operator++(int) {
SPROUT_CXX14_CONSTEXPR value_iterator operator++(int) {
value_iterator result(*this);
++*this;
return result;
}
value_iterator& operator--() {
SPROUT_CXX14_CONSTEXPR value_iterator& operator--() {
value_iterator temp(prev());
temp.swap(*this);
return *this;
}
value_iterator operator--(int) {
SPROUT_CXX14_CONSTEXPR value_iterator operator--(int) {
value_iterator result(*this);
--*this;
return result;
@ -123,12 +123,12 @@ namespace sprout {
SPROUT_CONSTEXPR value_iterator operator-(difference_type n) const {
return value_iterator(holder_, index_ + n);
}
value_iterator& operator+=(difference_type n) {
SPROUT_CXX14_CONSTEXPR value_iterator& operator+=(difference_type n) {
value_iterator temp(holder_, index_ - n);
temp.swap(*this);
return *this;
}
value_iterator& operator-=(difference_type n) {
SPROUT_CXX14_CONSTEXPR value_iterator& operator-=(difference_type n) {
value_iterator temp(holder_, index_ + n);
temp.swap(*this);
return *this;
@ -183,7 +183,7 @@ namespace sprout {
// swap
//
template<typename T>
inline void
inline SPROUT_CXX14_CONSTEXPR void
swap(sprout::value_iterator<T>& lhs, sprout::value_iterator<T>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{