@deezo

4 Followers
25 Following
140 Posts
Moral for programmers
C++26 will have data-parallel types (or std::simd as it came to be known; unless we rename it next meeting — don't settle in for the name just yet) 🎉  #cpp #cplusplus #cpp26 #simd

Person 1: What are you dressed up as?

Person 2: A harp

Person 1: Aren't you small for a harp?

Person 2: Are you calling me a lyre?

🥁

you can say what you want about C++... I like it #development #cpp

Order-dependent bugs have got to be the hardest to even realize existing. Especially in a C++ compiler.

If writing tests for our little software is a pain, the pain of writing tests for a C++ compiler has to be a million times. And that's not even counting the testing needed for different means to accomplish the same thing. Order dependency only makes things harder from there.

We cannot ever thank enough the FOSS implementers. 🙇‍♂️ 🫡 🙏

#cpp #foss #gcc #clang

Is there a way to extract replacement fields or standard format specification from std::format_string?
I want to convert back from single argument formatted string to arithmetic value.
#cpp #cplusplus #programming

C++20 introduced a significant change to lambdas without capture. The autogenerated unique type is now default-constructible and copy (and move) assignable.

While the previous behaviour made sense for lambdas with captures and conceptually (each lambda is inherently an instance of its autogenerated type), it also made lambdas awkward to use as arguments to generic code.

Compiler Explorer link: https://compiler-explorer.com/z/TY4oqYccc

#cpp #cplusplus #coding #programming #dailybiteofcpp

Compiler Explorer - C++

int main() { // Using a function object struct Cmp { bool operator()(int l, int r) const { return l < r; } } cmp; std::map<int,int,Cmp> a; // OK std::map<int,int,decltype(cmp)> b; // OK a = b; // OK // Same logic using a lambda auto lcmp = [](int l, int r) { return l < r; }; std::map<int,int,decltype(lcmp)> c(lcmp); // OK // pre-C++20 we have to copy-construct the comparator std::map<int,int,decltype(lcmp)> d; // Wouldn't compile pre-C++20 // pre-C++20 delctype(lcmp) isn't default constructible c = d; // Wouldn't compile pre-C++20 // pre-C++20 decltype(lcmp) isn't copy-assignable }

Wish #cpp allowed concept definitions in class scope, not just namespace scope. DRY, better encapsulate class, reduce litter outside class.

E.g., if a class has many functions w "strict bool" parameter:
- (a) works, not DRY
- (b) DRY but concept visible in client along with class

//a: repeat w each function
template<typename B> requires std::same_as<B, bool>
void f(B b);

//b: once
template<typename B>
concept strict_bool = std::same_as<B, bool>;

void f(strict_bool auto b); //succinct

From “The Irrationals”

🤯

The last in a series of blog posts on a C++ technique that I've put to use for a numerical library. Was a fun little exercise: Pattern Matching Template Types https://indii.org/blog/pattern-matching-template-types/ #cpp #cplusplus #metaprogramming #blogpost #programming
C++: Pattern Matching Template Types

How to check if a template type matches a pattern? Something like `is_like_v<T, vector<int,_>>`.

indii.org