Consider:
struct Point { int x, y; };
int main()
{
const auto [x, y] = Point{};
}
This code compiles fine with gcc 7.1 in C++17 mode, howe
The core idea behind structured bindings is that std::tuple_size
defines how many components you get from unpacking T
, and T::get
should access the N'th element. Not surprising, this std::tuple_size
is a specialization from the base template in
.
Now in this case, Point
doesn't have such support for structured bindings, but it is a special case (all public non-static members) for which C++17 states that no special unpacking support is needed. This is an exception to the rule above.
The compiler is tripping over itself here, and trying to use the generic rule when it sees the unspecialized std::tuple_size
from
.