Introduction
The c++ (cpp) internal_ptr example is extracted from the most popular open source projects, you can refer to the following example for usage.
Programming language: C++ (Cpp)
Class/type: internal_ptr
Example#1File:
fake_unit_ptr.cppProject:
8680-wesnoth/wesnoth-fork-old
/**
* Resets the internal unit pointer to match the given pointer.
* The value of my_manager_ is preserved -- the old unit is deregistered,
* and the new unit is registered with the same manager.
*/
void fake_unit_ptr::reset(const internal_ptr & ptr)
{
if (unit_.get() != ptr.get()) {
fake_unit_manager * mgr = my_manager_;
remove_from_fake_unit_manager();
unit_ = ptr;
if (mgr)
place_on_fake_unit_manager(mgr);
}
}
Example#2File:
fake_unit_ptr.hppProject:
fluffbeast/wesnoth-old
explicit operator bool() const
{ return unit_.get() != nullptr; }