3 ms·
> Writing C++20 code without modules, ranges, or concepts, is like, what is the point. * std::span is in! https://stackoverflow.com/q/45723819/1593077 https://
by einpoklum 2y ago
> Writing C++20 code without modules, ranges, or concepts, is like, what is the point.
* std::span is in! https://stackoverflow.com/q/45723819/1593077 https://stackoverflow.com/q/45723819/1593077
* Designated initializers (like in C99)
* Spaceship operator and default comparison ops
* More language constructs can be constexpr'ed
* Better structured binding
* using on enums
* Don't need to say "typename" as much :-)
* Bunch of minor improvements to the standard library
Note I did not say coroutines. I still don't understand how that boondoggle made it into the language the way that it has.
- pjmlp 2y agostd::span is a trap, gsl::span should be used instead, unless one is willing to enable checked collections on the respective compiler. As for the rest, the point stands regarding portable code across various C++ compilers. I agree on the co-routines, while I know C# co-routines relatively well, and the C++/CX stuff that was used as inspiration for Microsoft's initial proposal, they are a bit of a mess, when key WG21 members also don't fully grasp how they have to be implemented, and we need two hour sessions on C++ conferences to go through "hello world" kind of implementations.
- deleted 2y ago[deleted]
- vitus 2y agostd::span is no more a trap than the rest of C++'s standard library in that regard. Are you also eschewing std::vector and std::string? std::string_view, std::array? I suppose C++26 brings std::span::at, although exceptions are a different can of worms.
- pjmlp 2y agoSome errors are too late to fix, span was originally bounds checked when proposed. Pre-C++98 compiler frameworks used bounds checking by default. And yes, if I am calling the shots, bounds checking are enabled in release builds. Never has been a problem other than performance cargo cult folks. Thankfully governments are making this less of discussion.
- vitus 2y ago> And yes, if I am calling the shots, bounds checking are enabled in release builds. No disagreement there. But I'd prefer to turn it on across the board via compiler flag rather than pull in a special library for it and remember to use that library consistently. And if that's the case, I don't see std::span as any more problematic on this front than the rest of the standard library. (Yes, I know, GSL isn't really a special library on Windows. But anywhere else, it is.)
- protomolecule 2y ago>various C++ compilers Which compilers? I'd bet there are compilers that are still stuck at c++98.
- einpoklum 2y ago> std::span is a trap, gsl::span should be used instead It's not a trap if you weren't expecting bounds checking. > we need two hour sessions on C++ conferences to go through "hello world" kind of implementations. After one hour it became clear to me I am going to stay away from that stuff until either it becomes much more usable (unlikely TBH) or someone forces me to use it...