小编use*_*426的帖子

为什么我不能推断静态成员函数是否存在

我有以下代码:

#include <utility>

template<class T,class E = void>
struct func_impl;

template<class T,class E = void>
constexpr inline bool has_func = false;

template<class T>
constexpr inline bool has_func<T,decltype(func_impl<T>::apply(std::declval<T>()))> = true;

template<>
struct func_impl<int>
{
   static int apply(int i);
};

static_assert(has_func<int>);
Run Code Online (Sandbox Code Playgroud)

static_assert失败,我预计它会成功.我做错了什么?

c++ templates c++17

4
推荐指数
1
解决办法
147
查看次数

标签 统计

c++ ×1

c++17 ×1

templates ×1