This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

functional patch (cv propagation nightmare)


hi,
{unary,binary}_compose has the same defact as binder2nd (see:
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-active.html#109)
the attached patch correct this.
btw. _GLIBCPP_RESOLVE_LIB_DEFECTS is defined by default?

ps. IMHO it's not a defect neither this nor bind2nd. the whole problem
is based in the c++ cv propagation. non of the functional object
propagate the const, reference... cv. eg. why binder2nd use
const typename Operation::first_argument_type& 
as an argument? and why not (as the name suggest)
typename Operation::first_argument_type
and why not return always with result_type (see identity...)
the real defect in the mem_fun implementation.
boost people try to solve these with call_traits and friend, but from
here things are getting harder. unfortunately I can't solve my problem
without use boost, since on the result_type I have to propagate
const and reference, but on argument_type I'm not allowed (!!) to do
so. and here comes unary_compose which use first functor's result_type
as an agument_type for the second, but when it's an argument_type
it puts const argument_type& and here comes "the reference to reference
problem" (http://www.boost.org/libs/utility/call_traits.htm#refs):-(((
so there were hard hacking to be able to compile.
these are just my 2c.

 -- Levente                               "Si vis pacem para bellum!"
--- libstdc++-v3/include/bits/stl_function.h.lfarkas	Wed Oct  3 21:22:12 2001
+++ libstdc++-v3/include/bits/stl_function.h	Wed Oct  3 21:28:56 2001
@@ -475,6 +475,13 @@
   operator()(const typename _Operation2::argument_type& __x) const {
     return _M_fn1(_M_fn2(__x));
   }
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+  //same as 109.  Missing binders for non-const sequence elements
+  typename _Operation1::result_type
+  operator()(typename _Operation2::argument_type& __x) const {
+    return _M_fn1(_M_fn2(__x));
+  }
+#endif
 };
 
 /// An \link SGIextensions SGI extension \endlink.
@@ -502,6 +509,13 @@
   operator()(const typename _Operation2::argument_type& __x) const {
     return _M_fn1(_M_fn2(__x), _M_fn3(__x));
   }
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+  //same as 109.  Missing binders for non-const sequence elements
+  typename _Operation1::result_type
+  operator()(typename _Operation2::argument_type& __x) const {
+    return _M_fn1(_M_fn2(__x), _M_fn3(__x));
+  }
+#endif
 };
 
 /// An \link SGIextensions SGI extension \endlink.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]