, id(tt.id)
, pointed_to_object_is_alive(false)
{
- if (tt.pointed_to_object_is_alive && t != nullptr)
- t->subscribe(&pointed_to_object_is_alive, id);
+ if (tt != nullptr)
+ {
+ Assert(tt.pointed_to_object_is_alive,
+ ExcMessage("You can't copy a smart pointer object that "
+ "is pointing to an object that is no longer alive."));
+ t->subscribe(&pointed_to_object_is_alive, id);
+ }
}
, id(tt.id)
, pointed_to_object_is_alive(false)
{
- if (tt.pointed_to_object_is_alive && t != nullptr)
- t->subscribe(&pointed_to_object_is_alive, id);
+ if (tt != nullptr)
+ {
+ Assert(tt.pointed_to_object_is_alive,
+ ExcMessage("You can't copy a smart pointer object that "
+ "is pointing to an object that is no longer alive."));
+ t->subscribe(&pointed_to_object_is_alive, id);
+ }
}
// Then reset to the new object, and subscribe to it
t = (tt != nullptr ? tt.get() : nullptr);
- if (tt.pointed_to_object_is_alive && tt != nullptr)
- t->subscribe(&pointed_to_object_is_alive, id);
+ if (tt != nullptr)
+ {
+ Assert(tt.pointed_to_object_is_alive,
+ ExcMessage("You can't copy a smart pointer object that "
+ "is pointing to an object that is no longer alive."));
+ t->subscribe(&pointed_to_object_is_alive, id);
+ }
return *this;
}
// Then reset to the new object, and subscribe to it
t = (tt != nullptr ? tt.get() : nullptr);
- if (tt.pointed_to_object_is_alive && tt != nullptr)
- t->subscribe(&pointed_to_object_is_alive, id);
-
+ if (tt != nullptr)
+ {
+ Assert(tt.pointed_to_object_is_alive,
+ ExcMessage("You can't copy a smart pointer object that "
+ "is pointing to an object that is no longer alive."));
+ t->subscribe(&pointed_to_object_is_alive, id);
+ }
return *this;
}