This is a follow-up to my previous question where I seem to have made the problem more involved than I had originally intended. (See discussions in question and answer comme
If a
is destroyed (whether by delete
or by falling out of scope), then t.~T()
is called, which is UB if t
isn't actually a T
(by not calling destruct
).
This doesn't apply if
T
is trivial, ordelete
U
is derived from T
, orAfter destruct
is called you are not allowed to use t
if T
has const
or reference members (until C++20).
Apart from that there is no restriction on what you do with the class as written as far as I can see.