I can\'t initialize std::tuple
elements element-wise from a std::tuple
of compatible types. Why doesn\'t it work as with boost::tuple
?
Overloads (4) and (5) are poorer matches than (3) when passed a tuple&
: they are const&
and &&
overloads, while (3) matches exactly through the magic of perfect forwarding.
(3) is valid because your Foo(U&&)
constructor is overly greedy.
Add SFINAE checks to Foo(U&&)
so that it fails to match when it fails to build:
template {},int>* =nullptr
>
Foo(U &&u) : val(std::forward(u)) {}
The rvalue case should, however, work or be ambiguous. Looking at the error log of your live example, the only error I see is with the lvalue one.