当struct / class不在函数中时:
#include <vector>
struct Foo { };
int main()
{
std::vector< Foo > foos;
return 0;
}
Visual Studio 2012的STL调试可视化工具处理foos
就好了:
Name Value Type
- foos { size=0 } std::vector<Foo,std::allocator<Foo> >
[size] 0 int
[capacity] 0 int
+ [Raw View] 0x0026fbcc {...} std::vector<Foo,std::allocator<Foo> > *
但是当Foo
位于main()
内时:
#include <vector>
int main()
{
struct Foo { };
std::vector< Foo > foos;
return 0;
}
调试器吐出垃圾(?)类型/值,看起来像名称错误严重错误:
Name Value Type
- foos {...} std::?$vector@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@
- std::?$_Vector_alloc@$0A@U?$_Vec_base_types@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@@std@@ {...} std::?$_Vector_alloc@$0A@U?$_Vec_base_types@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@@std@@
- std::?$_Vector_val@U?$_Simple_types@UFoo@?1?main@@std@@ {_Myfirst=0x00000000 {...} _Mylast=0x00000000 {...} _Myend=0x00000000 {...} } std::?$_Vector_val@U?$_Simple_types@UFoo@?1?main@@std@@
std::_Container_base0 {...} std::_Container_base0
_Myfirst 0x00000000 {...} main::__l2::Foo *
_Mylast 0x00000000 {...} main::__l2::Foo *
_Myend 0x00000000 {...} main::__l2::Foo *
两个问题:
Foo
外main()
”)