C++ Logo


Advanced search

Re: [std-proposals] D3077R0 Proposal of static_cast shorthand: <T>(x) DRAFT 1

From: Andrew Tomazos <andrewtomazos_at_[hidden]>
Date: Sun, 31 Dec 2023 01:36:42 +1000
On Sun, Dec 31, 2023 at 12:54 AM Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>

> On Fri, Dec 29, 2023 at 4:30 PM Andrew Tomazos via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>> Please find attached a short 2-page proposal:
>> D3077R0 Proposal of static_cast shorthand: <T>(x) DRAFT 1
>> https://isocpp.org/files/papers/D3077R0.pdf
> Well, replacing `static_cast<T>(x)` with `<T>(x)` is obviously not a good
> idea.

Arthur, thanks but could you please state the reasons why you don't think
it is a good idea. If they were obvious to me, then I wouldn't have
written the proposal.

Is your main point that C++ already has "many cast syntaxes already", so it
doesn't need the added complexity of yet another one?

I didn't consider the idea of partial deprecation of T(x) as viable given
how often it is used, nor can it be applied to type-ids that are not
simple-type-specifiers (ie ones with declarators). That is:

    int(x) // ok
    T(x) // ok
    T*(x) // nope
    T&(x) // nope


    <int>(x) // ok
    <T>(x) // ok
    <T*>(x) // ok
    <T&>(x) // ok

I would agree fixing T(x) would be better if it was viable and subsumed
<T>(x), but neither seems so.

Received on 2023-12-30 15:36:55