Re: boost::variant and VC debugger



Thanks a lot for your help... As Jeff wrote, casting in the watch
window doesn't work. And even looking at the buffer itself, the data is
not easily readable.

One of the suggestions was that the debugger can evaluate some standard
functions so I decided to try a simple function that takes in input a
boost::variant and calls internally the boost::apply_visitor() method.

This solution seems to work ok-ish from the command window, even if the
watch window seems to evaluate the function only once (instead of
calling it again every time the object is modified). Which forces me to
use the command line to examine the value for the boost::variant.

Basically what i did was something on the lines:

typedef boost::variant<long, std::string> GcVariant;

class GcString: public boost::static_visitor<string>{
public:
string operator()(long i) const {
stringstream istr;
istr << i;
return istr.str();
}

string operator()( const string& i) const {
return i;
}
};

const char* SV( const GcVariant& p_variant) {
static string outputString;
outputString = boost::apply_visitor( GcString(), p_variant );
return outputString.c_str();
}

And if in the code i defined say:
GcVariant u;
u = "This is a string";
u = 234;
I can use the command window and type SV(u) and see the values "This is
a string" and "234".

One more question about the debugger ... if i define the function:
const std::string returnString() { return std::string("Test string"); }
and i try to evaluate it using the debugger i get a <Bad Ptr>. Does
this sound normal?

(this is the reason why i declare a static string in SV() and return
the c_str() that seems correctly handled by the debugger)
Thanks for your help!
gc

.



Relevant Pages

  • RE: debugger IDE hangs when stepping with properties in watch wind
    ... Thanks - but as I'm typically changing context with each step (from one ... adding and then removing items from the watch ... window before each step isn't really very helpful - basically, ... > watch window, it will cost debugger much time to resolve these variables, ...
    (microsoft.public.vsnet.debugging)
  • RE: VBScript debugger
    ... I understand that the debugger must be running to show the variables. ... cannot add anything to the watch window. ... > function/sub where that variable is used, to trace a function/sub use F8, or ...
    (microsoft.public.access.modulesdaovba)
  • Re: Is it possible to see the vtable from within VC6?
    ... > In the debugger you can see it in the Watch window... ... What is the proper name? ...
    (microsoft.public.vc.mfc)
  • Re: AppleWin Debugger & AppleWin Ports
    ... I found the single-screen debugger constraining at first ... do what I needed within the window. ... the command line/docs are a little too obtuse for it ... debugger and set a breakpoint at $300, switch back to the emulator and CALL ...
    (comp.emulators.apple2)
  • Re: Application.screenupdating always True?
    ... Application.Screenupdating can have no effect while single stepping - each step releases control to the OS, which will refresh every application window - and it is, in effect, True at every breakpoint. ... It seems possible that the Watch Window might be reflecting this - if you set a break on change it does break, and then breaks again after the next statement so it seems as though it might be getting a little confused. ... I wrote a test routine that set Screenupdating to false and then retested it then back to true 100 times - no break occurred; the question is essentially: if someone else has code that sets screenupdating to false and looks at the value in the watch pane while single stepping, do they see the value become false? ... Instead I try to use the Range object ...
    (microsoft.public.word.vba.general)

Loading