[GiNaC-list] (const) ostream&
fang at csl.cornell.edu
Wed Dec 27 05:07:29 CET 2006
> the print functions declared in ginac/print.h
> all take "std::ostream &" as an argument.
> I wonder if this could be changed to
> "const std::ostream &". Else functions receiving
> a "const std::ostream &" (in any program using the GiNaC
> library) cause troubles when calling
> the print functions of the ginac library.
You might want to review how ostreams work. In general, the only
thing you can do with const ostreams is query state information. Almost
all useful work with ostreams (be it member function or out-of-class uses)
are modifiying (non-const), because 'writing' to an ostream changes its
state (consider what has to go on internally w.r.t. buffers). Take a look
at all the declarations in <iostream>, <iomanip>, etc... of your favorite
I'd venture a guess that receiving "const std::ostream&" is either
a mistake on the library writer's part, or that the implementation really
does honor the constness, in which case it is perfectly legal to pass a
non-const-reference argument to a const-reference parameter. To pass a
const-reference to a non-const-reference is an error -- you should not be
able to modify an ostream through a reference that was promised to be
Does this address your concerns?
> Kind regards and best wishes for 2007.
> Harald Devos.
Computer Systems Laboratory
Electrical & Computer Engineering
-- (2400 baud? Netscape 3.0?? lynx??? No problem!)
More information about the GiNaC-list