我试图弄清楚是否可以使用 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);
};
知道为什么吗?
问候,