[multiple changes]
authorPaolo Carlini <pcarlini@suse.de>
Fri, 17 Jun 2005 21:51:34 +0000 (21:51 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 17 Jun 2005 21:51:34 +0000 (21:51 +0000)
2005-06-17  Paolo Carlini  <pcarlini@suse.de>

        Port from libstdcxx_so_7-branch:
2005-01-12  Christopher Jefferson <chris@bubblescope.net>

* 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.

From-SVN: r101139

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_function.h
libstdc++-v3/testsuite/20_util/functional/binders/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/functional/binders/3113.cc [moved from libstdc++-v3/testsuite/20_util/functional/binders.cc with 100% similarity]

index 649c017..120ca4c 100644 (file)
@@ -1,3 +1,16 @@
+2005-06-17  Paolo Carlini  <pcarlini@suse.de>
+
+        Port from libstdcxx_so_7-branch:
+       2005-01-12  Christopher Jefferson <chris@bubblescope.net>
+
+       * 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  <redi@gcc.gnu.org>
 
        * docs/html/21_strings/gotw29a.txt: Update code to corrected version.
index fbd22c3..a6c60dc 100644 (file)
@@ -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 _Tp>
-    class mem_fun_t<void, _Tp> : 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 _Tp>
-    class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*, void>
-    {
-    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 _Tp>
-    class mem_fun_ref_t<void, _Tp> : 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 _Tp>
-    class const_mem_fun_ref_t<void, _Tp> : 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 _Tp, class _Arg>
-    class mem_fun1_t<void, _Tp, _Arg> : 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 _Tp, class _Arg>
-    class const_mem_fun1_t<void, _Tp, _Arg>
-    : public binary_function<const _Tp*, _Arg, void>
-    {
-    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 _Tp, class _Arg>
-    class mem_fun1_ref_t<void, _Tp, _Arg>
-    : 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 _Tp, class _Arg>
-    class const_mem_fun1_ref_t<void, _Tp, _Arg>
-    : 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 <class _Ret, class _Tp>
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 (file)
index 0000000..e8af653
--- /dev/null
@@ -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 <functional>
+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<void, s> p1(&s::f_void_void);
+  mem_fun_t<int, s> p2(&s::f_int_void);
+  p1(&a);
+  p2(&a);
+  mem_fun1_t<void, s, int> q1(&s::f_void_int);
+  mem_fun1_t<int, s, int> 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<void, s> ref1(&s::f_void_void);
+  mem_fun_ref_t<int, s> ref2(&s::f_int_void);
+
+  ref1(a);
+  ref2(a);
+
+  mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int);
+  mem_fun1_ref_t<int, s, int> 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<void, s> p1(&s::f_void_void_const);
+  const_mem_fun_t<int, s> p2(&s::f_int_void_const);
+  p1(&a);
+  p2(&a);
+  const_mem_fun1_t<void, s, int> q1(&s::f_void_int_const);
+  const_mem_fun1_t<int, s, int> 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<void, s> ref1(&s::f_void_void_const);
+  const_mem_fun_ref_t<int, s> ref2(&s::f_int_void_const);
+
+  ref1(a);
+  ref2(a);
+
+  const_mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int_const);
+  const_mem_fun1_ref_t<int, s, int> 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);
+}