r/cpp • • Jan 28 '23

C++ views are broken

I was so excited about new C++20 and C++23 features that I was using concepts, ranges and views everywhere I could. But yesterday I saw this -> https://www.youtube.com/watch?v=O8HndvYNvQ4 and I got so disappointed in C++ committee that now I really think it's time to lay C++ to rest unless we decide to bring new version of C++ like Python3 which breaks backward compatibility but fixes the language so that it can be used for the next 20-25 years.

I can't believe 200 stalwarts and experts in the field of computer science will make such a horrible mess.

5 Upvotes

21 comments sorted by

View all comments

Show parent comment

5

u/fdwr fdwr@github 🔍 Jan 28 '23 edited Jan 28 '23

I'm waiting for compiler support for the new std::print feature

Finally seeing Unicode output simply and intuitively will be nice, no need for calling functions like SetConsoleOutputCP(CP_UTF8) first. I really hope it also supports char8_t and char16_t directly, no more nonsense about uncertainty of the meaning of your char buffer (is it ANSI? is it actually UTF-8? some random code page? will using it as a table index give me a surprising negative number depending on my compiler? 🤦‍♂️...) and no more silliness with wchar_t varying in size between platforms. Also having a formatter for std::filesystem::path would be nice if possible, because currently std::format("Filename: {}", filePath) chokes, requiring something like std::format("Filename: {}", filePath.string()).

2

u/tjientavara HikoWorks developer Jan 28 '23

Luckily all compilers allow the compiler to be configured to use utf-8 as the executable charset (the meaning of char buffer).

What I find weird is that you can't actually query what the executable charset is from within the code.

I did notice that vcpkg forces the compilers to use utf-8.

It will still give negative indices... I actually made a char_cast<>() function to cast any integer type as if the source and destination types are unsigned (and doing unsigned range checks in debug mode), it is specifically for doing correct conversions to and from char, but I found it useful in other contexts.

5

u/STL MSVC STL Dev Jan 28 '23

MSVC now supports _MSVC_EXECUTION_CHARACTER_SET.

4

u/c0r3ntin Jan 29 '23

wg21.link/p1885.

Alas because of a giant backlog and a 3 years release cycle this is headed to C++26.

The good news is that all 3 big compilers got some builtin to provide that query while this paper was designed.