where did explicit come from?

S

Stephen Alpert

I've moved an ATL project (that uses STL) from VC6 to VC7. Of course, it won't
compile. In particular, the line

char *res = (char *)malloc( n );
ostrstream pout = ostrstream( res, n ); <<-- error here

now generates an error:

error C2558: class 'std::blush:strstream' : no copy constructor available or copy
constructor is declared 'explicit'

The relevant definition from <strstream> is:
....
_CRTIMP2 ostrstream(char *, streamsize,
ios_base::blush:penmode =
ios_base::blush:ut); // construct with static array


How do I fix this? Do I have to extend ostrstream and add my own constructor?
Am I misreading the error message?

/steveA
Steve Alpert
my email (e-mail address removed) is encrypted with ROT13 (www.rot13.org)
-------------------------------------------
NOTICE OF CONFIDENTIALITY
-------------------------------------------
The information in this email, including attachments, may be confidential
and/or privileged and may contain confidential health information. This
email is intended to be reviewed only by the individual or organization
named as addressee. If you have received this email in error please
notify IDX immediately--by return message to the sender or to
(e-mail address removed)--and destroy all copies of this message and any
attachments. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent
those of IDX. Confidential health information is protected by state and
federal law, including, but not limited to, the Health Insurance
Portability and Accountability Act of 1996 and related regulations.
 
H

Hendrik Schober

Stephen Alpert said:
I've moved an ATL project (that uses STL) from VC6 to VC7. Of course, it won't
compile. In particular, the line

char *res = (char *)malloc( n );
ostrstream pout = ostrstream( res, n ); <<-- error here

Do you really want to do this??
It creates a temporary unnamed 'ostrstream'
object and uses that to initialize 'pout'.
now generates an error:

error C2558: class 'std::blush:strstream' : no copy constructor available or copy
constructor is declared 'explicit'

While the compiler is allowed to eliminate
the temporary, the copy constructor is
required nevertheless.
The relevant definition from <strstream> is:
...
_CRTIMP2 ostrstream(char *, streamsize,
ios_base::blush:penmode =
ios_base::blush:ut); // construct with static array


How do I fix this? Do I have to extend ostrstream and add my own constructor?

Try this:
ostrstream pout( res, n );
Am I misreading the error message?

An 'explicit' is one way that would lead to
this error message. Here, it probably is the
missing copy ctor.
/steveA
Steve Alpert
[...]


Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough not to?"
Beth Orton
 
S

Stephen Alpert

Do you really want to do this??
It creates a temporary unnamed 'ostrstream'
object and uses that to initialize 'pout'.

....[stuff deleted]...

I found that
ostrstream pout( res, n );
worked just fine. I guess VC6 wasn't so picky!

thanks!
/steveA

Steve Alpert
my email (e-mail address removed) is encrypted with ROT13 (www.rot13.org)
-------------------------------------------
NOTICE OF CONFIDENTIALITY
-------------------------------------------
The information in this email, including attachments, may be confidential
and/or privileged and may contain confidential health information. This
email is intended to be reviewed only by the individual or organization
named as addressee. If you have received this email in error please
notify IDX immediately--by return message to the sender or to
(e-mail address removed)--and destroy all copies of this message and any
attachments. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent
those of IDX. Confidential health information is protected by state and
federal law, including, but not limited to, the Health Insurance
Portability and Accountability Act of 1996 and related regulations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top