int main()
{
SafeReference<Room> room_ref1;
printf("&room_ref1 = %p\n", &room_ref1);
printf("\troom_ref1 valid: %d\n", room_ref1.IsValid());
{
printf("\nEntering sub-scope\n");
Room room;
printf("&room = %p\n", &room);
#ifdef DBG_SAFE_REF
room.DumpReferences();
#endif
room_ref1 = room.GetReference();
printf("\troom_ref1 valid: %d\n", room_ref1.IsValid());
if (room_ref1.IsValid()) printf("\tRef points to %p\n", room_ref1.GetObject());
#ifdef DBG_SAFE_REF
room.DumpReferences();
#endif
printf("\nAdding 2nd room ref\n");
SafeReference<Room> room_ref2 = room.GetReference();
printf("&room_ref2 = %p\n", &room_ref2);
printf("\troom_ref2 valid: %d\n", room_ref1.IsValid());
#ifdef DBG_SAFE_REF
room.DumpReferences();
#endif
printf("\nMoving references\n");
room_ref1 = std::move(room_ref2);
printf("\nLeaving sub-scope\n");
}
printf("\troom_ref1 valid: %d\n", room_ref1.IsValid());
return 0;
}