When I was reading constructors and destructors in unions, I came across a stack overflow question Is a Union Member's Destructor Called
The accepted answer for that question is saying that we need to provide the destructor for string object explicitly. But as for the accepted answer of Deleting string object in C++, we shouldn't delete the string object explicitly and when the string goes out of scope, it's destructor will be called automatically and the memory will be freed.
These 2 are contradicting. May I know how can we delete the string even if we need to? and also for which objects we need to delete explicitly?
As per the spec If any non-static data member of a union has a non-trivial default constructor (12.1), copy constructor (12.8), move constructor (12.8), copy assignment operator (12.8), move assignment operator (12.8), or destructor (12.4), the corresponding member function of the union must be user-provided or it will be implicitly deleted (8.4.3) for the union. But what is meant by non-trivial?