std::make_from_tuple doesn’t compile without constructor

  c++, c++17, default-constructor, tuples

I have a simple struct:

struct A
{
    int a;
    int b;
    int c;
    
    // A(int a, int b, int c) : a{a}, b{b}, c{c} { }
};

The constructor is commented for now. I am trying to create object of type A in a such way:

auto t = std::make_tuple(1, 2, 3);
A a = std::make_from_tuple<A>(std::move(t));

but it doesn’t compile. MSVC gives a message:
<function-style-cast>: cannot convert from initializer_list to _Ty.
After I uncomment the constructor of struct A, it starts working.

The question is: why std::make_from_tuple() requires a user-defined constructor instead of default one?

Source: Windows Questions C++

LEAVE A COMMENT