I guess this is embarrassing if I told you I cant get this to compile. would you please help me:
using namespace std;
std::unique_ptr<int> p1(new int(5));
$ gcc main.cpp
main.cpp: In function ‘int main()’:
main.cpp:6:2: error: ‘unique_ptr’ was not declared in this scope
main.cpp:6:13: error: expected primary-expression before ‘int’
main.cpp:6:13: error: expected ‘;’ before ‘int’
$ gcc --version
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
This is just a guess.
Most likely you compiled your program like this (or similarly) :
If you did, then the problem is that g++ uses c++03 as default. To use c++11 features (and
std::unique_ptr), you need to use c++11:
and I would recommend to use also
-Wall -Wextra -pedantic.