mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-02-09 09:53:57 +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);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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_back(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_back(Container& cont) {
|
||||
return sprout::container_range_traits<Container>::range_back(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_back(Container const& cont) {
|
||||
return sprout::container_range_traits<Container>::range_back(cont);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// back
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_back(cont) -> range_back(cont)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_back(cont)
|
||||
// sprout::container_range_traits<Container>::range_back(cont)
|
||||
// [default]
|
||||
// callable cont.back() -> cont.back()
|
||||
// otherwise -> *prev(end(cont))
|
||||
// ADL callable range_back(cont) -> range_back(cont)
|
||||
// [default]
|
||||
// Container is T[N] -> cont[N - 1]
|
||||
// callable cont.back() -> cont.back()
|
||||
// otherwise -> *sprout::next(sprout::begin(cont), sprout::size(cont) - 1)
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
back(Container& cont) {
|
||||
using sprout::container_detail::range_back;
|
||||
using sprout_adl::range_back;
|
||||
return range_back(cont);
|
||||
return sprout::container_range_traits<Container>::range_back(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
back(Container const& cont) {
|
||||
using sprout::container_detail::range_back;
|
||||
using sprout_adl::range_back;
|
||||
return range_back(cont);
|
||||
return sprout::container_range_traits<Container const>::range_back(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::reference
|
||||
back(T (& arr)[N]) {
|
||||
return sprout::container_detail::range_back(arr);
|
||||
return sprout::container_range_traits<T[N]>::range_back(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::reference
|
||||
back(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_back(arr);
|
||||
return sprout::container_range_traits<T const[N]>::range_back(arr);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -12,58 +12,38 @@
|
|||
#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_begin(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_begin(Container& cont) {
|
||||
return sprout::container_range_traits<Container>::range_begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_begin(Container const& cont) {
|
||||
return sprout::container_range_traits<Container>::range_begin(cont);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// begin
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_begin(cont) -> range_begin(cont)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_begin(cont)
|
||||
// sprout::container_range_traits<Container>::range_begin(cont)
|
||||
// [default]
|
||||
// cont.begin()
|
||||
// ADL callable range_begin(cont) -> range_begin(cont)
|
||||
// [default]
|
||||
// Container is T[N] -> iterator(cont)
|
||||
// otherwise -> cont.begin()
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
begin(Container& cont) {
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
return sprout::container_range_traits<Container>::range_begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
begin(Container const& cont) {
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
return sprout::container_range_traits<Container const>::range_begin(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||
begin(T (& arr)[N]) {
|
||||
return sprout::container_detail::range_begin(arr);
|
||||
return sprout::container_range_traits<T[N]>::range_begin(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
begin(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_begin(arr);
|
||||
return sprout::container_range_traits<T const[N]>::range_begin(arr);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -17,15 +17,23 @@
|
|||
#include <sprout/container/traits_fwd.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/range_functions_fwd.hpp>
|
||||
#include <sprout/container/begin.hpp>
|
||||
#include <sprout/container/end.hpp>
|
||||
#include <sprout/container/size.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::not_found_via_adl range_begin(...);
|
||||
sprout::not_found_via_adl range_end(...);
|
||||
sprout::not_found_via_adl range_size(...);
|
||||
sprout::not_found_via_adl range_empty(...);
|
||||
sprout::not_found_via_adl range_front(...);
|
||||
sprout::not_found_via_adl range_back(...);
|
||||
sprout::not_found_via_adl range_at(...);
|
||||
sprout::not_found_via_adl range_nth(...);
|
||||
sprout::not_found_via_adl range_index_of(...);
|
||||
sprout::not_found_via_adl range_data(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// container_range_traits
|
||||
//
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
struct has_mem_size_test {
|
||||
|
@ -49,30 +57,22 @@ namespace sprout {
|
|||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_size_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_size_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_size<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
range_size(Container const& cont) {
|
||||
return cont.size();
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_size<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::size_type
|
||||
>::type
|
||||
range_size_impl(Container const& cont) {
|
||||
return cont.size();
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_size_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_size<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
range_size(Container const& cont) {
|
||||
return sprout::distance(sprout::begin(cont), sprout::end(cont));
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_size<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::size_type
|
||||
>::type
|
||||
range_size_impl(Container const& cont) {
|
||||
return sprout::distance(sprout::begin(cont), sprout::end(cont));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_empty_test {
|
||||
|
@ -96,30 +96,22 @@ namespace sprout {
|
|||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_empty_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_empty_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_empty<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR bool
|
||||
range_empty(Container const& cont) {
|
||||
return cont.empty();
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_empty<Container const>::value,
|
||||
bool
|
||||
>::type
|
||||
range_empty_impl(Container const& cont) {
|
||||
return cont.empty();
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_empty_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_empty<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR bool
|
||||
range_empty(Container const& cont) {
|
||||
return sprout::size(cont) == 0;
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_empty<Container const>::value,
|
||||
bool
|
||||
>::type
|
||||
range_empty_impl(Container const& cont) {
|
||||
return sprout::size(cont) == 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_front_test {
|
||||
|
@ -143,55 +135,38 @@ namespace sprout {
|
|||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_front_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_front_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_front<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_front(Container& cont) {
|
||||
return cont.front();
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_front<Container>::value,
|
||||
typename sprout::container_traits<Container>::reference
|
||||
>::type
|
||||
range_front_impl(Container& cont) {
|
||||
return cont.front();
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_front_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_front<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_front(Container& cont) {
|
||||
return *sprout::begin(cont);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_front_const_impl;
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_front<Container>::value,
|
||||
typename sprout::container_traits<Container>::reference
|
||||
>::type
|
||||
range_front_impl(Container& cont) {
|
||||
return *sprout::begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_front_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_front<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_front(Container const& cont) {
|
||||
return cont.front();
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_front<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::reference
|
||||
>::type
|
||||
range_front_impl(Container const& cont) {
|
||||
return cont.front();
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_front_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_front<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_front(Container const& cont) {
|
||||
return *sprout::begin(cont);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_front<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::reference
|
||||
>::type
|
||||
range_front_impl(Container const& cont) {
|
||||
return *sprout::begin(cont);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_back_test {
|
||||
|
@ -215,55 +190,38 @@ namespace sprout {
|
|||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_back_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_back_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_back<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_back(Container& cont) {
|
||||
return cont.back();
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_back<Container>::value,
|
||||
typename sprout::container_traits<Container>::reference
|
||||
>::type
|
||||
range_back_impl(Container& cont) {
|
||||
return cont.back();
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_back_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_back<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_back(Container& cont) {
|
||||
return *sprout::prev(sprout::end(cont));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_back_const_impl;
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_back<Container>::value,
|
||||
typename sprout::container_traits<Container>::reference
|
||||
>::type
|
||||
range_back_impl(Container& cont) {
|
||||
return *sprout::begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_back_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_back<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_back(Container const& cont) {
|
||||
return cont.back();
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_back<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::reference
|
||||
>::type
|
||||
range_back_impl(Container const& cont) {
|
||||
return cont.back();
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_back_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_back<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_back(Container const& cont) {
|
||||
return *sprout::prev(sprout::end(cont));
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_back<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::reference
|
||||
>::type
|
||||
range_back_impl(Container const& cont) {
|
||||
return *sprout::next(sprout::begin(cont), sprout::size(cont) - 1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_at_test {
|
||||
|
@ -287,55 +245,38 @@ namespace sprout {
|
|||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_at_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_at_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_at<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_at(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return cont.at(i);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_at<Container>::value,
|
||||
typename sprout::container_traits<Container>::reference
|
||||
>::type
|
||||
range_at_impl(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return cont.at(i);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_at_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_at<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_at(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return *sprout::next(sprout::begin(cont), i);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_at_const_impl;
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_at<Container>::value,
|
||||
typename sprout::container_traits<Container>::reference
|
||||
>::type
|
||||
range_at_impl(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return *sprout::next(sprout::begin(cont), i);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_at_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_at<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_at(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return cont.at(i);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_at<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::reference
|
||||
>::type
|
||||
range_at_impl(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return cont.at(i);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_at_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_at<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static 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::next(sprout::begin(cont), i);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_at<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::reference
|
||||
>::type
|
||||
range_at_impl(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return *sprout::next(sprout::begin(cont), i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_nth_test {
|
||||
|
@ -359,55 +300,38 @@ namespace sprout {
|
|||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_nth_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_nth_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_nth<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_nth(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return cont.nth(i);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_nth<Container>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_nth_impl(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return cont.nth(i);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_nth_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_nth<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_nth(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return sprout::next(sprout::begin(cont), i);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_nth_const_impl;
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_nth<Container>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_nth_impl(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return sprout::next(sprout::begin(cont), i);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_nth_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_nth<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_nth(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return cont.nth(i);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_nth<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_nth_impl(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return cont.nth(i);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_nth_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_nth<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_nth(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return sprout::next(sprout::begin(cont), i);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_nth<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_nth_impl(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return sprout::next(sprout::begin(cont), i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_index_of_test {
|
||||
|
@ -431,110 +355,262 @@ namespace sprout {
|
|||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_index_of_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_index_of_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_index_of<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
range_index_of(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
return cont.index_of(p);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_index_of<Container>::value,
|
||||
typename sprout::container_traits<Container>::size_type
|
||||
>::type
|
||||
range_index_of_impl(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
return cont.index_of(p);
|
||||
}
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_index_of_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_index_of<Container>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
range_index_of(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
return sprout::distance(sprout::begin(cont), p);
|
||||
}
|
||||
};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_index_of<Container>::value,
|
||||
typename sprout::container_traits<Container>::size_type
|
||||
>::type
|
||||
range_index_of_impl(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
return sprout::distance(begin(cont), p);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_mem_index_of<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::size_type
|
||||
>::type
|
||||
range_index_of_impl(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
return cont.index_of(p);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_mem_index_of<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::size_type
|
||||
>::type
|
||||
range_index_of_impl(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
return sprout::distance(begin(cont), p);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace sprout
|
||||
|
||||
template<typename Container, typename = void>
|
||||
struct container_range_traits_range_index_of_const_impl;
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_index_of_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<sprout::detail::has_mem_index_of<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_index_of(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
return cont.index_of(p);
|
||||
}
|
||||
};
|
||||
template<typename Container>
|
||||
struct container_range_traits_range_index_of_const_impl<
|
||||
Container,
|
||||
typename std::enable_if<!sprout::detail::has_mem_index_of<Container const>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_index_of(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
return sprout::distance(sprout::begin(cont), p);
|
||||
}
|
||||
};
|
||||
namespace sprout_container_range_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_begin(Container& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_begin(Container const& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_end(Container& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_end(Container const& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_size(Container const& cont) {
|
||||
return sprout::detail::range_size_impl(cont);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
range_empty(Container const& cont) {
|
||||
return sprout::detail::range_empty_impl(cont);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_front(Container& cont) {
|
||||
return sprout::detail::range_front_impl(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_front(Container const& cont) {
|
||||
return sprout::detail::range_front_impl(cont);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_back(Container& cont) {
|
||||
return sprout::detail::range_back_impl(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_back(Container const& cont) {
|
||||
return sprout::detail::range_back_impl(cont);
|
||||
}
|
||||
|
||||
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::detail::range_at_impl(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::detail::range_at_impl(cont, i);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_nth(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return sprout::detail::range_nth_impl(cont, i);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_nth(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return sprout::detail::range_nth_impl(cont, i);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
range_index_of(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
return sprout::detail::range_index_of_impl(cont, p);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_index_of(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
return sprout::detail::range_index_of_impl(cont, p);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::pointer
|
||||
range_data(Container& cont) {
|
||||
return cont.data();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::pointer
|
||||
range_data(Container const& cont) {
|
||||
return cont.data();
|
||||
}
|
||||
} // namespace sprout_container_range_detail
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
//
|
||||
// container_range_traits_default
|
||||
//
|
||||
template<typename Container>
|
||||
struct container_range_traits_default
|
||||
: public sprout::detail::container_range_traits_range_size_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_empty_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_front_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_front_const_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_back_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_back_const_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_at_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_at_const_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_nth_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_nth_const_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_index_of_impl<Container>
|
||||
, public sprout::detail::container_range_traits_range_index_of_const_impl<Container>
|
||||
{
|
||||
using sprout::detail::container_range_traits_range_front_impl<Container>::range_front;
|
||||
using sprout::detail::container_range_traits_range_front_const_impl<Container>::range_front;
|
||||
using sprout::detail::container_range_traits_range_back_impl<Container>::range_back;
|
||||
using sprout::detail::container_range_traits_range_back_const_impl<Container>::range_back;
|
||||
using sprout::detail::container_range_traits_range_at_impl<Container>::range_at;
|
||||
using sprout::detail::container_range_traits_range_at_const_impl<Container>::range_at;
|
||||
using sprout::detail::container_range_traits_range_nth_impl<Container>::range_nth;
|
||||
using sprout::detail::container_range_traits_range_nth_const_impl<Container>::range_nth;
|
||||
using sprout::detail::container_range_traits_range_index_of_impl<Container>::range_index_of;
|
||||
using sprout::detail::container_range_traits_range_index_of_const_impl<Container>::range_index_of;
|
||||
struct container_range_traits_default {
|
||||
public:
|
||||
// iterators:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_begin(Container& cont) {
|
||||
return cont.begin();
|
||||
using sprout_container_range_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_begin(Container const& cont) {
|
||||
return cont.begin();
|
||||
using sprout_container_range_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_end(Container& cont) {
|
||||
return cont.end();
|
||||
using sprout_container_range_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_end(Container const& cont) {
|
||||
return cont.end();
|
||||
using sprout_container_range_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
// capacity:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_size(Container const& cont) {
|
||||
using sprout_container_range_detail::range_size;
|
||||
using sprout_adl::range_size;
|
||||
return range_size(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_empty(Container const& cont) {
|
||||
using sprout_container_range_detail::range_empty;
|
||||
using sprout_adl::range_empty;
|
||||
return range_empty(cont);
|
||||
}
|
||||
// element access:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_front(Container& cont) {
|
||||
using sprout_container_range_detail::range_front;
|
||||
using sprout_adl::range_front;
|
||||
return range_front(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_front(Container const& cont) {
|
||||
using sprout_container_range_detail::range_front;
|
||||
using sprout_adl::range_front;
|
||||
return range_front(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_back(Container& cont) {
|
||||
using sprout_container_range_detail::range_back;
|
||||
using sprout_adl::range_back;
|
||||
return range_back(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_back(Container const& cont) {
|
||||
using sprout_container_range_detail::range_back;
|
||||
using sprout_adl::range_back;
|
||||
return range_back(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_at(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
using sprout_container_range_detail::range_at;
|
||||
using sprout_adl::range_at;
|
||||
return range_at(cont, i);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_at(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
using sprout_container_range_detail::range_at;
|
||||
using sprout_adl::range_at;
|
||||
return range_at(cont, i);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_nth(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
using sprout_container_range_detail::range_nth;
|
||||
using sprout_adl::range_nth;
|
||||
return range_nth(cont, i);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_nth(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
using sprout_container_range_detail::range_nth;
|
||||
using sprout_adl::range_nth;
|
||||
return range_nth(cont, i);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
range_index_of(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
using sprout_container_range_detail::range_index_of;
|
||||
using sprout_adl::range_index_of;
|
||||
return range_index_of(cont, p);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_index_of(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
using sprout_container_range_detail::range_index_of;
|
||||
using sprout_adl::range_index_of;
|
||||
return range_index_of(cont, p);
|
||||
}
|
||||
// data access:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::pointer
|
||||
range_data(Container& cont) {
|
||||
return cont.data();
|
||||
using sprout_container_range_detail::range_data;
|
||||
using sprout_adl::range_data;
|
||||
return range_data(cont);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::pointer
|
||||
range_data(Container const& cont) {
|
||||
return cont.data();
|
||||
using sprout_container_range_detail::range_data;
|
||||
using sprout_adl::range_data;
|
||||
return range_data(cont);
|
||||
}
|
||||
};
|
||||
//
|
||||
|
@ -742,4 +818,8 @@ namespace sprout {
|
|||
};
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/container/begin.hpp>
|
||||
#include <sprout/container/end.hpp>
|
||||
#include <sprout/container/size.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
||||
|
|
|
@ -12,58 +12,38 @@
|
|||
#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_data(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::pointer
|
||||
range_data(Container& cont) {
|
||||
return sprout::container_range_traits<Container>::range_data(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::pointer
|
||||
range_data(Container const& cont) {
|
||||
return sprout::container_range_traits<Container>::range_data(cont);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// data
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_data(cont) -> range_data(cont)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_data(cont)
|
||||
// sprout::container_range_traits<Container>::range_data(cont)
|
||||
// [default]
|
||||
// cont.data()
|
||||
// ADL callable range_data(cont) -> range_data(cont)
|
||||
// [default]
|
||||
// Container is T[N] -> pointer(cont)
|
||||
// cont.data()
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::pointer
|
||||
data(Container& cont) {
|
||||
using sprout::container_detail::range_data;
|
||||
using sprout_adl::range_data;
|
||||
return range_data(cont);
|
||||
return sprout::container_range_traits<Container>::range_data(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::pointer
|
||||
data(Container const& cont) {
|
||||
using sprout::container_detail::range_data;
|
||||
using sprout_adl::range_data;
|
||||
return range_data(cont);
|
||||
return sprout::container_range_traits<Container>::range_data(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::pointer
|
||||
data(T (& arr)[N]) {
|
||||
return sprout::container_detail::range_data(arr);
|
||||
return sprout::container_range_traits<T[N]>::range_data(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::pointer
|
||||
data(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_data(arr);
|
||||
return sprout::container_range_traits<T const[N]>::range_data(arr);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -12,58 +12,38 @@
|
|||
#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_end(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_end(Container& cont) {
|
||||
return sprout::container_range_traits<Container>::range_end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_end(Container const& cont) {
|
||||
return sprout::container_range_traits<Container>::range_end(cont);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// end
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_end(cont) -> range_end(cont)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_end(cont)
|
||||
// sprout::container_range_traits<Container>::range_end(cont)
|
||||
// [default]
|
||||
// cont.end()
|
||||
// ADL callable range_end(cont) -> range_end(cont)
|
||||
// [default]
|
||||
// Container is T[N] -> iterator(cont) + N
|
||||
// otherwise -> cont.end()
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
end(Container& cont) {
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
return sprout::container_range_traits<Container>::range_end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
end(Container const& cont) {
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
return sprout::container_range_traits<Container const>::range_end(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||
end(T (& arr)[N]) {
|
||||
return sprout::container_detail::range_end(arr);
|
||||
return sprout::container_range_traits<T[N]>::range_end(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
end(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_end(arr);
|
||||
return sprout::container_range_traits<T const[N]>::range_end(arr);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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_front(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
range_front(Container& cont) {
|
||||
return sprout::container_range_traits<Container>::range_front(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
range_front(Container const& cont) {
|
||||
return sprout::container_range_traits<Container>::range_front(cont);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// front
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_front(cont) -> range_front(cont)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_front(cont)
|
||||
// sprout::container_range_traits<Container>::range_front(cont)
|
||||
// [default]
|
||||
// callable cont.front() -> cont.front()
|
||||
// otherwise -> *begin(cont)
|
||||
// ADL callable range_front(cont) -> range_front(cont)
|
||||
// [default]
|
||||
// Container is T[N] -> cont[0]
|
||||
// callable cont.front() -> cont.front()
|
||||
// otherwise -> *sprout::begin(cont)
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::reference
|
||||
front(Container& cont) {
|
||||
using sprout::container_detail::range_front;
|
||||
using sprout_adl::range_front;
|
||||
return range_front(cont);
|
||||
return sprout::container_range_traits<Container>::range_front(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::reference
|
||||
front(Container const& cont) {
|
||||
using sprout::container_detail::range_front;
|
||||
using sprout_adl::range_front;
|
||||
return range_front(cont);
|
||||
return sprout::container_range_traits<Container const>::range_front(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::reference
|
||||
front(T (& arr)[N]) {
|
||||
return sprout::container_detail::range_front(arr);
|
||||
return sprout::container_range_traits<T[N]>::range_front(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::reference
|
||||
front(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_front(arr);
|
||||
return sprout::container_range_traits<T const[N]>::range_front(arr);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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_index_of(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
range_index_of(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
return sprout::container_range_traits<Container>::range_index_of(cont, p);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
range_index_of(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
return sprout::container_range_traits<Container>::range_index_of(cont, p);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// index_of
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_index_of(cont, p) -> range_index_of(cont, p)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_index_of(cont, p)
|
||||
// sprout::container_range_traits<Container>::range_index_of(cont, p)
|
||||
// [default]
|
||||
// callable cont.index_of(p) -> cont.index_of(p)
|
||||
// otherwise -> *next(begin(cont), p)
|
||||
// ADL callable range_index_of(cont, p) -> range_index_of(cont, p)
|
||||
// [default]
|
||||
// Container is T[N] -> p - iterator(cont)
|
||||
// callable cont.index_of(p) -> cont.index_of(p)
|
||||
// otherwise -> sprout::distance(begin(cont), p)
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||
index_of(Container& cont, typename sprout::container_traits<Container>::iterator p) {
|
||||
using sprout::container_detail::range_index_of;
|
||||
using sprout_adl::range_index_of;
|
||||
return range_index_of(cont, p);
|
||||
return sprout::container_range_traits<Container>::range_index_of(cont, p);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||
index_of(Container const& cont, typename sprout::container_traits<Container const>::iterator p) {
|
||||
using sprout::container_detail::range_index_of;
|
||||
using sprout_adl::range_index_of;
|
||||
return range_index_of(cont, p);
|
||||
return sprout::container_range_traits<Container const>::range_index_of(cont, p);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::size_type
|
||||
index_of(T (& arr)[N], typename sprout::container_traits<T[N]>::iterator p) {
|
||||
return sprout::container_detail::range_index_of(arr, p);
|
||||
return sprout::container_range_traits<T[N]>::range_index_of(arr, p);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::size_type
|
||||
index_of(T const (& arr)[N], typename sprout::container_traits<T const[N]>::iterator p) {
|
||||
return sprout::container_detail::range_index_of(arr, p);
|
||||
return sprout::container_range_traits<T const[N]>::range_index_of(arr, p);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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_nth(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_nth(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
return sprout::container_range_traits<Container>::range_nth(cont, i);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_nth(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
return sprout::container_range_traits<Container>::range_nth(cont, i);
|
||||
}
|
||||
} // namespace container_detail
|
||||
|
||||
//
|
||||
// nth
|
||||
//
|
||||
// effect:
|
||||
// ADL callable range_nth(cont, i) -> range_nth(cont, i)
|
||||
// otherwise -> sprout::container_range_traits<Container>::range_nth(cont, i)
|
||||
// sprout::container_range_traits<Container>::range_nth(cont, i)
|
||||
// [default]
|
||||
// callable cont.nth(i) -> cont.nth(i)
|
||||
// otherwise -> *next(begin(cont), i)
|
||||
// ADL callable range_nth(cont, i) -> range_nth(cont, i)
|
||||
// [default]
|
||||
// Container is T[N] -> iterator(cont) + i
|
||||
// callable cont.nth(i) -> cont.nth(i)
|
||||
// otherwise -> sprout::next(sprout::begin(cont), i)
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
nth(Container& cont, typename sprout::container_traits<Container>::size_type i) {
|
||||
using sprout::container_detail::range_nth;
|
||||
using sprout_adl::range_nth;
|
||||
return range_nth(cont, i);
|
||||
return sprout::container_range_traits<Container>::range_nth(cont, i);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
nth(Container const& cont, typename sprout::container_traits<Container const>::size_type i) {
|
||||
using sprout::container_detail::range_nth;
|
||||
using sprout_adl::range_nth;
|
||||
return range_nth(cont, i);
|
||||
return sprout::container_range_traits<Container const>::range_nth(cont, i);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||
nth(T (& arr)[N], typename sprout::container_traits<T[N]>::size_type i) {
|
||||
return sprout::container_detail::range_nth(arr, i);
|
||||
return sprout::container_range_traits<T[N]>::range_nth(arr, i);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
nth(T const (& arr)[N], typename sprout::container_traits<T const[N]>::size_type i) {
|
||||
return sprout::container_detail::range_nth(arr, i);
|
||||
return sprout::container_range_traits<T const[N]>::range_nth(arr, i);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue