C++ Logo

std-proposals

Advanced search

Re: std::as

From: Miguel Ojeda <miguel.ojeda.sandonis_at_[hidden]>
Date: Tue, 27 Oct 2020 11:16:23 +0100
On Mon, Oct 26, 2020 at 8:18 PM Arthur O'Dwyer via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> However, I would still !vote against such a proposal, because the fact remains that `*std::get_if<int>(&v)` has the same normative effect, and is shorter to type, and is idiomatic C++17 already. I don't think C++23 needs a new idiom to sit alongside the existing C++17 idiom. In particular, I want to be able to keep using `*std::get_if<int>(&v)` in my C++17 and C++20 codebases and get the optimization, without needing to rewrite any code. If the optimization is available only to C++23 codebases, and if I have to make a `git commit` touching the code before the compiler will deign to optimize it, that's not so useful to me.

Simple and proper APIs that reflect the proper intention of the writer
are better than "idioms" which are only so because the library did not
include a function to start with. Not to mention that optimizers are
not magical, plus it takes build time to untangle the mess anyway.

Cheers,
Miguel

Received on 2020-10-27 05:16:37