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
-fno-inline
)std::move(MyStruct)
anywhere in the compiled code to meet the odr-used requirementMyStruct
has at least one parent class or a non-static member (recursively), with a non-trivial move constructor (e.g. an std::string
would suffice), or (easier)nm -C ... | grep 'MyStruct.*&&'
The result will imply whether the move constructor was generated or not.
As discussed in the question itself, this method didn't seem to work reliably, but after fixing the two issues that made it unreliable: inlining and triviality of the move constructor, it turned out to be a working method.
Whether the generated move constructor is implicitly or explicitly defaulted plays no role—whether the default is trivial or not is relevant: a trivial move (and copy) constructor will simply perform a byte-wise copy of the object.