1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

sprout::detail::distance のADL追加

sprout/numeric/fixed/partial_sum.hpp 修正
sprout/numeric/fixed/adjacent_difference.hpp 修正
This commit is contained in:
bolero-MURAKAMI 2012-02-25 11:51:23 +09:00
parent bbe932a452
commit aa96f9ce73
13 changed files with 496 additions and 296 deletions

View file

@ -7,6 +7,28 @@
namespace sprout {
namespace detail {
namespace detail_ {
template<typename Iterator>
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type distance(
Iterator first,
Iterator last
)
{
return first == last
? 0
: 1 + sprout::detail::detail_::distance(sprout::next(first), last)
;
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type distance_impl(
Iterator first,
Iterator last
)
{
using sprout::detail::detail_::distance;
return distance(first, last);
}
} // namespace detail_
//
// distance
//
@ -16,7 +38,7 @@ namespace sprout {
Iterator last
)
{
return first == last ? 0 : 1 + sprout::detail::distance(sprout::next(first), last);
return sprout::detail::detail_::distance_impl(first, last);
}
template<typename Iterator>
@ -43,7 +65,10 @@ namespace sprout {
Iterator last
)
{
return first == last ? 0 : sprout::detail::bidirectional_distance_impl(sprout::next(first), sprout::prev(first), last);
return first == last
? 0
: sprout::detail::bidirectional_distance_impl(sprout::next(first), sprout::prev(first), last)
;
}
} // namespace detail
} // namespace sprout