Writing tie instead of std::tie works here, because of argument-dependent lookup:
std::tuple<int, std::string> tup = std::make_tuple<int, std::string>(1, "a");
int i;
std::string str;
tie(i, str) = tup;
But why does make_tuple require std::?
In order for ADL (Argument-dependent lookup) to work, you need one of the arguments to the in the
stdnamespace.This is the case in your call to
tie(stris astd::string), but not in the call tomake_tuple(neigher1nor"a"are).You could use ADL by supplying a
std::stringlike this:Note:
The code above, which attempts to be closest to your version, requires c++20 (where explicit template arguments don't prevent ADL).
However - this version which is also shorter works in earlier c++ versions: