00001
00002
00003 #ifndef TRIGBUNCHCROSSINGTOOL_BINARY_COMPOSE_H
00004 #define TRIGBUNCHCROSSINGTOOL_BINARY_COMPOSE_H
00005
00006 namespace Trig {
00007
00033 template< class BinaryFunction,
00034 class UnaryFunction1,
00035 class UnaryFunction2 >
00036 class binary_compose {
00037
00038 public:
00039 binary_compose( BinaryFunction bfn, UnaryFunction1 ufn1,
00040 UnaryFunction2 ufn2 )
00041 : m_bfn( bfn ), m_ufn1( ufn1 ), m_ufn2( ufn2 ) {}
00042
00043 typename BinaryFunction::result_type
00044 operator()( const typename UnaryFunction1::argument_type& x ) {
00045 return m_bfn( m_ufn1( x ), m_ufn2( x ) );
00046 }
00047
00048 private:
00049 BinaryFunction m_bfn;
00050 UnaryFunction1 m_ufn1;
00051 UnaryFunction2 m_ufn2;
00052 };
00053
00066 template< class BinaryFunction,
00067 class UnaryFunction1,
00068 class UnaryFunction2 >
00069 binary_compose< BinaryFunction, UnaryFunction1, UnaryFunction2 >
00070 compose2( BinaryFunction bfn, UnaryFunction1 ufn1, UnaryFunction2 ufn2 ) {
00071
00072 return binary_compose< BinaryFunction, UnaryFunction1,
00073 UnaryFunction2 >( bfn, ufn1, ufn2 );
00074 }
00075
00076 }
00077
00078 #endif // TRIGBUNCHCROSSINGTOOL_BINARY_COMPOSE_H