C++ Logo


Advanced search

Re: [std-proposals] C-style array specialization for std::get

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Fri, 11 Mar 2022 00:00:38 +0000

I believe it's aligned for sequence containers, and subscript returns `reference` for a non-const container there, regardless of value category.


-------- Original Message --------
From: Giuseppe D'Angelo via Std-Proposals <std-proposals_at_[hidden]>
Sent: March 10, 2022 11:10:53 PM GMT+00:00
To: std-proposals_at_[hidden]
Cc: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Subject: Re: [std-proposals] C-style array specialization for std::get

On 10/03/2022 20:20, Zhihao Yuan via Std-Proposals wrote:
> But other than the built-in array,
> no operator[] in the standard is
> aware of value-category (std::array,
> std::vector, etc.) The built-in
> array is special here as its "[i]"
> models after a member access.

To be honest, this prompts the question as if this was an oversight
(does std::array predate move semantics?) or a deliberate design
decision to align with e.g. std::vector.

(I can understand why std::vector operator[] hasn't been changed to
return rvalue references invoked on a rvalue vector.)

Giuseppe D'Angelo

Received on 2022-03-11 00:00:44