#ifndef SPROUT_ITERATOR_PREV_HPP #define SPROUT_ITERATOR_PREV_HPP #include #include #include #include namespace sprout { namespace detail { template SPROUT_CONSTEXPR typename std::enable_if< std::is_literal_type::type>::value, typename std::decay::type >::type prev_impl( Iterator&& it, std::random_access_iterator_tag* ) { return sprout::forward(it) - 1; } template Iterator prev_impl( Iterator&& it, void* ) { return std::prev(sprout::forward(it)); } template SPROUT_CONSTEXPR typename std::enable_if< std::is_literal_type::type>::value, typename std::decay::type >::type prev_impl( Iterator&& it, typename std::iterator_traits::type>::difference_type n, std::random_access_iterator_tag* ) { return sprout::forward(it) - n; } template Iterator prev_impl( Iterator it, typename std::iterator_traits::type>::difference_type n, void* ) { return std::prev(sprout::forward(it), n); } } // namespace detail // // prev // template SPROUT_CONSTEXPR typename std::decay::type prev(Iterator&& it) { return sprout::detail::prev_impl( sprout::forward(it), static_cast::type>::iterator_category*>(nullptr) ); } template SPROUT_CONSTEXPR typename std::decay::type prev( Iterator&& it, typename std::iterator_traits::type>::difference_type n ) { return sprout::detail::prev_impl( sprout::forward(it), n, static_cast::type>::iterator_category*>(nullptr) ); } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_PREV_HPP