Search code examples
c++constructorlanguage-lawyerdefaulted-functions

How to Check if a Constructor is Explicitly-Defaulted


For example:

struct X {
    X(){/***/}
    X(const int& ){/***/}
    X(      int&&){/***/}
    X(const X& ) = default;
    X(      X&&) = default;
    X& operator=(const X& ){/***/}
    X& operator=(      X&&){/***/}
};

Class X is not trivial and is not an aggregate.

Checking the source code of class X is not an option (although it is known which constructors and operators are available).


Solution

  • There is no trait in the library for this. It isn't possible to check with the help of the core language either.