C++ Logo

sg16

Advanced search

Re: [isocpp-sg16] Typing Unicode symbols in wording

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Fri, 25 Oct 2024 14:50:51 +0200
On 25/10/2024 09.03, Mateusz Pusz via SG16 wrote:
> One more question. It seems that we can define the same Unicode thing in many ways:
>
> inline constexpr struct pi final : mag_constant<symbol_text{u8"π", "pi"}, std::numbers::pi_v<long double>> {} pi;
> inline constexpr struct pi final : mag_constant<symbol_text{u8"\u03c0", "pi"}, std::numbers::pi_v<long double>> {} pi;
> inline constexpr struct pi final : mag_constant<symbol_text{u8"\N{GREEK SMALL LETTER PI}", "pi"}, std::numbers::pi_v<long double>> {} pi;
>
> We agreed that the first spelling is not the best choice. The second is already used to define chrono duration I/O (https://eel.is/c++draft/time.duration.io <https://eel.is/c++draft/time.duration.io>). However, maybe the third line provides the most information about what is going on?
> What is your opinion here?

For me, the last option conveys the most information. On the other hand,
having the character number available also has value.
Note: The <chrono> specification predates named universal characters
(third option) in the core language.

What about this:

inline constexpr struct pi final : mag_constant<symbol_text{u8"π" /* U+03C0 GREEK SMALL LETTER PI */, "pi"}, std::numbers::pi_v<long double>> {} pi;

?


Jens

Received on 2024-10-25 12:50:56