Where is shared_ptr?
There are at least three places where you may find shared_ptr
:
If your C++ implementation supports C++11 (or at least the C++11
shared_ptr
), thenstd::shared_ptr
will be defined in<memory>
.If your C++ implementation supports the C++ TR1 library extensions, then
std::tr1::shared_ptr
will likely be in<memory>
(Microsoft Visual C++) or<tr1/memory>
(g++'s libstdc++). Boost also provides a TR1 implementation that you can use.Otherwise, you can obtain the Boost libraries and use
boost::shared_ptr
, which can be found in<boost/shared_ptr.hpp>
.
Boost Getting Started
If you want to use it from Boost TR1 instead
shared_ptr Example