News for hackers. Stuff that matters.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by dale_glass on Monday April 01, 2024 @08:26AM (#39893398)
I kinda like it, it's comfortable and pragmatic. I don't have to look at the docs to figure out what's the format specifier for something like a size_t, and you can easily add support for whatever might be needed, so you can comfortably do:

   std::cout << "Player is at" << _player_pos;
And get the x/y/z breakdown automatically.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by diath on Monday April 01, 2024 @09:02AM (#39893707)
But you can do that with fmtlib/std::format as well when you provide formatting for custom types, that just becomes:

    fmt::println("Player is at {}", _player_pos);
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by petters on Monday April 01, 2024 @10:30AM (#39894534)
Should be possible to implement cout more effectively since there is no string parsing. I say “should” because in practice it seems to be the other way around. I don’t know why.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by hermitdev on Monday April 01, 2024 @02:33PM (#39897483)
Been a while since I've looked at it, but pretty sure std::format validates and parses most (all?) format strings at compile time. There should be no runtime penalty.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by vitaut on Tuesday April 02, 2024 @07:58PM (#39912148)
There are some fundamental reasons why cout is slower than stdio/{fmt}: https://stackoverflow.com/a/65325727/471164.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by blacklion on Monday April 01, 2024 @09:15AM (#39893839)
And now try to do task which should be as trivial as add 1 format character: output number in hexadecimal and leave stream in same state that was before your code.

It becomes cumbersome very fast.