Date: Thu, 3 Jul 2025 10:01:18 +0100
On Thu, 3 Jul 2025 at 09:52, Jonathan Wakely <cxx_at_[hidden]> wrote:
>
>
> On Thu, 3 Jul 2025 at 09:50, Frederick Virchanza Gotham via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> Rather than have to write functions like:
>>
>> inline constexpr char tolower_consteval_char(char const c) noexcept
>> {
>> switch ( c )
>> {
>> case 'A': return 'a'; case 'B': return 'b'; case 'C':
>> return 'c'; case 'D': return 'd';
>> case 'E': return 'e'; case 'F': return 'f'; case 'G':
>> return 'g'; case 'H': return 'h';
>> case 'I': return 'i'; case 'J': return 'j'; case 'K':
>> return 'k'; case 'L': return 'l';
>> case 'M': return 'm'; case 'N': return 'n'; case 'O':
>> return 'o'; case 'P': return 'p';
>> case 'Q': return 'q'; case 'R': return 'r'; case 'S':
>> return 's'; case 'T': return 't';
>> case 'U': return 'u'; case 'V': return 'v'; case 'W':
>> return 'w'; case 'X': return 'x';
>> case 'Y': return 'y'; case 'Z': return 'z';
>> }
>>
>> return c;
>> }
>>
>> Granted I didn't have to write that out myself because ChatGPT did it
>> for me, but can we make the likes of std::tolower, std::toupper,
>> std::isalpha, and so on, all constexpr?
>>
>
> They depend on the current locale.
>
>
>
Meaning that this would fail:
setlocale(LC_ALL, "de_DE.iso8859-1");
char c uuml = 0xFC; // lowercase u with umlaut
char c = std::toupper(uuml);
constexpr char cc = std::toupper(uuml);
assert( c == cc );
>
>
> On Thu, 3 Jul 2025 at 09:50, Frederick Virchanza Gotham via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> Rather than have to write functions like:
>>
>> inline constexpr char tolower_consteval_char(char const c) noexcept
>> {
>> switch ( c )
>> {
>> case 'A': return 'a'; case 'B': return 'b'; case 'C':
>> return 'c'; case 'D': return 'd';
>> case 'E': return 'e'; case 'F': return 'f'; case 'G':
>> return 'g'; case 'H': return 'h';
>> case 'I': return 'i'; case 'J': return 'j'; case 'K':
>> return 'k'; case 'L': return 'l';
>> case 'M': return 'm'; case 'N': return 'n'; case 'O':
>> return 'o'; case 'P': return 'p';
>> case 'Q': return 'q'; case 'R': return 'r'; case 'S':
>> return 's'; case 'T': return 't';
>> case 'U': return 'u'; case 'V': return 'v'; case 'W':
>> return 'w'; case 'X': return 'x';
>> case 'Y': return 'y'; case 'Z': return 'z';
>> }
>>
>> return c;
>> }
>>
>> Granted I didn't have to write that out myself because ChatGPT did it
>> for me, but can we make the likes of std::tolower, std::toupper,
>> std::isalpha, and so on, all constexpr?
>>
>
> They depend on the current locale.
>
>
>
Meaning that this would fail:
setlocale(LC_ALL, "de_DE.iso8859-1");
char c uuml = 0xFC; // lowercase u with umlaut
char c = std::toupper(uuml);
constexpr char cc = std::toupper(uuml);
assert( c == cc );
Received on 2025-07-03 09:01:37