When designing a class that can be moved but not copied, it's natural to declare the copy constructor as private. When having only movable and trivially copyable objects as instance members, it makes sense to allow the compiler to implicitly generate the move constructor.
However, when supporting both VS11 and G++4.7 I found an incompatibility:
As you can see, this places me in a bit of a pickle. My class must not be copied. I must support both VS11 and MinGW / GCC. I need my class to be movable.
Have I misunderstood something, or is there a way around this tiny problem? Can I make compilation fail if a call to the copy constructor is generated? Any better solution to this problem?
If you add this to the source file
#ifdef _MSC_VER
#define noexcept
#endif
You will be able to define it as noexcept
on GCC but VC++ will ignore noexcept
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With