fe2*_*263 6 c++ c++11 c++14 c++17
这是hana is_void impl代码:
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&&>{}; }
Run Code Online (Sandbox Code Playgroud)
因为is_void_t接受F &&,type_detail::is_valid_fun<F&&>然后is_valid_fun的模板arg是F &&,那么is_valid_impl的模板arg是F &&
...所以为什么std::declval<F&&>()(std::declval<Args&&>()...)不使用std::declval<F>()(std::declval<Args>()...)?
| 归档时间: |
|
| 查看次数: |
190 次 |
| 最近记录: |