下面的示例在我尝试过的所有编译器中都失败了:gcc-8.2、clang-8.0(两个选项都已尝试)--std=c++17
和std=c++2a
zapcc-2017.08。
从我的角度来看,代码示例是有效的,应该被编译。或者,至少,应该有一个更全面的错误。它看起来确实像 std 库中的一个错误,没有涵盖result_of
. 我错了吗?
#include <type_traits>
using namespace std;
struct bar {
int a;
long b;
};
template<auto M>
struct foo {
static auto q(bar & b) {
return b.*M;
}
};
template<auto M>
auto qoo(bar & b) {
return b.*M;
}
// error: 'type' in 'class std::result_of<int(bar&)>' does not name a type
using f = typename result_of<decltype(foo<&bar::a>::q)>::type;
// error: 'type' in 'class std::result_of<int(bar&)>' does not name a type
using q= typename result_of<decltype(qoo<&bar::a>)>::type;