restrict constructor access in variadic template class
Clash Royale CLAN TAG #URR8PPP restrict constructor access in variadic template class I want to create a statically checked builder. Something along these lines: class HasDough; class HasCheese; template <typename ... CurrentTypes> class Pizza { public: friend Pizza<> startPizzaMaking(); Pizza<HasDough, CurrentTypes ...> addDough(){ return Pizza<HasDough, CurrentTypes ...>(); } Pizza<HasCheese, CurrentTypes ...> addCheese(){ return Pizza<HasCheese, CurrentTypes ...>(); } public: // I want to change to private Pizza() = default; }; Pizza<> startPizzaMaking() { return Pizza<>(); } use it like this: int main(){ auto pizza = startPizzaMaking() .addDough() .addCheese(); return 0; } Now I can go along and check the current types with a disjunction. That way I can make sure everything is added. My Problem is: Each step along the way I crea...