#include#include int main(){ Ref_Ptr ptr1(new int(10)); std::cout << "Value: " << *ptr1 << ", Reference Count: " << ptr1.GetRefCount() << std::endl; { Ref_Ptr ptr2 = ptr1; std::cout << "Value: " << *ptr2 << ", Reference Count: " << ptr2.GetRefCount() << std::endl; } std::cout << "Value: " << *ptr1 << ", Reference Count: " << ptr1.GetRefCount() << std::endl; ptr1.Release(); return 0; }
#includeIn this example, we create a vector of Ref_Ptr objects called `vec`. We then loop from 0 to 9 and create a new Ref_Ptr object with the integer value of `i` using the `emplace_back` function. We then loop through all the elements in `vec` and print out their values using the dereference operator. This example shows how we can use Ref_Ptr objects in containers like vectors. Package library: RefPtr#include #include int main(){ std::vector > vec; for(int i = 0; i < 10; i++){ vec.emplace_back(new int(i)); } for(auto& ref_ptr : vec){ std::cout << *ref_ptr << " "; } return 0; }