With a static std::forward_list, the debugger only shows the 1’st element.
A non static std::forward_list or a static std::list works fine.
Is there any work around in the debugger I could use?
#include "stdafx.h"
#include <forward_list>
#include <list>
int _tmain(int argc, _TCHAR* argv[])
{
static std::forward_list<int> sfl;
sfl.push_front( 1 );
sfl.push_front( 2 );
std::forward_list<int> fl;
fl.push_front( 1 );
fl.push_front( 2 );
static std::list<int> sl;
sl.push_front( 1 );
sl.push_front( 2 );
//Break here.
//In a debugger watch window:
// 'sfl' only shows the '2' element
// 'fl' & 'sl' shows all elements.
return 0;
}
I believe this is a bug in Visual Studio’s debugger visualizer. The closest thing to a workaround I’ve come up with is to modify the
forward_listentry inautoexp.dat(normally found in%VSINSTALLDIR%\Common7\Packages\Debugger\)The file should have a section with the following:
Replace with:
This is not a great solution. It displays the children as
[actual 0], [0], [1], ...rather than[0], [1], [2], ..., i.e. elementxis labelled[x-1].You can however modify
autoexp.datwithout closing Visual Studio, you just need to restart the debugger. So I’d recommend using this hack for just as long as you need to debug a particular issue, and then revert back to the originalautoexp.dat.