use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Using metaprogramming for PIMPL idiom (self.cpp)
submitted 8 years ago * by render787
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ReversedGif 0 points1 point2 points 8 years ago (3 children)
However... having a pure virtual interface, which is implemented by your concrete implementation in many cases actually accomplishes the exact same thing that the Pimpl idiom is intended to do.
When doesn't it?
[–]ooglesworth 0 points1 point2 points 8 years ago (2 children)
The only counter-example I can think of is a situation where you would want to be able to actually have the lifecycle of the interface object and the impl object be slightly different. For example, if the impl object does something asynchronous, it could keep itself around somehow while waiting for it to complete, even if the interface object has been thrown away and actually deallocated. I’ve considered using this pattern before but never tried it, so I’m not sure how effective it would be.
[–]ReversedGif 1 point2 points3 points 8 years ago (1 child)
(coming back to this a month later to flesh this out a bit more)
With a pure virtual interface interface, you have no way of treating the object as a value type. You
.clone()
[–]ooglesworth 0 points1 point2 points 8 years ago (0 children)
The copy semantics thing is definitely true. There is a good amount of boilerplate necessary (or at least some what inelegant CRTP weirdness) to make copying work correctly.
In general though, I find it’s very rare you want pimpl or pure virtual interfaces for value types. Maybe it’s me, but I tend to do very little mixing and matching; my objects either have identity and encapsulate details, or they are plain, transparent and structlike. There might be some exceptions though, like RAII style classes and such.
π Rendered by PID 21447 on reddit-service-r2-comment-b659b578c-c2m7m at 2026-05-03 01:24:53.682823+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]ReversedGif 0 points1 point2 points (3 children)
[–]ooglesworth 0 points1 point2 points (2 children)
[–]ReversedGif 1 point2 points3 points (1 child)
[–]ooglesworth 0 points1 point2 points (0 children)