Consider class A with the only custom constructor:
class A
{
public:
A(float) {}
private:
A() = delete;
A(const A&) = delete;
A(A&&) = delete;
};
And another class B, which contains a tuple of A (let it be the only tuple member for simplicity):
class B
{
public:
B() : ta(0.0f) {} // ta initialization OK
private:
std::tuple<A> ta;
};
Now we can declare an object of B and it works fine:
B b;
But how to do the same if the constructor of A
has more than one argument?
class A
{
public:
A(float, int) {}
private:
A() = delete;
A(const A&) = delete;
A(A&&) = delete;
};
class B
{
public:
// B() : ta(0.0f, 1) {} // Compilation errors
// B() : ta({0.0f, 1}) {} // Compilation errors
// B() : ta{0.0f, 1} {} // Compilation errors
// B() : ta(A(0.0f, 1)) {} // No constructor to copy or move A
private:
std::tuple<A> ta;
};
B b;
std::make_tuple
, std::forward_as_tuple
and others like that don't solve the problem, because default, copy and move constructors of A
are disabled.