简体   繁体   中英

std::vector visualizer doesn't work properly on std::vector<boost::variant>

The visual studio std::vector visualizer in the VS2008 autoexp.dat file doesn't seem to work if I have a std::vector<boost::variant<...>> . It does work on other types of vectors I have tried (eg std::vector<int> , std::vector<boost::shared_ptr<..>> )

Here is the visualizer code:

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
        ),
        ")"
    )

)
}

Instead of showing the number of items and the item values, the preview shows

{_Myfirst= _Mylast= _Myend= }

And the children, which should be the vector items, are the actual vector members. It's as if the std::vector visualizer didn't exist.

I took a screenshot of the watch window. You can see how it displays the std::vector<boost::variant<int, std::string>> wrong, and then displays the next two vectors correctly: Hyperlink to screenshot

Does anyone know what is causing this and how to stop it happening?

Thanks!

It seems to be a bug related to the size of the name of your type... boost::variant generates types with very long names.

I've made some tests, and it seems that the limit is a struct with name size of 497 characters. The following code reproduces the error... take the last character of the struct name, and it works fine!

struct abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopqrstuvwxyz012345abcdefghijklmnopq
{
};

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

    test2.resize(10);

    return 0;
}

Feel free to report the bug on http://connect.microsoft.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM