The only good solution here is to avoid this situation arising in the first place.
The situation typically arises when you have something on the general order of having to create an object where its initial value depends on some condition, so conceptually what you want is something on this general order:
if (xyz)
A a(123);
else
A a(456);
// code that uses A goes here
The problem in this case is that in this case, A
goes out of scope before you can use it. The cure is typically to divide this code up into two functions, so you end up with something like this:
if (xyz)
code_that_uses_A(123);
else
code_that_uses_A(456);
Although I certainly prefer to avoid it, there is another possibility that can be workable: a wrapper object that keeps track of whether the object it contains has been initialized or not. For example, it can contain a pointer to the actual object. This is initialized to a null pointer. When you initialize the object it contains, you allocate a contained object. Depending on what you want, attempting to re-initialize the container object could throw or it could just assign a new value to the contained object.
Of these two, the former is nearly always preferable. It tends to clean up the code and give each individual piece of code a single, clear responsibility. The latter can work, but generally requires quite a bit of work to get the wrapper object present a clean interface. Although I'd usually consider it a lesser concern, such a wrapper typically adds substantial overhead to using the wrapped object.