Given some classes with parameterized constructors, such as:
class A
{
public:
A(bool b, int i) { /*...*/ }
private:
A(const A&) {}
};
class B
{
public:
B(char c, double d) { /* ... */ }
private:
B(const B&) {}
};
How to properly initialize a tuple of such classes?
boost::tuple<A,B> tup( /* ??? */ );
Not using copy constructor of A or B, and, if possible, not using move-constructor either. C++03 solution preferred, if possible.
Can you just add a piecewise constructor for your types? If so, you can create a horrible macro that unpacks and delegates a tuple:
And just add it to your types:
And pass in tuples:
Pre-C++11, I don't know that this is possible - you don't have delegating constructors at all. You'd have to either:
tuple-like class that accepts tuples in its constructorboost::tuple<boost::scoped_ptr<A>, boost::scoped_ptr<B>>(new A(...), new B(...))(1) is a lot of work, (2) is code duplication and error prone, and (3) involves now having to do allocation all of a sudden.