From d7d3929226df1c8f8174ac63d11b6fad47997840 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 10 Jan 2018 00:02:22 +0100 Subject: [PATCH] refactor expression SFINAE tests not to use pointers --- ostd/format.hh | 13 ++++++++----- ostd/range.hh | 30 ++++++++++++++++-------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/ostd/format.hh b/ostd/format.hh index 77b7db8..2de816f 100644 --- a/ostd/format.hh +++ b/ostd/format.hh @@ -217,7 +217,8 @@ namespace detail { * pair, array, possibly other types added later or overridden... */ template - inline std::true_type tuple_like_test(typename std::tuple_size::type *); + inline auto tuple_like_test(int) -> + typename std::is_integral::value)>::type; template inline std::false_type tuple_like_test(...); @@ -228,10 +229,12 @@ namespace detail { /* test if format traits are available for the type */ template - inline std::true_type test_tofmt(decltype(format_traits::to_format( - std::declval(), std::declval(), - std::declval() - )) *); + inline auto test_tofmt(int) -> typename std::is_void< + decltype(format_traits::to_format( + std::declval(), std::declval(), + std::declval() + )) + >::type; template inline std::false_type test_tofmt(...); diff --git a/ostd/range.hh b/ostd/range.hh index dedffde..e9a4ea4 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -592,9 +592,9 @@ static inline constexpr bool const is_contiguous_range = namespace detail { template - inline std::true_type test_outrange(typename std::is_same< - decltype(std::declval().put(std::declval())), void - >::type *); + inline auto test_outrange(int) -> typename std::is_void< + decltype(std::declval().put(std::declval())) + >::tyoe; template inline std::false_type test_outrange(...); @@ -1208,9 +1208,9 @@ inline auto zip(R1 &&r1, R &&...rr) { namespace detail { template - inline std::true_type test_direct_iter( - decltype(std::declval().iter()) * - ); + inline auto test_direct_iter(int) -> std::integral_constant< + bool, is_input_range().iter())> + >; template inline std::false_type test_direct_iter(...); @@ -1219,18 +1219,20 @@ namespace detail { static inline constexpr bool const direct_iter_test = decltype(test_direct_iter(0))::value; + template - inline std::true_type test_std_iter( - decltype(std::begin(std::declval())) *, - decltype(std::end(std::declval())) * - ); + inline auto test_std_iter(int) -> std::integral_constant< + bool, + !std::is_void_v()))> && + !std::is_void_v()))> + >; template inline std::false_type test_std_iter(...); template static inline constexpr bool const std_iter_test = - decltype(test_std_iter(0, 0))::value; + decltype(test_std_iter(0))::value; /* direct iter and std iter; the case for std iter is * specialized after iterator_range is actually defined @@ -1303,9 +1305,9 @@ inline auto citer(T const &r) -> decltype(ranged_traits::iter(r)) { namespace detail { template - inline std::true_type test_iterable( - decltype(ostd::iter(std::declval())) * - ); + inline auto test_iterable(int) -> std::integral_constant< + bool, is_input_range()))> + >; template inline std::false_type test_iterable(...);