C++ Logo

sg16

Advanced search

Re: [isocpp-sg16] Unicode identifiers in the source code

From: Mateusz Pusz <mateusz.pusz_at_[hidden]>
Date: Sun, 30 Jun 2024 17:06:22 +0200
If you use it like below, it may not look that bad:

auto q = 90 * ° + 20 * ′ + 12 * ″;

Yes, I understand your point. However, if we discuss providing Unicode
identifiers, we should probably provide them for all or none of the units.

Anyway, we also have the "ASCII" version:

inline constexpr auto deg = degree;
inline constexpr auto arcmin = arcminute;
inline constexpr auto arcsec = arcsecond;

so this is always the alternative:

auto q = 90 * deg + 20 * arcmin + 12 * arcsec;

niedz., 30 cze 2024 o 16:58 Ville Voutilainen <ville.voutilainen_at_[hidden]>
napisał(a):

> On Sun, 30 Jun 2024 at 17:56, Mateusz Pusz via SG16
> <sg16_at_[hidden]> wrote:
> >
> > Hi,
> >
> > During the recent LEWGI discussion on the units library, people in the
> room suggested that in addition to the regular "ASCII" version, we should
> also provide Unicode symbols for unit identifiers. It seems that with
> P1949R7, this could be possible.
> >
> > However, when I tried this in the code, I was able to make the following
> work:
> >
> > inline constexpr auto µΩ = micro<si::ohm>;
> >
> > but not:
> >
> > inline constexpr auto ℃ = degree_Celsius;
> > inline constexpr auto ° = degree;
> > inline constexpr auto ′ = arcminute;
> > inline constexpr auto ″ = arcsecond;
> >
> > Are those outside of the supported range and should not be supported, or
> is it just the lack of proper support in the compilers I use (gcc-14 and
> clang-18)?
> >
> > Even if this can work, is it a good idea?
>
> The symbols for arcminute and arcsecond are an unmitigatable disaster,
> if you ask me, considering the use of single and double quotes
> elsewhere in
> the language.
>

Received on 2024-06-30 15:06:35