why declare constrexpr constructors for classes with non-trivial destructors (e.g. unique_ptr, std::variant)
问题 As far as I understand (at least for c++14 ), a destructor cannot be constexpr if it is not trivial (implicit generated or =default ). What is the point of declaring constexpr constructors for structures with non-trivial destructors? struct X { int a_; constexpr X(int a) : a_{a} {} // constexpr ~X(){}; // Error dtor cannot be marked constexpr // ~X(){}; // causes error at y declaration: temporary of non-literal type ‘X’ // in a constant expression . }; template <int N> struct Y {}; int main()