Boost logo

Boost :

From: Thomas Witt (witt_at_[hidden])
Date: 2003-05-04 04:55:57


Hi,

I have to admit I am unable to remember the template argument ordering
on std::unary/binary_function each time I use it. The attached patch
adds the std typedefs for adaptable function objects to
boost::function_traits. The net effect is that the following declares a
adaptable function object:

struct my_functor :
   public boost::function_traits<int(double)>
{
  // ...
};

To me this syntax is a lot easier to remember and to read than

struct my_functor :
   public std::unary_function<double, int>
{
  // ...
};

Comments ?

Thomas

-- 
Dipl.-Ing. Thomas Witt
Institut fuer Verkehrswesen, Eisenbahnbau und -betrieb, Universitaet 
Hannover
voice: +49(0) 511 762 - 4273, fax: +49(0) 511 762-3001
http://www.ive.uni-hannover.de

Index: function_traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/type_traits/function_traits.hpp,v
retrieving revision 1.13
diff -u -r1.13 function_traits.hpp
--- function_traits.hpp 15 Sep 2002 22:13:19 -0000 1.13
+++ function_traits.hpp 4 May 2003 09:48:30 -0000
@@ -37,6 +37,7 @@
   BOOST_STATIC_CONSTANT(int, arity = 1);
   typedef R result_type;
   typedef T1 arg1_type;
+ typedef T1 argument_type;
 };
 
 template<typename R, typename T1, typename T2>
@@ -46,6 +47,8 @@
   typedef R result_type;
   typedef T1 arg1_type;
   typedef T2 arg2_type;
+ typedef T1 first_argument_type;
+ typedef T2 second_argument_type;
 };
 
 template<typename R, typename T1, typename T2, typename T3>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk