2011-09-30 15:04:03 +00:00
|
|
|
#ifndef SPROUT_ITERATOR_NEXT_HPP
|
|
|
|
#define SPROUT_ITERATOR_NEXT_HPP
|
2011-10-26 06:57:31 +00:00
|
|
|
|
2011-09-30 15:04:03 +00:00
|
|
|
#include <iterator>
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace detail {
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename RandomAccessIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-04-04 08:48:02 +00:00
|
|
|
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value,
|
|
|
|
typename std::decay<RandomAccessIterator>::type
|
2011-09-30 15:04:03 +00:00
|
|
|
>::type next_impl(
|
2012-04-04 08:48:02 +00:00
|
|
|
RandomAccessIterator&& it,
|
2011-09-30 15:04:03 +00:00
|
|
|
std::random_access_iterator_tag*
|
|
|
|
)
|
|
|
|
{
|
2012-04-04 08:48:02 +00:00
|
|
|
return sprout::forward<RandomAccessIterator>(it) + 1;
|
2011-09-30 15:04:03 +00:00
|
|
|
}
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename ForwardIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next_impl(
|
2012-04-04 08:48:02 +00:00
|
|
|
ForwardIterator&& it,
|
2011-09-30 15:04:03 +00:00
|
|
|
void*
|
|
|
|
)
|
|
|
|
{
|
2012-09-21 06:43:30 +00:00
|
|
|
return std::next(sprout::forward<ForwardIterator>(it));
|
2011-09-30 15:04:03 +00:00
|
|
|
}
|
|
|
|
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename RandomAccessIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-04-04 08:48:02 +00:00
|
|
|
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value,
|
|
|
|
typename std::decay<RandomAccessIterator>::type
|
2011-09-30 15:04:03 +00:00
|
|
|
>::type next_impl(
|
2012-04-04 08:48:02 +00:00
|
|
|
RandomAccessIterator&& it,
|
|
|
|
typename std::iterator_traits<typename std::decay<RandomAccessIterator>::type>::difference_type n,
|
2011-09-30 15:04:03 +00:00
|
|
|
std::random_access_iterator_tag*
|
|
|
|
)
|
|
|
|
{
|
2012-04-04 08:48:02 +00:00
|
|
|
return sprout::forward<RandomAccessIterator>(it) + n;
|
2011-09-30 15:04:03 +00:00
|
|
|
}
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename ForwardIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next_impl(
|
2012-04-04 08:48:02 +00:00
|
|
|
ForwardIterator it,
|
|
|
|
typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::difference_type n,
|
2011-09-30 15:04:03 +00:00
|
|
|
void*
|
|
|
|
)
|
|
|
|
{
|
2012-09-21 06:43:30 +00:00
|
|
|
return std::next(sprout::forward<ForwardIterator>(it), n);
|
2011-09-30 15:04:03 +00:00
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// next
|
|
|
|
//
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename ForwardIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type
|
|
|
|
next(ForwardIterator&& it) {
|
2012-04-04 08:48:02 +00:00
|
|
|
typedef typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::iterator_category* category;
|
2011-09-30 15:04:03 +00:00
|
|
|
return sprout::detail::next_impl(
|
2012-04-04 08:48:02 +00:00
|
|
|
sprout::forward<ForwardIterator>(it),
|
2011-10-06 06:08:59 +00:00
|
|
|
category()
|
2011-09-30 15:04:03 +00:00
|
|
|
);
|
|
|
|
}
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename ForwardIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type
|
|
|
|
next(ForwardIterator&& it, typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::difference_type n) {
|
2012-04-04 08:48:02 +00:00
|
|
|
typedef typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::iterator_category* category;
|
2011-10-01 15:19:13 +00:00
|
|
|
return sprout::detail::next_impl(
|
2012-04-04 08:48:02 +00:00
|
|
|
sprout::forward<ForwardIterator>(it),
|
2011-10-01 15:19:13 +00:00
|
|
|
n,
|
2011-10-06 06:08:59 +00:00
|
|
|
category()
|
2011-10-01 15:19:13 +00:00
|
|
|
);
|
|
|
|
}
|
2011-09-30 15:04:03 +00:00
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ITERATOR_NEXT_HPP
|