On Mon, Nov 29, 2021 at 3:16 AM Cleiton Santoia via SG16 <sg16@lists.isocpp.org> 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

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@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/sg16