00001
00002
00003 #ifndef TRIGBUNCHCROSSINGTOOL_UNARY_COMPOSE_H
00004 #define TRIGBUNCHCROSSINGTOOL_UNARY_COMPOSE_H
00005
00006 namespace Trig {
00007
00030 template< class UnaryFunction1,
00031 class UnaryFunction2 >
00032 class unary_compose {
00033
00034 public:
00035 unary_compose( UnaryFunction1 ufn1, UnaryFunction2 ufn2 )
00036 : m_ufn1( ufn1 ), m_ufn2( ufn2 ) {}
00037
00038 typename UnaryFunction1::result_type
00039 operator()( const typename UnaryFunction2::argument_type& x ) {
00040 return m_ufn1( m_ufn2( x ) );
00041 }
00042
00043 private:
00044 UnaryFunction1 m_ufn1;
00045 UnaryFunction2 m_ufn2;
00046
00047 };
00048
00061 template< class UnaryFunction1,
00062 class UnaryFunction2 >
00063 unary_compose< UnaryFunction1, UnaryFunction2 >
00064 compose1( UnaryFunction1 ufn1, UnaryFunction2 ufn2 ) {
00065
00066 return unary_compose< UnaryFunction1,
00067 UnaryFunction2 >( ufn1, ufn2 );
00068 }
00069
00070 }
00071
00072 #endif // TRIGBUNCHCROSSINGTOOL_UNARY_COMPOSE_H