Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inspecting STL containers in Visual Studio 2015

I'm running Visual Studio Enterprise 2015, version 14.0.23107.0 D14REL.

When debugging a C++ program I cannot see the contents of STL containers.

I've got the "Show raw structure of objects in variables windows" option unchecked (Tools->Options->Debugging->General).

Here's an example that illustrates the problem:

#include <list> #include <string> #include <vector>  int main() {     std::string string = "test";     std::vector<int> vector{ 4, 5, 6 };     std::list<std::string> list{ "one", "two", "three" };     return 0; } 

In the Locals or Watch windows I see the following:

list         [...]() vector       [...](...   (error)    0   (error)    0 string       {npos=4294967295}   (error)    0   (error)    0 

If I then check the "Show raw structure..." option, I can correctly drill down into the vector and string objects, but still not the list!

Is there another option that I've missed, or is this a genuine bug in VS?

like image 789
Graham Avatar asked Sep 18 '15 15:09

Graham


People also ask

Are STL containers passed by reference?

@BjörnPollex Yes! I forgot to mention that.

What do all STL containers define?

An STL container is a collection of objects of the same type (the elements). Container owns the elements. Creation and destruction is controlled by the container.

How are STL containers implemented in C++?

In C++, STL Unordered Associative Containers provide the unsorted versions of the associative container. Internally, unordered associative containers are implemented as hash table data structures.


1 Answers

I had a same problem.

You need to go into Tools->Options->Debugging->General and uncheck both "Use Managed Compability Mode" and "Use Native Compability Mode".

like image 148
Bogdan Mazurenko Avatar answered Oct 14 '22 23:10

Bogdan Mazurenko