by nwallin · 3y ago · 0 comments
No you don't. A tuple needs to be declared once. Then everything else is sugared.
#include <string>
#include <tuple>
using Foo = std::tuple<int, std::string, float>;
Foo foo(int a, const char* b, double c)
{
return {a,b,c};
}
Foo bar(long);
double baz(long x) {
const auto [a, b, c] = bar(x);
return c;
}
godbolt: https://godbolt.org/z/exdsb4hqbNote that the return part of this (foo()) worked as far back as C++11. Only the structured bindings on the receiving side (baz) requires C++17.