From a5e7d61ad355a10d1737d490855311e2688e55b5 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Mon, 23 Mar 2015 12:04:57 +0900 Subject: [PATCH] fix nth(), index_of() --- sprout/array/array.hpp | 4 ++-- sprout/string/string.hpp | 6 ++--- sprout/sub_array/sub_array.hpp | 42 +++++++++++++++++----------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/sprout/array/array.hpp b/sprout/array/array.hpp index 587895d6..2a218dd2 100644 --- a/sprout/array/array.hpp +++ b/sprout/array/array.hpp @@ -230,7 +230,7 @@ namespace sprout { : (throw std::out_of_range("array<>: index out of range"), const_iterator()) ; } - SPROUT_CONSTEXPR size_type index_of(iterator p) const SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR size_type index_of(iterator p) SPROUT_NOEXCEPT { return p.index(); } SPROUT_CONSTEXPR size_type index_of(const_iterator p) const SPROUT_NOEXCEPT { @@ -249,7 +249,7 @@ namespace sprout { : (throw std::out_of_range("array<>: index out of range"), const_iterator()) ; } - SPROUT_CONSTEXPR size_type index_of(iterator p) const SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR size_type index_of(iterator p) SPROUT_NOEXCEPT { return sprout::distance(begin(), p); } SPROUT_CONSTEXPR size_type index_of(const_iterator p) const SPROUT_NOEXCEPT { diff --git a/sprout/string/string.hpp b/sprout/string/string.hpp index d9e0f216..0e7ffc2c 100644 --- a/sprout/string/string.hpp +++ b/sprout/string/string.hpp @@ -947,7 +947,7 @@ namespace sprout { : (throw std::out_of_range("basic_string<>: index out of range"), const_iterator()) ; } - SPROUT_CONSTEXPR size_type index_of(iterator p) const SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR size_type index_of(iterator p) SPROUT_NOEXCEPT { return p.index(); } SPROUT_CONSTEXPR size_type index_of(const_iterator p) const SPROUT_NOEXCEPT { @@ -965,8 +965,8 @@ namespace sprout { ? data() + i : (throw std::out_of_range("basic_string<>: index out of range"), const_iterator()) ; - } - SPROUT_CONSTEXPR size_type index_of(iterator p) const SPROUT_NOEXCEPT { + }SPROUT_CXX14_CONSTEXPR + SPROUT_CONSTEXPR size_type index_of(iterator p) SPROUT_NOEXCEPT { return sprout::distance(begin(), p); } SPROUT_CONSTEXPR size_type index_of(const_iterator p) const SPROUT_NOEXCEPT { diff --git a/sprout/sub_array/sub_array.hpp b/sprout/sub_array/sub_array.hpp index 316a5e7d..cf9715a9 100644 --- a/sprout/sub_array/sub_array.hpp +++ b/sprout/sub_array/sub_array.hpp @@ -271,8 +271,8 @@ namespace sprout { array_tag(), impl_type::template to_param(other.array_), sprout::make_index_tuple::make(), - sprout::distance(sprout::begin(other.get_array()), first), - sprout::distance(sprout::begin(other.get_array()), last) + sprout::distance(sprout::begin(other.get_internal()), first), + sprout::distance(sprout::begin(other.get_internal()), last) ) {} SPROUT_CONSTEXPR sub_array(sub_array const& other, difference_type to_first, difference_type to_last) @@ -312,22 +312,22 @@ namespace sprout { } // iterators: SPROUT_CXX14_CONSTEXPR iterator begin() { - return sprout::next(sprout::begin(get_array()), to_first_); + return sprout::next(sprout::begin(get_internal()), to_first_); } SPROUT_CONSTEXPR const_iterator begin() const { - return sprout::next(sprout::begin(get_array()), to_first_); + return sprout::next(sprout::begin(get_internal()), to_first_); } SPROUT_CXX14_CONSTEXPR iterator end() { - return sprout::next(sprout::begin(get_array()), to_last_); + return sprout::next(sprout::begin(get_internal()), to_last_); } SPROUT_CONSTEXPR const_iterator end() const { - return sprout::next(sprout::begin(get_array()), to_last_); + return sprout::next(sprout::begin(get_internal()), to_last_); } SPROUT_CONSTEXPR const_iterator cbegin() const { - return sprout::next(sprout::begin(get_array()), to_first_); + return sprout::next(sprout::begin(get_internal()), to_first_); } SPROUT_CONSTEXPR const_iterator cend() const { - return sprout::next(sprout::begin(get_array()), to_last_); + return sprout::next(sprout::begin(get_internal()), to_last_); } // capacity: SPROUT_CONSTEXPR size_type size() const { @@ -341,39 +341,39 @@ namespace sprout { } // element access: SPROUT_CXX14_CONSTEXPR reference operator[](size_type i) { - return *sprout::next(sprout::begin(get_array()), to_first_ + i); + return *sprout::next(sprout::begin(get_internal()), to_first_ + i); } SPROUT_CONSTEXPR const_reference operator[](size_type i) const { - return *sprout::next(sprout::begin(get_array()), to_first_ + i); + return *sprout::next(sprout::begin(get_internal()), to_first_ + i); } SPROUT_CXX14_CONSTEXPR reference at(size_type i) { - return i < size() ? *sprout::next(sprout::begin(get_array()), to_first_ + i) - : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), to_first_ + i)) + return i < size() ? *sprout::next(sprout::begin(get_internal()), to_first_ + i) + : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_internal()), to_first_ + i)) ; } SPROUT_CONSTEXPR const_reference at(size_type i) const { - return i < size() ? *sprout::next(sprout::begin(get_array()), to_first_ + i) - : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), to_first_ + i)) + return i < size() ? *sprout::next(sprout::begin(get_internal()), to_first_ + i) + : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_internal()), to_first_ + i)) ; } SPROUT_CXX14_CONSTEXPR reference front() { - return *sprout::next(sprout::begin(get_array()), to_first_); + return *sprout::next(sprout::begin(get_internal()), to_first_); } SPROUT_CONSTEXPR const_reference front() const { - return *sprout::next(sprout::begin(get_array()), to_first_); + return *sprout::next(sprout::begin(get_internal()), to_first_); } SPROUT_CXX14_CONSTEXPR reference back() { - return *sprout::next(sprout::begin(get_array()), to_last_ - 1); + return *sprout::next(sprout::begin(get_internal()), to_last_ - 1); } SPROUT_CONSTEXPR const_reference back() const { - return *sprout::next(sprout::begin(get_array()), to_last_ - 1); + return *sprout::next(sprout::begin(get_internal()), to_last_ - 1); } SPROUT_CXX14_CONSTEXPR pointer data() { - return get_array().data() + to_first_; + return get_internal().data() + to_first_; } SPROUT_CONSTEXPR const_pointer data() const { - return get_array().data() + to_first_; + return get_internal().data() + to_first_; } // others: SPROUT_CXX14_CONSTEXPR pointer c_array() { @@ -413,7 +413,7 @@ namespace sprout { return to_first_; } SPROUT_CONSTEXPR difference_type from_end() const { - return to_last_ - sprout::size(get_array()); + return to_last_ - sprout::size(get_internal()); } SPROUT_CXX14_CONSTEXPR iterator nth(size_type i) {