我想我在gcc中发现了一个错误,但我想确认:
struct Foo {
void good(int);
template <typename T>
void bad(T);
};
以下所有工作都很好:
enable_if_t<is_same_v<decltype(&Foo::good), void (Foo::*)(int)>, void> test1() {}
template <typename T> enable_if_t<is_same_v<decltype(&T::good), void (T::*)(int)>, void> test2() {}
enable_if_t<is_same_v<decltype(&Foo::bad<int>), void (Foo::*)(int)>::value, void> test3() {}
template <typename T> enable_if_t<is_same_v<decltype(&Foo::bad<T>), void (Foo::*)(T)>, void> test4() {}
但这甚至无法定义:
template <typename T>
enable_if_t<is_same_v<decltype(&T::bad<int>), void (T::*)(int)>, void> test5() {}
如果是,我会收到几个错误:
错误:模板参数数量错误(1,应为2)
任何人都可以确认这是一个gcc错误吗?它似乎适用于其他编译器,例如Visual Studio:http://webcompiler.cloudapp.net/,但使用http://melpon.org/wandbox我可以通过gcc 7.0确认这种情况持续存在。