Live data from Hacker News

The PImpl idiom and the C++26 std:indirect type

mariusbancila.ro

1–10 of 122 posts

Re: The PImpl idiom and the C++26 std:indirect type

#4

C++ is getting more and more complex. It used to be said that people use only a small percentage of it when writing C++, but I am beginning to think that the cake is a lie here.

where "more and more complex" do u see in this article? This is a basic C++ idiom, which constantly used by developers

Re: The PImpl idiom and the C++26 std:indirect type

#6
This looks great indeed - I wonder if there are any particular gotchas, though, as things often are in C++next land.

With many of the features coming into the language over time, I kinda wish that a bit more restricted subset of it eventually becomes a thing, but I know in practice it might as well be a completely different language. That, and I expect that still many other things have not been resolved as well as they are elsewhere, such as build system and dependency management (although I haven't touched this stack for a while now, so I would love to be surprised).

Re: The PImpl idiom and the C++26 std:indirect type

#7

This is actually useful, but despite it is another extra thing you will have to remember when reading C++ code. I guess with LLMs things aren't so bad.

Why? It’s still the good (bad) old pimpl pattern. It just got a bit shorter. When reading you dont even need to grok “std::indirect”, you see the word pimpl and you know what’s going on.

Re: The PImpl idiom and the C++26 std:indirect type

#8
post #5

Hmm. Do people use PIMPL that much (I have used it, but rarely) that we need std library support (and testing, documentation, understanding)? Just asking.

They didn't add PImpl support, they added std::indirect which can be used for PImpl among other things.

Re: The PImpl idiom and the C++26 std:indirect type

#9
post #5

Hmm. Do people use PIMPL that much (I have used it, but rarely) that we need std library support (and testing, documentation, understanding)? Just asking.

Back when I used to write C++ it was used all over the place. Admittedly that was a log time ago.

Re: The PImpl idiom and the C++26 std:indirect type

#10
post #5

Hmm. Do people use PIMPL that much (I have used it, but rarely) that we need std library support (and testing, documentation, understanding)? Just asking.

I remember using it all the time for the Windows headers because they pollutes the compilation unit like you wouldn't believe — the rule was to only include them in c/cpp files.
Post reply on HN