why hana's is_valid_t SFINAE test use std::declval<F&&>() not use std::declval<F>()?

Viewed 219

here is hana is_void impl code:

 namespace type_detail {
        template <typename F, typename ...Args, typename = decltype(
            std::declval<F&&>()(std::declval<Args&&>()...)
        )>
        constexpr auto is_valid_impl(int) { return hana::true_c; }

        template <typename F, typename ...Args>
        constexpr auto is_valid_impl(...) { return hana::false_c; }

        template <typename F>
        struct is_valid_fun {
            template <typename ...Args>
            constexpr auto operator()(Args&& ...) const
            { return is_valid_impl<F, Args&&...>(int{}); }
        };
    }

    //! @cond
    template <typename F>
    constexpr auto is_valid_t::operator()(F&&) const
    { return type_detail::is_valid_fun<F&&>{}; }

since is_void_t accept F&&,type_detail::is_valid_fun<F&&> then is_valid_fun's template arg is F&&,then is_valid_impl's template arg is F&&

...so why use std::declval<F&&>()(std::declval<Args&&>()...) not just use std::declval<F>()(std::declval<Args>()...)?

0 Answers
Related