C++ Weekly - Ep 462 - C++23's Amazing New Range Formatters

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 67

  • @costa_marco
    @costa_marco День тому +38

    We are pretty close to write idiomatic python in c++... ;)

    • @TsvetanDimitrov1976
      @TsvetanDimitrov1976 День тому +6

      It's all good as long as it's not idiomatic perl xD

    • @pyajudeme9245
      @pyajudeme9245 День тому +7

      That's actually what I thought when I [re]started studying C++ (This time version 20 instead of 11), and it is the reason why I am loving C++ now.

    • @costa_marco
      @costa_marco День тому

      @@TsvetanDimitrov1976 :D

    • @Maciej-Komosinski
      @Maciej-Komosinski День тому

      @@TsvetanDimitrov1976 It's all good as long as int is not as long as long! 🙃

    • @treyquattro
      @treyquattro День тому +3

      I sometimes wonder if that's where the inspiration is coming from these days

  • @muhdiversity7409
    @muhdiversity7409 День тому +16

    We're looking for someone with 15 years experience in the C++23 new Range Formatter features. Reach out.

    • @PedroOliveira-sl6nw
      @PedroOliveira-sl6nw День тому +5

      Did you mean: "We're looking for a recent graduate with 15 years experience in the C++23 new Range Formatter features. Reach out" ?

    • @muhdiversity7409
      @muhdiversity7409 День тому +1

      @@PedroOliveira-sl6nw could be ...

    • @pikachulovesketchup666
      @pikachulovesketchup666 День тому

      or 10 years of experience with C++36

  • @chaquator
    @chaquator День тому +11

    so when will c++ modules actually be ready

  • @davidgillies620
    @davidgillies620 День тому +3

    Literally yesterday I was wondering if std::cout would ever get the ability to print pairs, because I haven't yet internalised the idea that print() is a better way of doing things these days. Time to refactor some code.

    • @kaosce
      @kaosce 7 хвилин тому

      Yeah cout feels like a deprecated way in recent versions

  • @paulluckner411
    @paulluckner411 День тому +1

    Content starts at 1:32.

  • @AlfredoCorrea
    @AlfredoCorrea День тому

    Where do you find all these options? The documents I see online seem to be outdated. Also, without the ability of specifying element separator (like with `fmt::join` in fmt), the facility is pretty useless for ranges. (in clang `std::views::join_with` doesn't work yet).

  • @bac2463
    @bac2463 День тому

    can anyone help me, in a complex class, suppose the class name is Object; move obj, copy(or move) std::shard_ptr and move std::unique_ptr, which one gives the highest performance, if it has to move around 5 times

  • @xorbe2
    @xorbe2 День тому +4

    Alarming that a single print statement was slow to compile.

    • @TsvetanDimitrov1976
      @TsvetanDimitrov1976 День тому

      Most probably a variadic template plus a bunch of recursive template instantiations. I wouldn't be too worried about that, someone will optimize it.

    • @xorbe2
      @xorbe2 День тому +3

      @@TsvetanDimitrov1976 I think the optimizations have to be on the compiler side, there is a lot of template constexpr magic to make the compile-time parsing validation work.

  • @treyquattro
    @treyquattro День тому

    this has replaced a load of code I wrote for formatting output, plus my own print function (I wonder how many others also did their own post-C++17 and pre-C++23?). Not sure how to feel about that. Good, I guess?

    • @__Brandon__
      @__Brandon__ День тому +1

      The standard library must be working if everyone is going to go delete a bunch of repeated code when it gets an update

  • @krumbergify
    @krumbergify 23 години тому

    Really nice!

  • @TonniTielens
    @TonniTielens День тому

    Is something similar being added for enum constants? C++, as far as I know, really lacks an easy way of converting enum constants to strings. I was hoping C++26 would be adding support for that maybe.

    • @krumbergify
      @krumbergify День тому

      Try the ”magic enum” library. It uses some __PRETTY_FUNCTION__ trickery to fetch the name of enums.

  • @cavesalamander6308
    @cavesalamander6308 День тому

    As someone still using C++99, I hope C++23 also has a corresponding "scan".

    • @jasonenns5076
      @jasonenns5076 19 годин тому +1

      Why are you using C++98?

    • @cavesalamander6308
      @cavesalamander6308 19 годин тому

      ​@@jasonenns5076 I like it. 🙂
      More seriously, it’s just an old development system (Borland C-builder 6 and CodeGear RAD Studio 2007), which has been enough for me for a quarter of a century.

  • @VoidloniXaarii
    @VoidloniXaarii День тому

    再次感谢

  • @ИнякинАлександр

    Is it C++? Or is it Python, or is it Rust?

  • @simonmaracine4721
    @simonmaracine4721 День тому +3

    Rust had these formatting features since the beginning. I'm happy that C++ is catching up.

    • @cm5754
      @cm5754 День тому +1

      C had printf from long ago… languages are just recreating the idea of format string + parameters

    • @simonmaracine4721
      @simonmaracine4721 День тому +1

      @@cm5754 No, I'm referring to being able to print containers that have printable items. And raising a compile error, if anything is wrong. Rust actually can print any struct in an uniform way, if it's members are printable, which could be, of course, other structs and containers and anything. And all of these are opt-in.

    • @ensuretime
      @ensuretime День тому

      ​@simonmaracine4721 fmtlib also has features implemented even before rust's own std.fmt, even many fmtlib features were not added to the standard iso, although it seems that everything comes from rust, in the case of std::format everything derives from fmtlib

    • @rastaarmando7058
      @rastaarmando7058 22 години тому

      @simonmaracine4721 Last time I tried Rust the book clearly stated you can't print containers by default. When did this become a thing?

  • @Ahmed-S-Lilah
    @Ahmed-S-Lilah День тому +1

    As some who loved the premise of C++ at the beginning and started programming in it at 11 years old.
    I'm sorry but this is ridiculous.
    Like the implementation is so bad.
    C++26 reflections is horrible engineering.
    Like who would refuse something Jai like meta programming for whatever C++ bullshit is beingoffered.
    And refusing Circle meta programming proposal?
    What?!
    I watched a video on the C++26 reflections and meta programming facilities.
    And I was like, I'll kill myself before writing this shit.
    Add this to the useless coroutines and constexpr BS and OMG the safety proposal!!!
    And you had yourself one very angry C++ Dev.
    I really wonder if the C++ Committee gets high while taking these decisions.
    Like, I'm sorry but the hell did you mean by saying it's amazing?
    I sometimes wonder if you guys are just happy that C++ is getting this complicated so you can still work as C++ instructors?
    If you see this comment please tell why would any one still consider working with C++.

    • @muhdiversity7409
      @muhdiversity7409 День тому +1

      C++ jumped the shark, long, long, long ago.

    • @Ahmed-S-Lilah
      @Ahmed-S-Lilah День тому

      @muhdiversity7409
      I know but they're not even acknowledging it.
      They're choosing the absolute worst way any feature could be added and then making a fucken miss of feature.
      And you see them talking about this shit in conferences like they invented a cure for cancer or something.
      And they speak in this sumg academic language to sound smart or whatever to end up producing a pile of trash.
      Mean while, some like Jonathan Blow is making stuff a billion times better that them on his own.
      Like for fuck sake how many people are working on ISO CPP committee??

    • @pikachulovesketchup666
      @pikachulovesketchup666 День тому +2

      For me the biggest nonsense of C++26 is defining uninitialized variables as something valid xDDDD Instead of simply disallowing read from uninitialized data (compiler does see this every time you do something bad. This is inherent property of SSA) they defined that 2 uninitialized variables are equal 😢std::span is still broken with "safety by assert". Assert doesn't exist. It's never executed. Instead they should have made all STL operators perform range checks 100% of time, and specify extra stuff like "unsafe_at", "unsafe_first", etc. which ignore the checks with assert. If you want backwards compatibility compiler should require some flag, e.g. "-fallow-unsafe-garbage-code".

    • @taw3e8
      @taw3e8 6 годин тому

      ​@@pikachulovesketchup666uninitialized read is unfortunately not always visible due to pointer arithmetic

  • @literallynull
    @literallynull День тому

    I will still use fmt simply because of the standard library bloat

  • @victotronics
    @victotronics 2 дні тому +2

    Yet more letters to remember for std::format. I already have a cheat sheet hanging over my desk. It's not as natural yet as printf ever was.

    • @timangus
      @timangus День тому +3

      I think you watched a different video to the one I just did.

    •  День тому +1

      Bot?

    • @aniketbisht2823
      @aniketbisht2823 День тому +15

      printf doesn't even have all these facilities. It's primitive, unsafe ,and slow. With more flexibility comes more rules. You can always define your own types and specify how they are printed using std::formatter.

    • @not_ever
      @not_ever День тому +7

      printf fans are an odd bunch of people

    • @karemegypt25
      @karemegypt25 День тому +3

      Probably meant the ":m"?