Date: Mon, 29 Nov 2021 08:44:51 +0100
On Mon, Nov 29, 2021 at 3:16 AM Cleiton Santoia via SG16 <
sg16_at_[hidden]> wrote:
> Does unicode support allow a portable STL UDL like s² ?
>
> inline fancy_unity_time_square operator "" s²(long double s) {
> return fancy_unity_time_square{s * s};
> };
>
> auto t2 = 6s²
> auto g = 9.8m/s²;
>
>
> Working sample
> https://www.godbolt.org/z/eYz31a9cq
>
No - GCC only conforms to P1949 under c++23 and -pedantic, which i think is
a bit unfortunate https://www.godbolt.org/z/deczGWf8x
Clang has the correct behavior by default
https://www.godbolt.org/z/63TWrMGbh
² doesn't have the XID_Continue continue property and therefore cannot be
part of identifiers. UDL suffixes are identifiers as far as the C++ grammar
is
concerned, and so they obey the same rules as other identifiers.
Characters with the XID_Continue can be used in UDLs
inline int operator "" Ω(long double s) {
return 0;
};
I hope this helps,
>
>
>
> BR
> Cleiton
> --
> SG16 mailing list
> SG16_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg16
>
sg16_at_[hidden]> wrote:
> Does unicode support allow a portable STL UDL like s² ?
>
> inline fancy_unity_time_square operator "" s²(long double s) {
> return fancy_unity_time_square{s * s};
> };
>
> auto t2 = 6s²
> auto g = 9.8m/s²;
>
>
> Working sample
> https://www.godbolt.org/z/eYz31a9cq
>
No - GCC only conforms to P1949 under c++23 and -pedantic, which i think is
a bit unfortunate https://www.godbolt.org/z/deczGWf8x
Clang has the correct behavior by default
https://www.godbolt.org/z/63TWrMGbh
² doesn't have the XID_Continue continue property and therefore cannot be
part of identifiers. UDL suffixes are identifiers as far as the C++ grammar
is
concerned, and so they obey the same rules as other identifiers.
Characters with the XID_Continue can be used in UDLs
inline int operator "" Ω(long double s) {
return 0;
};
I hope this helps,
>
>
>
> BR
> Cleiton
> --
> SG16 mailing list
> SG16_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg16
>
Received on 2021-11-29 01:45:09