I have several classes for which I wish to check whether a default move constructor is being generated. Is there a way to check this (be it a compile-time assertion, or parsing
Declare the special member functions you want to exist in MyStruct, but don't default the ones you want to check. Suppose you care about the move functions and also want to make sure that the move constructor is noexcept:
struct MyStruct {
MyStruct() = default;
MyStruct(const MyStruct&) = default;
MyStruct(MyStruct&&) noexcept; // no = default; here
MyStruct& operator=(const MyStruct&) = default;
MyStruct& operator=(MyStruct&&); // or here
};
Then explicitly default them, outside the class definition:
inline MyStruct::MyStruct(MyStruct&&) noexcept = default;
inline MyStruct& MyStruct::operator=(MyStruct&&) = default;
This triggers a compile-time error if the defaulted function would be implicitly defined as deleted.