Which header should be used for using scoped_ptr
Asked Answered
F

3

5

I want to use smart pointer in my c++ application.

Which header file I should include for using std scoped_ptr?

Fellowship answered 23/7, 2012 at 12:10 Comment(7)
May I know the reason for vote downFellowship
scoped_ptr is not a standard smart pointer, it is provided by Boost. C++11 introduced std::unique_ptr, which is similar to scoped_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.Internal
I downvoted your question because it does not show any research effort: the StackOverflow users are not a replacement for documentation, where you could have found this information.Internal
For the differences between boost::scoped_ptr and std::unique_ptr, see this question and this one.Internal
@LucTouraille Please see this link link Here, something std::tr1::scoped_ptr is mentioned in Lloyd's answerFellowship
@Lloyd's answer is wrong, there is no std::tr1::scoped_ptrJoyjoya
@LucTouraille Actually, the boost docs don't explicitly say which header file to use: boost.org/doc/libs/1_55_0/libs/smart_ptr/scoped_ptr.htm - it's buried in example codeBritzka
K
6

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.

Koralle answered 23/7, 2012 at 12:14 Comment(0)
N
3

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>

Nipissing answered 23/7, 2012 at 12:15 Comment(0)
G
2

scoped_ptr is a part of Boost library, not standard library.

Gurglet answered 23/7, 2012 at 12:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.