The PIMPL Idiom (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the public class is part of.
An "idiom" in (non-programming) language is a saying or expression which is unique to a particular language. Generally something which doesn't follow the "rules" of the langauge, and just exist because native speakers "just know" what it means. (for instance, in English we say "in line" but "out of line" -- that would be idiomatic)
51 There have been a few questions on SO about the pimpl idiom, but I'm more curious about how often it is leveraged in practice. I understand there are some trade-offs between performance and encapsulation, plus some debugging annoyances due to the extra redirection.
The PImpl idiom moves definition of the private members into the source and thus decouples the ABI from their definition. See Fragile Binary Interface Problem When a header changes, all sources including it have to be recompiled. And C++ compilation is rather slow.
I've used both, depending on what is in the existing code base---the pimpl idiom (originally called the Cheshire cat idiom, and predating Herb's description of it by at least 5 years) seems to have a longer history and be more widely used in C++, but otherwise, both work.
In other word, using this idiom, working with a resource means making a resource class to hold the resource and initialize resource at time of constructing the class object. Implicitly, it suggests the deallocation of the resource should happen symmetrically in the resource class destructor. How is this useful?
The remove-erase idiom The combination of std::remove and std::erase allows you to remove matching elements from the container so that container would actually get truncated if elements were removed.
The copy-and-swap idiom is a way to do just that: It first calls a class' copy constructor to create a temporary object, then swaps its data with the temporary's, and then lets the temporary's destructor destroy the old state. Since swap() is supposed to never fail, the only part which might fail is the copy-construction.