• 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
  • From feoh@VERT/SDF1 to All on Fri Feb 6 18:04:00 2026
    auto seems SUPER compelling and looks like it might take some of the drudgework out of using C++, at least for whimps like me who generally reach for gc languages like Python first.

    I knew C++ pretty well in the 90s. Hopefully one of these days I can dust off those neurons and enjoy some of the newer features that have come along since I last checked.

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: SDF-1 BBS: bbs.sdf1.net (ssh: 5022, telnet: 5023)
  • From Nightfox@VERT/DIGDIST to feoh on Fri Feb 6 13:30:51 2026
    Re: Re: C++20+
    By: feoh to All on Fri Feb 06 2026 06:04 pm

    auto seems SUPER compelling and looks like it might take some of the drudgework out of using C++, at least for whimps like me who generally reach for gc languages like Python first.

    I knew C++ pretty well in the 90s. Hopefully one of these days I can dust off those neurons and enjoy some of the newer features that have come along since I last checked.

    The 'auto' keyword has been around in C++ since 2011 (added to the C++11 standard).

    I've been using C++ a while (professionally since 2003, and started learning it in college in 1999-2000). I like many of the additions to C++ since the C++11 standard, though I feel like I still shy away from 'auto' sometimes. I see the usefulness of it, but I hesitate to use it liberally in my code. I think one of the strengths of C++ is that it's a strongly-typed language, and before 'auto', that meant you would know the type of all the variables just by reading the code. With 'auto', I think the code is a bit less readable, as you now need to look more closely at what the code is doing in order to determine what type it (probably) has.

    There are also times when you really need a variable to have a specific type - For instance, if you're reading & writing audio data, you need a variable that's specifically a number of bits wide. At some point, you'd need to declare a variable with a specific type. Although higher up in the code, you could still use 'auto' (and I think that could be useful).

    The 'auto' keyword helps in allowing the code to deal with changing return types. I think it's mostly useful if you're using a library function and that function's return type ends up being changed at some point.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion: digitaldistortionbbs.com
  • From Digital Man@VERT to Nightfox on Fri Feb 6 16:30:28 2026
    Re: Re: C++20+
    By: Nightfox to feoh on Fri Feb 06 2026 01:30 pm

    Re: Re: C++20+
    By: feoh to All on Fri Feb 06 2026 06:04 pm

    auto seems SUPER compelling and looks like it might take some of the drudgework out of using C++, at least for whimps like me who generally reach for gc languages like Python first.

    I knew C++ pretty well in the 90s. Hopefully one of these days I can dust off those neurons and enjoy some of the newer features that have come along since I last checked.

    The 'auto' keyword has been around in C++ since 2011 (added to the C++11 standard).

    The 'auto' keyword actually dates back to the pre-standard (i.e. 1978) C Programming language. It was a storage class modifier (the opposite meaning of 'static' when declaring a function-local variable). Since 'auto' was the default storage class, you didn't see it used much at all in C. So it was kind of safe to reuse for a different purporse in C++ and now the newest version of C (2023?) has a similar (but not identical) repurposing of the 'auto' keyword as how its used in C++.
    --
    digital man (rob)

    Synchronet/BBS Terminology Definition #46:
    IMAP = Internet Message Access Protocol
    Norco, CA WX: 66.3øF, 67.0% humidity, 8 mph W wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Fri Feb 6 18:18:28 2026
    Re: Re: C++20+
    By: Digital Man to Nightfox on Fri Feb 06 2026 04:30 pm

    The 'auto' keyword has been around in C++ since 2011 (added to the C++11
    standard).

    The 'auto' keyword actually dates back to the pre-standard (i.e. 1978) C Programming language. It was a storage class modifier (the opposite meaning of 'static' when declaring a function-local variable). Since 'auto' was the default storage class, you didn't see it used much at all in C. So it was kind of safe to reuse for a different purporse in C++ and now the newest version of C (2023?) has a similar (but not identical) repurposing of the 'auto' keyword as how its used in C++.

    Ah.. Interesting to know. Though I was thinking of "auto" just in its current use in C++. :)

    Nightfox

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