From f5411a03368a07dea91552f18577a841b3051563 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Mon, 5 Sep 2011 20:41:30 +0900 Subject: [PATCH] =?UTF-8?q?rbegin(),=20rend()=20=E4=BF=AE=E6=AD=A3=20rever?= =?UTF-8?q?se=5Fiterator=20=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sprout/array.hpp | 25 +++++++++++++------------ sprout/detail/iterator.hpp | 6 +++--- sprout/string.hpp | 14 +++++++------- sprout/sub_array.hpp | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/sprout/array.hpp b/sprout/array.hpp index 250e0768..da310d35 100644 --- a/sprout/array.hpp +++ b/sprout/array.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL @@ -40,7 +41,7 @@ namespace sprout { return N; } SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { - return N != 0; + return N == 0; } SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { return size(); @@ -69,23 +70,23 @@ namespace sprout { return &elems[0] + size(); } reverse_iterator rbegin() SPROUT_NOEXCEPT { - return reverse_iterator(begin()); - } - SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT { - return const_reverse_iterator(begin()); - } - SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT { - return const_reverse_iterator(begin()); - } - reverse_iterator rend() SPROUT_NOEXCEPT { return reverse_iterator(end()); } - SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT { + SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT { return const_reverse_iterator(end()); } - SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT { + SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT { return const_reverse_iterator(end()); } + reverse_iterator rend() SPROUT_NOEXCEPT { + return reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } reference operator[](size_type i) { return elems[i]; } diff --git a/sprout/detail/iterator.hpp b/sprout/detail/iterator.hpp index f7dbff16..4ce3e1a8 100644 --- a/sprout/detail/iterator.hpp +++ b/sprout/detail/iterator.hpp @@ -75,15 +75,15 @@ namespace sprout { reverse_iterator(reverse_iterator const&) = default; SPROUT_CONSTEXPR explicit reverse_iterator(iterator_type it) : current(it) - , deref_tmp(current - 1) + , deref_tmp(it - 1) {} template SPROUT_CONSTEXPR reverse_iterator(reverse_iterator const& it) : current(it) - , deref_tmp(current - 1) + , deref_tmp(it - 1) {} template - reverse_iterator& operator=(const reverse_iterator& it) { + reverse_iterator& operator=(reverse_iterator const& it) { reverse_iterator temp(it); temp.swap(this); return this; diff --git a/sprout/string.hpp b/sprout/string.hpp index a73c821d..ae218105 100644 --- a/sprout/string.hpp +++ b/sprout/string.hpp @@ -45,7 +45,7 @@ namespace sprout { return N; } SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { - return N != 0; + return N == 0; } SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { return size(); @@ -74,22 +74,22 @@ namespace sprout { return &elems[0] + size(); } reverse_iterator rbegin() SPROUT_NOEXCEPT { - return reverse_iterator(begin()); + return const_reverse_iterator(end()); } SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT { - return const_reverse_iterator(begin()); + return const_reverse_iterator(end()); } SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT { - return const_reverse_iterator(begin()); + return const_reverse_iterator(end()); } reverse_iterator rend() SPROUT_NOEXCEPT { - return reverse_iterator(end()); + return const_reverse_iterator(begin()); } SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT { - return const_reverse_iterator(end()); + return const_reverse_iterator(begin()); } SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT { - return const_reverse_iterator(end()); + return const_reverse_iterator(begin()); } reference operator[](size_type i) { return elems[i]; diff --git a/sprout/sub_array.hpp b/sprout/sub_array.hpp index 8bf5c63a..5d7fcd93 100644 --- a/sprout/sub_array.hpp +++ b/sprout/sub_array.hpp @@ -279,7 +279,7 @@ namespace sprout { return last_ - first_; } SPROUT_CONSTEXPR bool empty() const { - return size() != 0; + return size() == 0; } SPROUT_CONSTEXPR size_type max_size() const { return size();