I'm trying to use C++11 feature on Mac OS X. I downloaded g++ 4.8.1 with port.
This is the test code.
class A
{
int x;
public:
A() {}
~A() {}
A(A& a) {}
A(int x) {this->x = x;}
int get() {return x;}
};
int main()
{
vector<unique_ptr<A>> v;
auto a = new A(10);
unique_ptr<A> pa(a);
v.push_back(move(pa)); // move(pa);
for (auto& i: v)
{
cout << i->get();
}
}
It compiles well under g++ 4.8, and I could debug it using gdb. Following this page, I could print out STL vectors using vector v
command.
However, with vector with unique_ptr, I got this error message in gdb.
Cannot perform pointer math on incomplete type "unique_ptr<A, std::default_delet
e<A> >", try casting to a known type, or void *.
What's the problem with it? How can I make unique_ptr complete type to get the content with gdb?
ADDED
I noticed that clang++ in Xcode 4.5 supports c++11 features, so the easiest way might be to use Xcode. I have some issue with command line though (lldb on xcode vs lldb on standalone)