• C++20+

    From hollowone@VERT/BEERS20 to All on Tue Feb 25 12:58:00 2025
    In my daily and production ready C++ code I consciously got stuck with up to C++17 features that seem to be practical to me.

    I find it extremely valuable with the:

    - std::move/forward mechanics
    - unique/shared_ptr
    - std::thread
    - lambda functions
    - auto/nullptr
    - range based for(auto& x : y)
    - std::chrono, tuple, new containers (unordered_map)
    - bracket initialization auto x = {1};
    - default,deleted,override and final functions
    - const,constexpr
    - std::optional, std::variant, std::any
    - std::filesystem

    I started reading about C++20 features, primarily:

    - anonymous template functions/methods
    - coroutines
    - <=> operator
    - concepts
    - ranges
    - modules
    - timezones in std::chrono
    - alternative string formatting via std::format

    I was avoiding any lecture related to it feared by general opinion that beyond C++17 the standard is messed up heavily. but actually I find many of the features mentioned above quite useful.

    I'll be experimenting with it, but I'm also curious about your opinion about practicality of above features in your projects.

    I find only concepts heavily confusing as first encounter, but I was never onto template driven/generic programming, thus I find this one obviously optional.

    How about you?

    -h1

    ... Xerox Alto was the thing. Anything after we use is just a mere copy.
  • From Nightfox@VERT/DIGDIST to hollowone on Tue Feb 25 15:16:04 2025
    Re: C++20+
    By: hollowone to All on Tue Feb 25 2025 12:58 pm

    In my daily and production ready C++ code I consciously got stuck with up to C++17 features that seem to be practical to me.

    I think there have been some fairly nice additions to C++ since C++11. I've been doing some C++ development recently, and some things I've found particularly useful are std::thread, shared_ptr, lambda/anonymous functions, and regular expressions.

    One thing that bugs me a little is 'auto'. I understand why it was introduced, but I feel like it reduces readability, as we don't immediately know what type the variable will be (or should be) when we see 'auto'.

    initialization auto x = {1};

    Also, I keep forgetting what the purpose of curly brace initialization is, and I often have to look it up. I see that it does not allow type narrowing, which I do think is useful.

    One thing I've seen recently is that for std::vector, they've added an emplace_back() method, which is like push_back(), but they say emplace_back() should have beetter performance as it "creates the object in place".

    Nightfox

    ---
    þ Synchronet þ Digital Distortion: digitaldistortionbbs.com