小编kei*_*eis的帖子

暧昧的模板怪异

我有以下代码(抱歉大代码块,但我不能再缩小它)

template <bool B>
struct enable_if_c {
      typedef void type;
};

template <>
struct enable_if_c<false> {};

template <class Cond>
struct enable_if : public enable_if_c<Cond::value> {};

template <typename X>
struct Base { enum { value = 1 }; };

template <typename X, typename Y=Base<X>, typename Z=void>
struct Foo;

template <typename X>
struct Foo<X, Base<X>, void> { enum { value = 0 }; };

template <typename X, typename Y>
struct Foo<X, Y, typename enable_if<Y>::type > { enum { value = 1 }; …
Run Code Online (Sandbox Code Playgroud)

c++ gcc templates specialization

8
推荐指数
1
解决办法
1401
查看次数

标签 统计

c++ ×1

gcc ×1

specialization ×1

templates ×1