Let's suppose I want to call an external function of my object to perform some checks inside the body constructor. Since the lifetime of an object begins when the constructor's body finishes its execution, is it an unsafe design?
struct A;
void check(A const&) { /* */ }
struct A
{
A() { check(*this); }
};
I mean, I'm calling and external function with a not-yet-alive object. Is it undefined behaviour?
Related questions: if I put that checking function as a member function (static or not), what does the standard says about using non-yet-alive objects outside the constructor but inside the class?
It there any difference in the lifetime concept between the point of view of a class and its users (a sort of in-class versus out-class lifetimes)?