Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2001-06-28 10:17:22


Hi,

I tried to add a new adapter: compose_f_gxy_hxy. This is a real helper
for me, I already use it several times. The code I have looks like this:

   // class for the compose_f_gxy_hxy adapter
   template< typename OP1, typename OP2, typename OP3 > class
compose_f_gxy_hxy_t
      : public std::binary_function< typename OP2::first_argument_type,
typename OP2::second_argument_type, typename OP1::result_type >
   {
   private:
      OP1 op1; // process: op1(op2(x,y),op3(x,y))
      OP2 op2;
      OP3 op3;
      
   public:
      // constructor
      compose_f_gxy_hxy_t( const OP1& o1, const OP2& o2, const OP3& o3 )
            : op1( o1 ), op2( o2 ), op3( o3 )
      {}

      // function call
      typename OP1::result_type
      operator()( const typename OP2::first_argument_type& x, const
typename OP2::second_argument_type& y ) const
      {
         return op1( op2( x, y ), op3( x, y ) );
      }
   };

   // convenience function for the compose_f_gxy_hxy adapter
   template< typename OP1, typename OP2, typename OP3 >
   inline compose_f_gxy_hxy_t< OP1, OP2, OP3 >
   compose_f_gxy_hxy( const OP1& o1, const OP2& o2, const OP3& o3 )
   {
      return compose_f_gxy_hxy_t< OP1, OP2, OP3 >( o1, o2, o3 );
   }

although it works for me, I'm not quite happy with it. I wonder if it's
a potential problem using OP2::first_argument_type and
OP2::second_argument_type and ignoring OP3's input parameter types.
operator() could be changed to a template function but this can't help
me when deriving from binary_function. Is there some clever solution I
can't see? Any comments are welcome...

Regards, Daniel

--
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

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