I have a class that I want to have accept 0-5 arguments in any order for it's constructor. Each argument is a const references to one of 5 possible class types. All arguments must be distinct in type, passing the same type twice in an error. Passing an argument that is not one of the 5 supported types is also an error.
How do you go about implementing something like this?
I figure first you have to create a constructor for each arity but then how do you constrain the constructors as described above? I imagine it would involve enable_if.
class widget
{
widget();
template< class A >
widget( const A& a );
template< class A, class B >
widget( const A& a, const B& b );
template< class A, class B, class C >
widget( const A& a, const B& b, const C& c );
template< class A, class B, class C, class D >
widget( const A& a, const B& b, const C& c, const D& d );
template< class A, class B, class C, class D, class E >
widget( const A& a, const B& b, const C& c, const D& d, const E& e );
};