Enlico
Enlico

Reputation: 28520

What part in cppreference tells me structured binding declarations only work with compile-time known objects?

My question is

What part of the cppreference.com's page on structured binding declarations should make apparent that they cannot be used with "things" not known at compile time?

That page does not contain any explicit reference to compile or run time.

Why?

I recently bumped into this question about whether structured binding declarations work with std::vector, which doesn't since its size is not known at compile time. Since I'm trying to understand how Boost.Hana works, I need to make clear in my mind what the detailed distinction between run time and compile time is, hence I took the chance to ask the question above.

Upvotes: 2

Views: 99

Answers (1)

MSalters
MSalters

Reputation: 180305

The relevant part is std::tuple_size, which yields a compile-time size. You can't implement that for std::vector. It has a run-time variable std::vector::size.

Upvotes: 6

Related Questions