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