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_empty(...);
} // namespace sprout_adl
namespace sprout {
namespace container_detail {
template<typename Container>
inline SPROUT_CONSTEXPR bool
range_empty(Container const& cont) {
return sprout::container_range_traits<Container>::range_empty(cont);
}
} // namespace container_detail
//
// empty
//
// effect:
// ADL callable range_empty(cont) -> range_empty(cont)
// otherwise -> sprout::container_range_traits<Container>::range_empty(cont)
// sprout::container_range_traits<Container>::range_empty(cont)
// [default]
// callable cont.empty() -> cont.empty()
// otherwise -> size(cont) == 0
// ADL callable range_empty(cont) -> range_empty(cont)
// [default]
// Container is T[N] -> false
// callable cont.empty() -> cont.empty()
// otherwise -> sprout::size(cont) == 0
//
template<typename Container>
inline SPROUT_CONSTEXPR bool
empty(Container const& cont) {
using sprout::container_detail::range_empty;
using sprout_adl::range_empty;
return range_empty(cont);
return sprout::container_range_traits<Container const>::range_empty(cont);
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR bool
empty(T const (& arr)[N]) {
return sprout::container_detail::range_empty(arr);
return sprout::container_range_traits<T const[N]>::range_empty(arr);
}
} // namespace sprout