3

I've seen code where something like this is done:

auto [a, b, c] = some_array_ptr;

What are the rules and proper terminology for this type of assignment?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
Ben Pang
  • 33
  • 3

1 Answers1

2

(Translating @BessieTheCow's comment into an answer) in C++, this is called "structured binding". Read about it at cppreference.com, and you may also be interested in this question here on StackOverflow:

Understand structured binding in C++17 by analogy

Note that not everything you might interpret as "multiple values" can actually be used in structured binding (e.g. - a pointer may point to many values but it won't work, as @Peter points out.)

einpoklum
  • 118,144
  • 57
  • 340
  • 684