C++ Logo

sg10

Advanced search

Re: [SG10] New issue: auto(x) should have a feature-testing macro

From: Casey Carter <cartec69_at_[hidden]>
Date: Mon, 10 Jan 2022 17:02:16 -0800
libc++ is using

#define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay
<decltype((expr))>::type>(expr)

which has equivalent-ish semantics and inferior throughput. I suspect they
would like to replace that with auto(expr) when possible.

On Tue, Jan 4, 2022 at 11:47 AM Jonathan Wakely via SG10 <
sg10_at_[hidden]> wrote:

>
>
> On Tue, 4 Jan 2022 at 19:27, Barry Revzin via SG10 <sg10_at_[hidden]>
> wrote:
>
>> Do you have an example of code that would benefit from such detection?
>>
>
> And what is the alternative code that you'd use in the #else branch?
>
> If the alternative has equivalent semantics and performance, we don't need
> a macro.
>
>
>
>
>>
>> ---------- Forwarded message ---------
>> From: William M. (Mike) Miller <wmm_at_[hidden]>
>> Date: Tue, Jan 4, 2022 at 1:25 PM
>> Subject: Fwd: New issue: auto(x) should have a feature-testing macro
>> To: Barry Revzin <barry.revzin_at_[hidden]>
>> Cc: Zhihao Yuan <zy_at_[hidden]>, <arthur.j.odwyer_at_[hidden]>
>>
>>
>> This suggestion should be decided by SG10 rather than being
>> handled as a core language issue, so I'm forwarding it to the
>> SG10 chair for consideration. Thanks.
>>
>>
>> -------- Forwarded Message --------
>> Subject: New issue: auto(x) should have a feature-testing macro
>> Date: Tue, 14 Dec 2021 02:48:12 +0000
>> From: Zhihao Yuan <zy_at_[hidden]>
>> Reply-To: Zhihao Yuan <zy_at_[hidden]>
>> To: William M. \(Mike\) Miller <wmm_at_[hidden]>
>> CC: 'Arthur O'Dwyer' <arthur.j.odwyer_at_[hidden]>
>>
>> It's hard to detect whether it is legal to
>> do auto(expr) after adopting P0849R8;
>> A feature testing macro would help.
>>
>> There was no __cpp_auto (unlike
>> __cpp_decltype_auto), but the direction
>> of evolving auto(x) is probably not
>> necessarily tied to `auto` in a
>> declaration.
>>
>> Proposed resolution:
>>
>> This wording is relative to N4901.
>>
>> Add an entry to [tab:cpp.predefined.ft]
>>
>> Table 21: Feature-test macros
>>
>> | Macro name | Value |
>> | -------- | ------- || <ins>__cpp_auto_cast</ins> | 202110L |
>>
>> --
>> Zhihao Yuan, ID lichray
>>
>> The best way to predict the future is to invent it.
>>
>> _______________________________________________
>> --
>> SG10 mailing list
>> SG10_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/sg10
>>
> --
> SG10 mailing list
> SG10_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg10
>

Received on 2022-01-11 01:02:29