Hi, 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. Kind regards and best wishes for 2007. Harald Devos. -------------------------------------------------------------------------- Harald Devos Electronics and Information Systems Department, Faculty of Engineering, Ghent University, St. Pietersnieuwstraat 41, O O B-9000 Ghent, Belgium O O work phone: +32-9-264.34.51 fax: +32-9-264.35.94 O email: hmdevos@elis.UGent.be
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.
Hi, 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 implementation. 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 const. Does this address your concerns?
Kind regards and best wishes for 2007.
Harald Devos.
David Fang Computer Systems Laboratory Electrical & Computer Engineering Cornell University http://www.csl.cornell.edu/~fang/ -- (2400 baud? Netscape 3.0?? lynx??? No problem!)
participants (2)
-
David Fang
-
Harald Devos