std :: vector visualizer在std :: vector <boost :: variant> </boost :: variant>上无法正常工作

时间:2009-07-06 15:07:53

标签: c++ visual-studio boost debugging

如果我有一个std::vector<boost::variant<...>>,VS2008 autoexp.dat文件中的visual studio std :: vector visualizer似乎不起作用。它适用于我尝试过的其他类型的向量(例如std::vector<int>std::vector<boost::shared_ptr<..>>

以下是可视化代码:

std::vector<*>{
children
(
    #array
    (
        expr :      ($e._Myfirst)[$i],
        size :      $e._Mylast-$e._Myfirst
    )
)
preview
(
    #(
        "[", $e._Mylast - $e._Myfirst , "](",
        #array
        (
            expr :  ($e._Myfirst)[$i],
            size :  $e._Mylast-$e._Myfirst
        ),
        ")"
    )

)
}

预览显示

,而不是显示项目数和项目值
{_Myfirst= _Mylast= _Myend= }

应该是矢量项的子项是实际的矢量成员。就像std :: vector visualizer不存在一样。

我拍了一下观察窗的截图。您可以看到它显示std::vector<boost::variant<int, std::string>>错误的方式,然后正确显示下两个向量:Hyperlink to screenshot

有谁知道造成这种情况的原因以及如何阻止它发生?

谢谢!

1 个答案:

答案 0 :(得分:5)

这似乎是与您的类型名称大小相关的错误... boost :: variant生成名称很长的类型。

我做了一些测试,似乎限制是一个名称大小为497个字符的结构。下面的代码重现了错误...取结构名称的最后一个字符,它工作正常!

struct abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopq
{
};

int main()
{
    std::vector< abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopq > test2;

    test2.resize(10);

    return 0;
}

随时报告http://connect.microsoft.com/

上的错误