I've used std::tie without giving much thought into it. It works so I've just accept that:
auto test()
{
int a, b;
std::tie(a, b) = std::make_tuple(2, 3);
// a is now 2, b is now 3
return a + b; // 5
}
But how does black magic work? How does a temporary created by std::tie change a and b. I find this more interesting since it's a library feature, not a language feature, so surely it is something we can implement ourselves and understand.
Aucun commentaire:
Enregistrer un commentaire