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

fix adapt interface (range functions)

This commit is contained in:
bolero-MURAKAMI 2016-04-10 13:48:41 +09:00
parent 36e0b187c0
commit 4cceea862f
11 changed files with 479 additions and 585 deletions

View file

@ -12,42 +12,29 @@
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/container/traits_fwd.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/adl/not_found.hpp>
namespace sprout_adl {
sprout::not_found_via_adl range_size(...);
} // namespace sprout_adl
namespace sprout {
namespace container_detail {
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
range_size(Container const& cont) {
return sprout::container_range_traits<Container>::range_size(cont);
}
} // namespace container_detail
//
// size
//
// effect:
// ADL callable range_size(cont) -> range_size(cont)
// otherwise -> sprout::container_range_traits<Container>::range_size(cont)
// sprout::container_range_traits<Container>::range_size(cont)
// [default]
// callable cont.size() -> cont.size()
// otherwise -> distance(begin(cont), end(cont))
// ADL callable range_size(cont) -> range_size(cont)
// [default]
// Container is T[N] -> N
// callable cont.size() -> cont.size()
// otherwise -> distance(begin(cont), end(cont))
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
size(Container const& cont) {
using sprout::container_detail::range_size;
using sprout_adl::range_size;
return range_size(cont);
return sprout::container_range_traits<Container const>::range_size(cont);
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::size_type
size(T const (& arr)[N]) {
return sprout::container_detail::range_size(arr);
return sprout::container_range_traits<T const[N]>::range_size(arr);
}
} // namespace sprout