我试图弄清楚是否有可能使用sfinae来测试命名空间成员的存在.谷歌相当沉默.我尝试了以下代码,但它失败了.
namespace xyz{
struct abc{};
}
struct abc{};
struct test_xyz{
typedef char yes;
typedef struct{ char a[2]; } no;
template <class C> static yes test(xyz::C = xyz::C()); //lets assume it has default constructor
template <class C> static no test(...);
const bool has_abc = sizeof(test_xyz::test<abc>()) == sizeof(yes);
};
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?
问候,