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:
parent
36e0b187c0
commit
4cceea862f
11 changed files with 479 additions and 585 deletions
|
@ -12,59 +12,39 @@
|
|||
#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_at(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_at(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return sprout::container_range_traits<Container>::range_at(cont, i);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_at(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return sprout::container_range_traits<Container>::range_at(cont, i);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// at
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_at(cont, i) -> range_at(cont, i)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_at(cont, i)
|
||||
// sprout::container_range_traits<Container>::range_at(cont, i)
|
||||
// [default]
|
||||
// callable cont.at(i) -> cont.at(i)
|
||||
// otherwise -> *next(begin(cont), i)
|
||||
// ADL callable range_at(cont, i) -> range_at(cont, i)
|
||||
// [default]
|
||||
// Container is T[N] -> cont[i]
|
||||
// callable cont.at(i) -> cont.at(i)
|
||||
// otherwise -> *sprout::next(sprout::begin(cont), i)
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
at(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
using sprout::container_detail::range_at;
|
||||
using sprout_adl::range_at;
|
||||
return range_at(cont, i);
|
||||
return sprout::container_range_traits<Container>::range_at(cont, i);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
at(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
using sprout::container_detail::range_at;
|
||||
using sprout_adl::range_at;
|
||||
return range_at(cont, i);
|
||||
return sprout::container_range_traits<Container const>::range_at(cont, i);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::reference
|
||||
at(T (& arr)[N], typename sprout::container_traits<T[N]>::size_type i) {
|
||||
return sprout::container_detail::range_at(arr, i);
|
||||
return sprout::container_range_traits<T[N]>::range_at(arr, i);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::reference
|
||||
at(T const (& arr)[N], typename sprout::container_traits<T const[N]>::size_type i) {
|
||||
return sprout::container_detail::range_at(arr, i);
|
||||
return sprout::container_range_traits<T const[N]>::range_at(arr, i);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue