fix distance

This commit is contained in:
bolero-MURAKAMI 2012-12-23 20:49:45 +09:00
parent 5fcb039ab4
commit 8a92528261

View file

@ -68,11 +68,22 @@ namespace sprout {
}
template<typename InputIterator>
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<InputIterator>::value,
typename std::iterator_traits<InputIterator>::difference_type
>::type
iterator_distance(InputIterator first, InputIterator last) {
typedef typename std::iterator_traits<InputIterator>::iterator_category* category;
return sprout::iterator_detail::iterator_distance(first, last, category());
}
template<typename InputIterator>
inline SPROUT_CONSTEXPR typename std::enable_if<
!std::is_literal_type<InputIterator>::value,
typename std::iterator_traits<InputIterator>::difference_type
>::type
iterator_distance(InputIterator first, InputIterator last) {
return std::distance(first, last);
}
} // namespace iterator_detail
} // namespace sprout
@ -92,7 +103,8 @@ namespace sprout {
//
// effect:
// ADL callable iterator_distance(first, last) -> iterator_distance(first, last)
// [first, last) is RandomAccessIterator && not Pointer -> last - first
// otherwise, [first, last) is LiteralType -> std::distance(first, last)
// otherwise, [first, last) is RandomAccessIterator && not Pointer -> last - first
// otherwise -> linearly count: first to last
//
template<typename InputIterator>