diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 649c017d8604..120ca4c5fb76 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2005-06-17 Paolo Carlini + + Port from libstdcxx_so_7-branch: + 2005-01-12 Christopher Jefferson + + * include/bits/stl_function.h (mem_fun_t, const_mem_fun_t, + mem_fun_ref_t, const_mem_fun_ref_t, mem_fun1_t, const_mem_fun1_t, + mem_fun1_ref_t, const_mem_fun1_ref_t): Remove overloads for void + return type, just an old HP/SGI workaround. + * testsuite/20_util/functional/binders.cc: Move to... + * testsuite/20_util/functional/binders/3113.cc: ...here. + * testsuite/20_util/functional/binders/1.cc: New. + 2005-06-17 Jonathan Wakely * docs/html/21_strings/gotw29a.txt: Update code to corrected version. diff --git a/libstdc++-v3/include/bits/stl_function.h b/libstdc++-v3/include/bits/stl_function.h index fbd22c3c8b5b..a6c60dc6342b 100644 --- a/libstdc++-v3/include/bits/stl_function.h +++ b/libstdc++-v3/include/bits/stl_function.h @@ -566,19 +566,11 @@ namespace std // 20.3.8 adaptors pointers members /** @defgroup s20_3_8_memadaptors Adaptors for pointers to members - * There are a total of 16 = 2^4 function objects in this family. + * There are a total of 8 = 2^3 function objects in this family. * (1) Member functions taking no arguments vs member functions taking * one argument. * (2) Call through pointer vs call through reference. - * (3) Member function with void return type vs member function with - * non-void return type. - * (4) Const vs non-const member function. - * - * Note that choice (3) is nothing more than a workaround: according - * to the draft, compilers should handle void and non-void the same way. - * This feature is not yet widely implemented, though. You can only use - * member functions returning void if your compiler supports partial - * specialization. + * (3) Const vs non-const member function. * * All of this complexity is in the function objects themselves. You can * ignore it by using the helper function mem_fun and mem_fun_ref, @@ -714,137 +706,6 @@ namespace std _Ret (_Tp::*_M_f)(_Arg) const; }; - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun_t : public unary_function<_Tp*, void> - { - public: - explicit - mem_fun_t(void (_Tp::*__pf)()) - : _M_f(__pf) {} - - void - operator()(_Tp* __p) const - { (__p->*_M_f)(); } - private: - void (_Tp::*_M_f)(); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun_t : public unary_function - { - public: - explicit - const_mem_fun_t(void (_Tp::*__pf)() const) - : _M_f(__pf) {} - - void - operator()(const _Tp* __p) const - { (__p->*_M_f)(); } - private: - void (_Tp::*_M_f)() const; - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun_ref_t : public unary_function<_Tp, void> - { - public: - explicit - mem_fun_ref_t(void (_Tp::*__pf)()) - : _M_f(__pf) {} - - void - operator()(_Tp& __r) const - { (__r.*_M_f)(); } - private: - void (_Tp::*_M_f)(); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun_ref_t : public unary_function<_Tp, void> - { - public: - explicit - const_mem_fun_ref_t(void (_Tp::*__pf)() const) - : _M_f(__pf) {} - - void - operator()(const _Tp& __r) const - { (__r.*_M_f)(); } - private: - void (_Tp::*_M_f)() const; - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun1_t : public binary_function<_Tp*, _Arg, void> - { - public: - explicit - mem_fun1_t(void (_Tp::*__pf)(_Arg)) - : _M_f(__pf) {} - - void - operator()(_Tp* __p, _Arg __x) const - { (__p->*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun1_t - : public binary_function - { - public: - explicit - const_mem_fun1_t(void (_Tp::*__pf)(_Arg) const) - : _M_f(__pf) {} - - void - operator()(const _Tp* __p, _Arg __x) const - { (__p->*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg) const; - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun1_ref_t - : public binary_function<_Tp, _Arg, void> - { - public: - explicit - mem_fun1_ref_t(void (_Tp::*__pf)(_Arg)) - : _M_f(__pf) {} - - void - operator()(_Tp& __r, _Arg __x) const - { (__r.*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun1_ref_t - : public binary_function<_Tp, _Arg, void> - { - public: - explicit - const_mem_fun1_ref_t(void (_Tp::*__pf)(_Arg) const) - : _M_f(__pf) {} - - void - operator()(const _Tp& __r, _Arg __x) const - { (__r.*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg) const; - }; - // Mem_fun adaptor helper functions. There are only two: // mem_fun and mem_fun_ref. template diff --git a/libstdc++-v3/testsuite/20_util/functional/binders/1.cc b/libstdc++-v3/testsuite/20_util/functional/binders/1.cc new file mode 100644 index 000000000000..e8af6533ec3e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/functional/binders/1.cc @@ -0,0 +1,104 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 20.3.6 Binders + +// { dg-do compile } + +#include +using namespace std; + +struct s +{ + void f_void_int_const(int) const {} + void f_void_int(int) {} + int f_int_int_const(int) const {} + int f_int_int(int) {} + void f_void_void_const() const {} + void f_void_void() {} + int f_int_void_const() const {} + int f_int_void() {} +}; + +void test01(s& a) +{ + mem_fun_t p1(&s::f_void_void); + mem_fun_t p2(&s::f_int_void); + p1(&a); + p2(&a); + mem_fun1_t q1(&s::f_void_int); + mem_fun1_t q2(&s::f_int_int); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void))(&a); + (mem_fun(&s::f_void_int))(&a,0); + (mem_fun(&s::f_int_void))(&a); + (mem_fun(&s::f_int_int))(&a,0); + + mem_fun_ref_t ref1(&s::f_void_void); + mem_fun_ref_t ref2(&s::f_int_void); + + ref1(a); + ref2(a); + + mem_fun1_ref_t ref3(&s::f_void_int); + mem_fun1_ref_t ref4(&s::f_int_int); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void))(a); + (mem_fun_ref(&s::f_void_int))(a, 0); + (mem_fun_ref(&s::f_int_void))(a); + (mem_fun_ref(&s::f_int_int))(a, 0); +} + +void test02(const s& a) +{ + const_mem_fun_t p1(&s::f_void_void_const); + const_mem_fun_t p2(&s::f_int_void_const); + p1(&a); + p2(&a); + const_mem_fun1_t q1(&s::f_void_int_const); + const_mem_fun1_t q2(&s::f_int_int_const); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void_const))(&a); + (mem_fun(&s::f_void_int_const))(&a, 0); + (mem_fun(&s::f_int_void_const))(&a); + (mem_fun(&s::f_int_int_const))(&a, 0); + + const_mem_fun_ref_t ref1(&s::f_void_void_const); + const_mem_fun_ref_t ref2(&s::f_int_void_const); + + ref1(a); + ref2(a); + + const_mem_fun1_ref_t ref3(&s::f_void_int_const); + const_mem_fun1_ref_t ref4(&s::f_int_int_const); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void_const))(a); + (mem_fun_ref(&s::f_void_int_const))(a, 0); + (mem_fun_ref(&s::f_int_void_const))(a); + (mem_fun_ref(&s::f_int_int_const))(a, 0); +} diff --git a/libstdc++-v3/testsuite/20_util/functional/binders.cc b/libstdc++-v3/testsuite/20_util/functional/binders/3113.cc similarity index 100% rename from libstdc++-v3/testsuite/20_util/functional/binders.cc rename to libstdc++-v3/testsuite/20_util/functional/binders/3113.cc