From a52257117e0e8df4b2ad2303f0547f5db962b512 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 6 Oct 2011 15:08:59 +0900 Subject: [PATCH] =?UTF-8?q?next,=20prev=20=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sprout/iterator/next.hpp | 6 ++++-- sprout/iterator/prev.hpp | 16 ++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/sprout/iterator/next.hpp b/sprout/iterator/next.hpp index 54843544..a031f9b9 100644 --- a/sprout/iterator/next.hpp +++ b/sprout/iterator/next.hpp @@ -57,9 +57,10 @@ namespace sprout { // template SPROUT_CONSTEXPR typename std::decay::type next(Iterator&& it) { + typedef typename std::iterator_traits::type>::iterator_category* category; return sprout::detail::next_impl( sprout::forward(it), - static_cast::type>::iterator_category*>(nullptr) + category() ); } template @@ -68,10 +69,11 @@ namespace sprout { typename std::iterator_traits::type>::difference_type n ) { + typedef typename std::iterator_traits::type>::iterator_category* category; return sprout::detail::next_impl( sprout::forward(it), n, - static_cast::type>::iterator_category*>(nullptr) + category() ); } } // namespace sprout diff --git a/sprout/iterator/prev.hpp b/sprout/iterator/prev.hpp index 195edd4b..1eb9c099 100644 --- a/sprout/iterator/prev.hpp +++ b/sprout/iterator/prev.hpp @@ -20,12 +20,13 @@ namespace sprout { return sprout::forward(it) - 1; } template - Iterator prev_impl( + SPROUT_CONSTEXPR typename std::decay::type prev_impl( Iterator&& it, void* ) { - return std::prev(sprout::forward(it)); + using std::prev; + return prev(sprout::forward(it)); } template @@ -41,13 +42,14 @@ namespace sprout { return sprout::forward(it) - n; } template - Iterator prev_impl( + SPROUT_CONSTEXPR typename std::decay::type prev_impl( Iterator it, typename std::iterator_traits::type>::difference_type n, void* ) { - return std::prev(sprout::forward(it), n); + using std::prev; + return prev(sprout::forward(it), n); } } // namespace detail // @@ -55,9 +57,10 @@ namespace sprout { // template SPROUT_CONSTEXPR typename std::decay::type prev(Iterator&& it) { + typedef typename std::iterator_traits::type>::iterator_category* category; return sprout::detail::prev_impl( sprout::forward(it), - static_cast::type>::iterator_category*>(nullptr) + category() ); } template @@ -66,10 +69,11 @@ namespace sprout { typename std::iterator_traits::type>::difference_type n ) { + typedef typename std::iterator_traits::type>::iterator_category* category; return sprout::detail::prev_impl( sprout::forward(it), n, - static_cast::type>::iterator_category*>(nullptr) + category() ); } } // namespace sprout