Sorry if this has been answered already, but I've been looking for hours and can't find anyone who's tried something quite like this. I'm trying to do something like the following, but I have no earthly idea what the syntax should be for Entity_Aspectual.
template<class Context>
class Trait1_Barsome
{
};
template<class Context>
class Trait1_Foobish
{
};
template<class Context>
class Trait2_Barsome
{
};
template<class Context>
class Trait2_Foobish
{
};
class Aspect_Foobish
{
public:
template<class Context>
using Trait1Policy = Trait1_Foobish<Context>;
template<class Context>
using Trait2Policy = Trait2_Foobish<Context>;
};
class Aspect_Barsome
{
public:
template<class Context>
using Trait1Policy = Trait1_Barsome<Context>;
template<class Context>
using Trait2Policy = Trait2_Barsome<Context>;
};
template<class Context,
template<class> class Trait1,
template<class> class Trait2>
class Entity:
public Trait1<Context>,
public Trait2<Context>
{
};
class ActualContext {};
template<class Context,
class Aspect>
using Entity_Aspectual = Entity<Context,
typename Aspect::Trait1Policy,
typename Aspect::Trait2Policy>;
int main()
{
Entity_Aspectual<ActualContext, Aspect_Foobish> foobishEntity;
Entity_Aspectual<ActualContext, Aspect_Barsome> barsomeEntity;
return 0;
}
It seems trivial in this case, but in my application the type of specialization you'd see in Entity is far more complex and would make Entity_Aspectual extremely verbose if I tried a solution like the following:
template<class Trait1,
class Trait2>
class Entity:
public Trait1,
public Trait2
{
};
template<class Context,
class Aspect>
using Entity_Aspectual = Entity<typename Aspect::template Trait1Policy<Context>,
typename Aspect::template Trait2Policy<Context>>;