Re: stringstream problems
This is a MIME GnuPG-signed message. If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.
The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
To open this message correctly you will need to install E-mail or Usenet
software that supports modern Internet standards.
--=_mimegpg-commodore.email-scan.com-6480-1274008409-0001
Content-Type: text/plain; format=flowed; charset="US-ASCII"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
Nick Keighley writes:
Hi,
I'm having problems with stringstream, specifically it won't compile
with Visual C++ 2008 Express. This may be a problem with CPPX, in
which case I'll go elsewhere (suggestions?). But is there an obvious
bug with this code?
#include <iostream>
#include <sstream>
class Lexer
{
public:
explicit Lexer (std::istream&);
~Lexer ();
private:
std::istream stream_;
};
Lexer::Lexer (std::istream& in_stream):
stream_(in_stream)
std::istream is not copyable. std::istream does not define a copy
constructor, or an assignment operator.
The diagnostic is:
c:\program files\microsoft visual studio 9.0\vc\include\istream(846) :
error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot
access private member declared in class
'std::basic_ios<_Elem,_Traits>'
1>
it sems to be claiming a bug in istream, which doesn't sound good...
I see no evidence of a bug. This is just one possible manifestation of an
undefined copy constructor or assignment operator.
Redefining your class member as a reference, "std::istream &stream_;" should
work, but keep in mind that your std::istringstream object you're using to
initialize this reference must exist as your Lexer object exists, in order
for this reference to remain valid.
--=_mimegpg-commodore.email-scan.com-6480-1274008409-0001
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEABECAAYFAkvv01kACgkQx9p3GYHlUOJadgCcCEzji7o0l3OLuT7IisCqNsyt
IvYAn1rtPJPoXMqJUQ+GJBWtu1Tluw6Z
=tvJx
-----END PGP SIGNATURE-----
--=_mimegpg-commodore.email-scan.com-6480-1274008409-0001--