Boost logo

Boost Users :

From: Kevin Martin (kev82_at_[hidden])
Date: 2008-05-21 10:45:31


On 21 May 2008, at 15:28, Meir Yanovich wrote:

> when im doing *Foo::iStream << c <<".\n";
> im getting
> error C2100: illegal indirection

I think this code is roughly equivalent to what you're trying to do,
and it compiles with both g++ and icc. Test if you can compile this,
if so your problem is somewhere else.

#include <boost/shared_ptr.hpp>
#include <sstream>
#include <iostream>
#include <ostream>

class X
{
public:
     static boost::shared_ptr<std::ostringstream> x;
     static void init_stream();
};

boost::shared_ptr<std::ostringstream> X::x;

void X::init_stream() {
     boost::shared_ptr<std::ostringstream> temp(new std::ostringstream);
     x.swap(temp);
}

int main() {
     X::init_stream();

     *X::x << "Hello" << std::flush;

     std::cout << X::x->str() << std::endl;
     return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net