sfinae を使用して名前空間メンバーの存在をテストできるかどうかを調べようとしていました。Googleはそれについてかなり沈黙しています。次のコードを試しましたが、失敗します。
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);
};
理由はありますか?
よろしく、