template <auto S2next>
struct SM1 {
static void state1() {
return state2();
}
static void state2() {
return S2next();
}
};
template <auto S2next>
struct SM2 {
static void state1() {
return state2();
}
static void state2() {
return S2next();
}
};
SM1<SM2::state1> sm12; // error: SM2 requires template argument
SM1<SM2<SM1::state1>> sm12; // error: SM1 requires template argument
Since both templates depend on each other, that's obviously not gonna work as is. I could write a combined SM1and2 class having all functions, but that doesn't let me compose the classes arbitrarily (I'll have SM3, and 4 and so on).
What design do I need in order for that to work?
One way to get something equivalent would be to manually combine SM1 and SM2 into another class:
struct Combined {
struct SM1 {
static void entry() { return A(); }
static void A() { return SM2::entry(); }
};
struct SM2 {
static void entry() { return B(); }
static void B() { return SM1::entry(); }
};
};
However, I would like to be able to compose Combined: template <class firstSM, class secondSM> class Combined; using MyCombined = Combined<SM1, SM2>;



(I mean my actual program not the file I sent here)