编辑:我正在使用tdm-gcc-4.7.1-2 for Windows如何从模板化的基础中消除多个继承的typedefs?
不知道如何解决这个问题。我想用它作为一种类型列表,让我知道我正在尝试使用B
的类型定义中不存在的类型。
template <typename T, typename U>
struct A {
typedef pair<T, U> type;
};
struct B : A<int, string>, A<int, float> {};
B::type foo; // won't compile, ambiguous reference, as expected
B::A<int, int>::type bar; // compiles fine?? :(
有没有办法得到它失败的A<int, int>
(以及任何其他A
“不B
继承S),或另一种方式来进行此事?我想我可以使用一个tuple
并缓解我的方式,对每个元素进行is_same
比较,无论我是否提供元函数,但这似乎更容易...首先:\
我怀疑'B ::一个 :: type'应该编译在所有...'B :: A'已经是模糊的,不参照模板,但从中'B'导出实例... –
2013-02-08 22:49:34
@DavidRodríguez-dribeas我同意的一个,我不明白为什么它编译。我可能错过了埋在标准中的规则。 – 2013-02-08 22:57:53
我相信C++ 11草案中的章节是14.6.1-4。明确地允许这种情况 – jmetcalfe 2013-02-08 23:04:15