thoth@springs.cis.ufl.edu (Gilligan) (02/02/90)
If there is a known bug involving header/implementation mismatch (`const' .vs. no `const') with the Plex class under libg++-1.36.3, ignore me. Has anyone noticed a problem with the libg++-1.36.3 Plex generic class? I pulled the new libg++ off of prep a few days ago and installed it. I was recently using it with one of my own classes and I got an error (something like "argument list does not match in any class definition" ). After a good night's sleep I noticed that the prototypes in the .h file were different from the implementation in the .cc file to the tune of a `const' or two. What follows are my diffs to Plex that made it work. I've noticed that a lot of the classes have been sprouting `const's left and right. Good job! Koenig said that this was one of the things that no one tells you, but is almost necessary for good code. Someone may want to check the rest of the classes for missing `const's (header and code mismatch that is). *** Plex.ccP Fri Dec 1 08:24:10 1989 --- /local/lib/gnu/g++-include/Plex.ccP Fri Feb 2 09:16:30 1990 *************** *** 153,164 **** } ! void <T>Plex::fill(<T&> x) { for (int i = lo; i < fnc; ++i) (*this)[i] = x; } ! void <T>Plex::fill(<T&> x, int lo, int hi) { for (int i = lo; i <= hi; ++i) (*this)[i] = x; } --- 153,164 ---- } ! void <T>Plex::fill(const <T&> x) { for (int i = lo; i < fnc; ++i) (*this)[i] = x; } ! void <T>Plex::fill(const <T&> x, int lo, int hi) { for (int i = lo; i <= hi; ++i) (*this)[i] = x; } -- ( My name's not really Gilligan, It's Robert Forsman, without an `e' )
dl@G.OSWEGO.EDU (Doug Lea) (02/03/90)
Thanks. `fill' was mismatched in all the *Plex files. Sorry. Fixed for next release. > I've noticed that a lot of the classes have been sprouting `const's > left and right. Good job! Koenig said that this was one of the > things that no one tells you, but is almost necessary for good code. > Someone may want to check the rest of the classes for missing `const's > (header and code mismatch that is). Most libg++ classes have been thoroughly const-ified. Occasionally this creates anomolies in order to be sufficiently conservative. For example, you cannot perform s.before("x") for a const String s, since the resulting SubString might modify s. This is true even if you only want to read, not change the SubString. There are several other such cases. -Doug