forked from OctaForge/libostd
clean up range tests
parent
755429f901
commit
2ce3e6496a
|
@ -82,20 +82,6 @@ using range_reference_t = typename range_traits<R>::reference;
|
||||||
template<typename R>
|
template<typename R>
|
||||||
using range_difference_t = typename range_traits<R>::difference_type;
|
using range_difference_t = typename range_traits<R>::difference_type;
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template<typename U>
|
|
||||||
static char is_range_test_f(
|
|
||||||
typename U::range_category *, typename U::size_type *,
|
|
||||||
typename U::difference_type *, typename U::value_type *,
|
|
||||||
std::remove_reference_t<typename U::reference> *
|
|
||||||
);
|
|
||||||
template<typename U>
|
|
||||||
static int is_range_test_f(...);
|
|
||||||
|
|
||||||
template<typename T> constexpr bool is_range_test =
|
|
||||||
(sizeof(is_range_test_f<T>(0, 0, 0, 0, 0)) == sizeof(char));
|
|
||||||
}
|
|
||||||
|
|
||||||
// is input range
|
// is input range
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -103,7 +89,7 @@ namespace detail {
|
||||||
constexpr bool is_input_range_core =
|
constexpr bool is_input_range_core =
|
||||||
std::is_convertible_v<range_category_t<T>, input_range_tag>;
|
std::is_convertible_v<range_category_t<T>, input_range_tag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::is_range_test<T>>
|
template<typename T, bool = detail::test_range_category<T>>
|
||||||
constexpr bool is_input_range_base = false;
|
constexpr bool is_input_range_base = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -120,7 +106,7 @@ namespace detail {
|
||||||
constexpr bool is_forward_range_core =
|
constexpr bool is_forward_range_core =
|
||||||
std::is_convertible_v<range_category_t<T>, forward_range_tag>;
|
std::is_convertible_v<range_category_t<T>, forward_range_tag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::is_range_test<T>>
|
template<typename T, bool = detail::test_range_category<T>>
|
||||||
constexpr bool is_forward_range_base = false;
|
constexpr bool is_forward_range_base = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -137,7 +123,7 @@ namespace detail {
|
||||||
constexpr bool is_bidirectional_range_core =
|
constexpr bool is_bidirectional_range_core =
|
||||||
std::is_convertible_v<range_category_t<T>, bidirectional_range_tag>;
|
std::is_convertible_v<range_category_t<T>, bidirectional_range_tag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::is_range_test<T>>
|
template<typename T, bool = detail::test_range_category<T>>
|
||||||
constexpr bool is_bidirectional_range_base = false;
|
constexpr bool is_bidirectional_range_base = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -155,7 +141,7 @@ namespace detail {
|
||||||
constexpr bool is_random_access_range_core =
|
constexpr bool is_random_access_range_core =
|
||||||
std::is_convertible_v<range_category_t<T>, random_access_range_tag>;
|
std::is_convertible_v<range_category_t<T>, random_access_range_tag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::is_range_test<T>>
|
template<typename T, bool = detail::test_range_category<T>>
|
||||||
constexpr bool is_random_access_range_base = false;
|
constexpr bool is_random_access_range_base = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -173,7 +159,7 @@ namespace detail {
|
||||||
constexpr bool is_finite_random_access_range_core =
|
constexpr bool is_finite_random_access_range_core =
|
||||||
std::is_convertible_v<range_category_t<T>, finite_random_access_range_tag>;
|
std::is_convertible_v<range_category_t<T>, finite_random_access_range_tag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::is_range_test<T>>
|
template<typename T, bool = detail::test_range_category<T>>
|
||||||
constexpr bool is_finite_random_access_range_base = false;
|
constexpr bool is_finite_random_access_range_base = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -196,7 +182,7 @@ namespace detail {
|
||||||
constexpr bool is_contiguous_range_core =
|
constexpr bool is_contiguous_range_core =
|
||||||
std::is_convertible_v<range_category_t<T>, contiguous_range_tag>;
|
std::is_convertible_v<range_category_t<T>, contiguous_range_tag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::is_range_test<T>>
|
template<typename T, bool = detail::test_range_category<T>>
|
||||||
constexpr bool is_contiguous_range_base = false;
|
constexpr bool is_contiguous_range_base = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -210,28 +196,28 @@ template<typename T> constexpr bool is_contiguous_range =
|
||||||
// is output range
|
// is output range
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, typename P>
|
template<typename R, typename T>
|
||||||
struct output_range_test {
|
static std::true_type test_outrange(typename std::is_same<
|
||||||
template<typename U, bool (U::*)(P)>
|
decltype(std::declval<R &>().put(std::declval<T>())), bool
|
||||||
struct test_t {};
|
>::type *);
|
||||||
template<typename U>
|
|
||||||
static char test(test_t<U, &U::put> *);
|
template<typename, typename>
|
||||||
template<typename U>
|
static std::false_type test_outrange(...);
|
||||||
static int test(...);
|
|
||||||
static constexpr bool value = (sizeof(test<T>(0)) == sizeof(char));
|
template<typename R, typename T>
|
||||||
};
|
constexpr bool output_range_test = decltype(test_outrange<R, T>())::value;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_output_range_core =
|
constexpr bool is_output_range_core =
|
||||||
std::is_convertible_v<range_category_t<T>, output_range_tag> || (
|
std::is_convertible_v<range_category_t<T>, output_range_tag> || (
|
||||||
is_input_range<T> && (
|
is_input_range<T> && (
|
||||||
detail::output_range_test<T, range_value_t<T> const &>::value ||
|
output_range_test<T, range_value_t<T> const &> ||
|
||||||
detail::output_range_test<T, range_value_t<T> &&>::value ||
|
output_range_test<T, range_value_t<T> &&> ||
|
||||||
detail::output_range_test<T, range_value_t<T> >::value
|
output_range_test<T, range_value_t<T> >
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
template<typename T, bool = detail::is_range_test<T>>
|
template<typename T, bool = detail::test_range_category<T>>
|
||||||
constexpr bool is_output_range_base = false;
|
constexpr bool is_output_range_base = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in New Issue