Question

I'm using Visual Studio 2010 sp1. with c++ and boost 1.47 in Windows 7

I have the following code:

typedef boost::variant<unsigned int,int,long,double,bool,string,istringstream,int32_t,
                                 uint32_t,int64_t,uint32_t,sql::SQLString> SQLVariant;

I have also try replacing istringstream for istream. I do get the following error :

Error   13  error C2249: 'std::basic_ios<_Elem,_Traits>::operator =' : 
no accessible path to private member declared in virtual base 'std::basic_ios<_Elem,_Traits>'
c:\program files (x86)\microsoft visual studio 10.0\vc\include\istream  860

If I declared istringstream i; I don't get the error. I do get similar error if I declare istream i2;

What am I doing wrong?

The reason that I need the istream or a derived class, it's for a sql library that I'm working on. In specific, for the mysql implementation I need a istream or istringstream to call setBlob...

I have found a temporary worked around, allowing to pass a string and the initializing the stringstream with the string. However, it will be nice if my variant type could take istreamstream or better yet, istream

Thanks, Frank

Was it helpful?

Solution

Quoting from Boost.Variant:

The requirements on a bounded type are as follows:

  • CopyConstructible [20.1.3].
  • Destructor upholds the no-throw exception-safety guarantee.
  • Complete at the point of variant template instantiation. (See boost::recursive_wrapper for a type wrapper that accepts incomplete types to enable recursive variant types.)

std::istringstream is not copy-constructible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top