I have been fine-tuning my recursive inheritance to the point that I can simply define the class I want to insert in the inheritance chain simply like this:
template <typename...T>
struct policy_name: T...{
// code here
};
But... that's not a recursive inheritance solution. That's the multiple inheritance solution. There must be some kind of a confusion here.
What I would idealy like is simply use existing structures and type:
inherit_recursively < existing_struct_1, existing_struct_2 /*,etc*/ > my_policies
where existing_struct_1 are plain vanilla structure such as:
struct my_policy{
// code
};
Well, assuming you are aiming for a multiple inheritance version, then, you can use the technique I demonstrated a few posts back. It went like this:
template <typename... P> struct policies;
template <typename P, typename... T>
struct policies<P, T...> : public P,
public policies<T...> { };
template <typename P> struct policies<P> : public P {};
struct policy12 {
// code...
}
// repeat for all desired policies with appropriate code
// and use like this:
policies<policy12, policy24 /*etc...*></policy12> my_chosen_policies;
That gives you exactly that effect, except that it doesn't implement the recursive inheritance scheme.
For a semi-recursive version, this might be the best approximation:
struct NullTerminatingTrait {
template <typename... Tail>
struct bind { };
};
template <typename... Args>
struct AnimalTraits;
template <>
struct AnimalTraits<> { };
template <typename T, typename... Tail>
struct AnimalTraits<T, Tail...> : T::template bind< Tail..., NullTerminatingTrait > { }; …