box2d icon indicating copy to clipboard operation
box2d copied to clipboard

Copyability of `b2World` and other classes

Open HolyBlackCat opened this issue 2 years ago • 1 comments

This is a rather minor issue.

I accidentally tried to copy an instance of b2World, and got a warning from Clang (from -Wdeprecated): b2_world.h:54:2: warning: definition of implicit copy constructor for 'b2World' is deprecated because it has a user-provided destructor [-Wdeprecated-copy-with-user-provided-dtor]

Is it supposed to be copyable? I think not, so the copy operations should be =deleted (or made private if you're supporting pre-C++11), but if yes, they should be =defaulted to silence the warning.

The same applies to all other classes with custom destructors.

If you agree with the fix, I can make a PR (I just need to know if I should target C++98 or >=C++11).

HolyBlackCat avatar Jan 08 '22 14:01 HolyBlackCat

Box2D was mostly written before C++11, but I have started adding some C++11 keywords when it makes sense. This seems like a good change. b2World is definitely not designed to be copied.

erincatto avatar Jan 16 '22 17:01 erincatto

Just b2World for now. #736

erincatto avatar Dec 25 '22 06:12 erincatto