我正在尝试检查operator []
在某些类中是否过载。有我的代码:
template <class T, class = void>
struct has_operator : std::false_type {};
template <class T>
struct has_operator < T,
std::void_t<decltype(std::declval<T>[](int i))>> :
std::true_type {};
但是实际上不起作用。
如果班级为operator ()
,我将尝试编写类似代码的巫婆che声>
这里是:
template <typename T,class=void>
struct callable_without_args: std::false_type{};
template <typename T>
struct callable_without_args<T
,std::void_t<decltype(std::declval<T>()())>>
:std::true_type{};
[我正在尝试检查运算符[]在某些类中是否过载。有我的代码:template
没有完全清楚您到底想要什么,但是...以下decltype()
是错误的
// ........................VVVVVVVVVVVVVVVVV U value
decltype(std::declval<T>()[std::declval<U>()])