I can't see any point to using the copy-and-swap idiom in C++11. If I need a handle, I can use unique_ptr or shared_ptr. If I need a collection of objects, I can just vector or string.
struct Relax
{
shared_ptr<Texture> resource;
public:
/* rest of stuff */
};
To me, the copy-and-swap idiom sounds like a pointless thought exercise full of bugs waiting to happen.
worry about exceptions
do I need to worry about self-assignment or not? premature optimization is the root of all evil
did I miss a place to call
swapsomewhere in my class's constructors?maybe I forgot a
deletesomewhere?
Let's say I have a compelling reason to use manual memory management. There's still allocators, swapping pointers, etc.
In modern C++, when would I need to do manual memory management (new, delete) w.r.t copy-and-swap?