From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dale Gerdemann To: egcs-bugs@cygnus.com Subject: Bug report Date: Fri, 08 Jan 1999 02:22:00 -0000 Message-id: <3695CCA6.6C99EA39@sfs.nphil.uni-tuebingen.de> X-SW-Source: 1999-01/msg00182.html List-Id: Hello, I thought I found a bug in Bjarne Stroustrup's book, but he says it's a bug in your compiler. Here's the e-mail conversation I had with Bjarne: -------------------------- I think that the definition of rotate_all on p. 521 is not right. mem_fun should not be able to take &Shape::rotate as an argument since this is presumably of type void (Shape::*)(int), whereas mem_fun is looking for an argument of type R (T::*)(). I tested this out with gcc version egcs-2.91.57 19980901 (egcs-1.1 release) and I indeed got the following error: test.cc: In function `void rotate_all(class list > &, int)': test.cc:18: no matching function for call to `mem_fun (void (Shape::*)(int))' Here's the code I used: #include #include #include #include class Shape { private: int rotatedness; public: Shape(int i): rotatedness(i) {} void rotate(int angle) { rotatedness += angle; cout << "rotated by " << rotatedness << " degrees" << endl; } }; void rotate_all(list& ls, int angle) { for_each(ls.begin(), ls.end(),bind2nd(mem_fun(&Shape::rotate),angle)); } int main() { list lst; lst.push_back(new Shape(3)); rotate_all(lst,2); return 0; } ===> It seems that the EGCS library is a bit behind the standard and provides mem_fun1() rather than mem_fun(). - Bjarne Bjarne Stroustrup, AT&T Labs, http://www.research.att.com/~bs --------------------------------------------------------------------- Dale Gerdemann dg@sfs.nphil.uni-tuebingen.de Dept. of Linguistics +49 7071-29-74967 office Section for Computational Linguistics +49 7472-442298 home University of Tuebingen Fax: +49 7071-550520 Kl. Wilhelmstr. 113 D-72074 Tuebingen, Germany ---------------------------------------------------------------------