I want to use smart pointer in my c++ application.
Which header file I should include for using std scoped_ptr?
I want to use smart pointer in my c++ application.
Which header file I should include for using std scoped_ptr?
There is no scoped_ptr in the standard C++ library. All C++11 smart pointers are in header <memory>
. If you want boost::scoped_ptr then you need boost/scoped_ptr.hpp
.
There is no scoped_ptr
in the namespace std
.
You can either use boost::scoped_ptr
from boost.
Or I guess you wanted std::unique_ptr
.In this case you need to include <memory>
scoped_ptr
is a part of Boost library, not standard library.
© 2022 - 2024 — McMap. All rights reserved.
scoped_ptr
is not a standard smart pointer, it is provided by Boost. C++11 introducedstd::unique_ptr
, which is similar toscoped_ptr
with the exception that it is movable. As to the headers where these can be found, this information can very easily be found in the respective documentations. – Internalboost::scoped_ptr
andstd::unique_ptr
, see this question and this one. – Internalstd::tr1::scoped_ptr
– Joyjoya