I have some code which seems unambiguous to me, but gcc4.7 is choking on it:
#include <iostream>
#include <tuple>
using namespace std;
// Container for mixins
template<template<typename> class... Mixins>
struct Mix : Mixins<Mix<Mixins...>>... {
typedef tuple<Mixins<Mix<Mixins...>>...> types;
};
// Outer layer extracts the type tuple from the argument
template<typename T>
struct InnerCombiner {
typedef typename InnerCombiner<typename T::types>::type type;
};
// Typedef type to be a new mix of the inner mixins of the MixedMixins
template<typename... MixedMixins>
struct InnerCombiner<tuple<MixedMixins...>> {
// This line is the problem. The compiler doesn't seem to be able to make sense
// of the reference to the inner mixin template template classes
typedef Mix<MixedMixins::InnerMixin...> type;
};
template<typename Mixed>
struct A {
template<typename MixedInner>
struct InnerMixin {
void foo() { cout << "foo() loves you!" << endl; };
};
};
template<typename Mixed>
struct B {
template<typename MixedInner>
struct InnerMixin {
void bar() { cout << "bar() loves you!" << endl; };
};
};
// I'm going to write out the type I expect ic to have. Oh god, it's so nasty:
// Mix<
// A<Mix<A,B>>::InnerMixin<Mix<A<Mix<A,B>>::InnerMixin,B<Mix<A,B>>::InnerMixin>,
// B<Mix<A,B>>::InnerMixin<Mix<A<Mix<A,B>>::InnerMixin,B<Mix<A,B>>::InnerMixin>
// >
int main() {
InnerCombiner<Mix<A,B>>::type ic;
ic.bar(); // Not working.
}
Is there something wrong with accessing InnerMixins this way? It seemed pretty reasonable when I wrote it :)