c++ - Inline ostringstream macro reloaded -


The question was for a macro in which the inline of objects to create the string Closing is allowed, Iostream-style

The answer was:

  #define SSTR (x) dynamic_cast & lt; Std :: Ostringstream & amp; & Gt; (\ (Std :: ostringstream). Seekp (0, std :: ios_base :: cur) & lt; x) \. .str ()  

use (of For example):

  std :: runtime_error (SSTR ("FooBar error: value" & lt; & lt; x & lt; "exceeds"  

It works well - with GCC It also compiles and runs under Visual C ++ 2005 but with the latter, all methods of Macro results are used in the empty string, and I'm quite disappointed as to why, and why it is to fix it. .? Unfortunately I do not have access to MSWC compiler to test.

In my previous experiences with Microsoft's tool, That's the definition of Microsoft language and the standards believe that some kind of guide (I've lost a lot of time on projects that Microsoft broke tradition with something in the form of CAM).

this Afso Looking at the status of S, I recommend experimenting with a series of trivial programs. Things like:

  std :: ostringstream (o) o.seekp (0, std: : Ios_base :: cur) & lt; "foo"; cout & lt; "test1:" & lt; o & lt; & lt; endl;  

or perhaps:

  std :: ostringstream () o; cout << "test2:"  

Try to see what works to stop working Then work from there with the problem.


Comments