Re: ostream, istream, and String^

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Peteroid" <peter_oliphant@xxxxxxx> wrote

>> Would you care to explain which error you see?
>
> The ones I indicated, both of which are something like 'no overload of
> '<<' or '>>' exists for String^".
>
That doesn't make sense. The operators you have provided are both matches.
Please do post the full error message (am I really the only one who reads
and understands compiler diagnostics *sigh*)

>>> I don't know what you're trying to achive, but the
>>> implementation looks quite pointless.
>
> Let me expalin it to you with code that does work. This code does work:
>
>>> ostream% operator <<( ostream% output, int value)
>>> {
>>> output << value ; //ok
>>> return output ;
>>> }
>
I don't even see how this would compile. Given you have included
iostream there's
std::basic_ostream<..>& std::basic_ostream<..>::operator <<( int )

The above "output << value" should therefore be ambigious. If
ostream is incomplete, the above call would be recursive. Anyway,
your implementation does not add any real value.

> This takes the output stream given as a parameter, uses ITS '<<' operator
> for 'int' and adds 'value' to the stream, and then returns the resulting
> stream. This is the standard way of doing streaming, such as when saving
> values serially to a file.
>
That's not quite correct.
output << value
looks for both member and non-member operators. Non-members in associated
namespaces (std for the above example) are considered. Therefore the
expression
is ambigious.

Can you give a full compilable example?

>>>the implementations recursively call themselves.
>
> The '<<' used in the implementation of the method is not the same '<<'
> this method defines.
>
I fail to see how overload resolution could find a better match.

> So my problem is because String^ does not have a natural overload of '<<'
> which is used to add it to streams. THAT is what I need, is a way to
> send/recieve String^'s through a stream (both directions). I'm guessing
> part of the problem is that String^ are both variable in length and
> mutable...
>
I've showed you to overloads that should work (I'm not quite sure about the
encoding and conversion, .NET Strings are Unicode while ostream is a
8-bit encoding)

BTW: .NET Strings are immutable. Therefore you should really use a reference
to a handle (String^%)

-hg


.



Relevant Pages

  • Re: ostream, istream, and String^
    ... > Would you care to explain which error you see? ... both of which are something like 'no overload of '<<' ... This takes the output stream given as a parameter, ... So my problem is because String^ does not have a natural overload of '<<' ...
    (microsoft.public.dotnet.languages.vc)
  • RE: Read a dataset from a stream
    ... You need to use DataSet.ReadXmloverload. ... Should you get an exception for valid XML, ... > Does anyone have a method up their sleeve to read a DataSet from a Stream? ... > I know I could rewrite the decrypted XML to the file system, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: sql xml bulkload error
    ... I agree there should be an overload for it - maybe I'm looking in the wrong ... You can load your XML string into the stream ... > load much, so there may not be an overload, but that is where I would look. ...
    (microsoft.public.dotnet.general)
  • Re: .NET to Delphi 7
    ... get it to work with Indy HTTP? ... From the VB code you posted, it looks like the server is expecting the file to be included as the payload of a POST request. ... If you want to receive the server's response in another stream, for instance, use the overload that takes a string and two streams as arguments, instead of the one I used above, which only takes one stream. ...
    (alt.comp.lang.borland-delphi)