From cppref
Like a reference, a structured binding is an alias to an existing object. Unlike a reference, the type of a structured binding does not have to be a reference type.
For example:
int a[2] = { 1, 2 };
auto [x, y] = a;
x
and y
are aliases rather than references. My question:
How to implement a type check function like is_alias_v<decltype(x)>
?
I do not believe that such a thing is possible.
Fortunately, there is never any need for it.
Use x
as if it were a nice juicy int
, regardless of its origins. Because, well, that's what it is!
Also don't forget that x
and y
here don't alias or reference the elements of a
, but an "invisible" copy.