Sunday 15 August 2010

c++ - How to print out the content in vector with gdb on Mac OS X -


I'm trying to use the C ++ 11 feature on Mac OS X. I am downloading G ++ 4.8.1 with port ++.

This is the test code

  class A {int x; Public: A () {} A () {} A (A and A) {} A (int x) {it-> x = x;} int mill () {return x;}}; Int main () {Vector & lt; Unique_ptr & lt; A & gt; & Gt; V; Auto A = new A (10); Unique_ptr & lt; A & gt; Clean); V.push_back (move (pA)); // move (PA); (Auto & amp; i: v) {cout & lt; & Lt; I- & gt; (Get); }}   

It compiles well under G ++ 4.8, and I can debug it using GDB. Following, I can print STL vectors using the vector v command.

However, with vector of unique_ptr, I have received this error message in gdb

  Can not pointer the imperfect type" unique_ptr "on math, a, std :: default_delet e & lt; A & gt; & Gt; Try to cast the "known" type, or zero *.   

What's the problem with it? How can I create unique Pitter completely to get content with GDB? < / P>

added

I saw that Xcode 4.5 supports horn ++ C ++ 11 features, so Xcode can be the easiest way to use. There is a problem with the command line ()

Typer looks like nostalgic stuff:

Enter image details here

No comments:

Post a Comment