1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

next, prev 修正

This commit is contained in:
bolero-MURAKAMI 2011-10-06 15:08:59 +09:00
parent ed469abdda
commit a52257117e
2 changed files with 14 additions and 8 deletions

View file

@ -57,9 +57,10 @@ namespace sprout {
//
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type next(Iterator&& it) {
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
return sprout::detail::next_impl(
sprout::forward<Iterator>(it),
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
category()
);
}
template<typename Iterator>
@ -68,10 +69,11 @@ namespace sprout {
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n
)
{
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
return sprout::detail::next_impl(
sprout::forward<Iterator>(it),
n,
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
category()
);
}
} // namespace sprout

View file

@ -20,12 +20,13 @@ namespace sprout {
return sprout::forward<Iterator>(it) - 1;
}
template<typename Iterator>
Iterator prev_impl(
SPROUT_CONSTEXPR typename std::decay<Iterator>::type prev_impl(
Iterator&& it,
void*
)
{
return std::prev(sprout::forward<Iterator>(it));
using std::prev;
return prev(sprout::forward<Iterator>(it));
}
template<typename Iterator>
@ -41,13 +42,14 @@ namespace sprout {
return sprout::forward<Iterator>(it) - n;
}
template<typename Iterator>
Iterator prev_impl(
SPROUT_CONSTEXPR typename std::decay<Iterator>::type prev_impl(
Iterator it,
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n,
void*
)
{
return std::prev(sprout::forward<Iterator>(it), n);
using std::prev;
return prev(sprout::forward<Iterator>(it), n);
}
} // namespace detail
//
@ -55,9 +57,10 @@ namespace sprout {
//
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type prev(Iterator&& it) {
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
return sprout::detail::prev_impl(
sprout::forward<Iterator>(it),
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
category()
);
}
template<typename Iterator>
@ -66,10 +69,11 @@ namespace sprout {
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n
)
{
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
return sprout::detail::prev_impl(
sprout::forward<Iterator>(it),
n,
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
category()
);
}
} // namespace sprout