4141#include < hydra/detail/utility/Utility_Tuple.h>
4242#include < hydra/detail/base_functor.h>
4343#include < hydra/detail/Constant.h>
44- #include < hydra/detail/CompositeBase .h>
44+ #include < hydra/Complex .h>
4545#include < hydra/detail/FunctorTraits.h>
46- #include < hydra/detail/CompositeTraits.h>
4746#include < hydra/Parameter.h>
4847#include < hydra/Tuple.h>
48+ #include < hydra/detail/BaseCompositeFunctor.h>
49+ #include < hydra/detail/TupleUtility.h>
50+ #include < hydra/detail/TupleTraits.h>
4951
5052namespace hydra {
5153
5254
5355template <typename F1, typename F2 >
54- class Divide : public detail ::CompositeBase<F1, F2>
56+ class Divide : public BaseCompositeFunctor <
57+ Divide<F1, F2>,
58+ hydra_thrust::tuple<F1, F2>,
59+ typename detail::merged_tuple<
60+ hydra_thrust::tuple< decltype ( std::declval<typename F1::return_type>()/std::declval<typename F2::return_type>() )>,
61+ typename detail::stripped_tuple<
62+ typename detail::merged_tuple<
63+ typename F1::argument_type,
64+ typename F2::argument_type
65+ >::type
66+ >::type
67+ >::type
68+ >
5569{
70+
71+ typedef BaseCompositeFunctor<
72+ Divide<F1, F2>,
73+ hydra_thrust::tuple<F1, F2>,
74+ typename detail::merged_tuple<
75+ hydra_thrust::tuple< decltype ( std::declval<typename F1::return_type>()/std::declval<typename F2::return_type>() )>,
76+ typename detail::stripped_tuple<
77+ typename detail::merged_tuple<
78+ typename F1::argument_type,
79+ typename F2::argument_type
80+ >::type
81+ >::type
82+ >::type
83+ > super_type;
84+
5685public:
5786
58- // tag
59- typedef typename detail::divide_result<typename F1::return_type,
60- typename F2::return_type >::type return_type;
6187
6288 Divide () = delete ;
6389
6490 Divide (F1 const & f1, F2 const & f2):
65- detail::CompositeBase<F1, F2> ( f1, f2)
91+ super_type ( f1, f2)
6692 { }
6793
6894 __hydra_host__ __hydra_device__
6995 Divide (Divide<F1,F2> const & other):
70- detail::CompositeBase<F1, F2> ( other )
96+ super_type ( other )
7197 { }
7298
7399 __hydra_host__ __hydra_device__
74100 Divide<F1,F2>& operator =(Divide<F1,F2> const & other)
75101 {
76102 if (this ==&other) return *this ;
77- detail::CompositeBase< F1, F2> ::operator =( other);
103+ super_type ::operator =( other);
78104 return *this ;
79105 }
80106
81- template <typename T1 >
107+ template <typename ...T >
82108 __hydra_host__ __hydra_device__ inline
83- return_type operator ()(T1&& t ) const
109+ typename super_type:: return_type Evaluate (T... x ) const
84110 {
85- return hydra_thrust::get<0 >(this ->GetFunctors ())(t) /hydra_thrust::get<1 >(this ->GetFunctors ())(t );
111+ return hydra_thrust::get<0 >(this ->GetFunctors ())( hydra::tie (x...) ) /hydra_thrust::get<1 >(this ->GetFunctors ())( hydra::tie (x...) );
86112 }
87113
88114
@@ -91,8 +117,8 @@ class Divide: public detail::CompositeBase<F1, F2>
91117// divide: / operator two functors
92118template <typename T1, typename T2>
93119inline typename std::enable_if<
94- (detail::is_hydra_functor<T1>::value || detail::is_hydra_lambda<T1>::value || detail::is_hydra_composite_functor<T1>::value ) &&
95- (detail::is_hydra_functor<T2>::value || detail::is_hydra_lambda<T2>::value || detail::is_hydra_composite_functor<T2>::value ),
120+ (detail::is_hydra_functor<T1>::value || detail::is_hydra_lambda<T1>::value) &&
121+ (detail::is_hydra_functor<T2>::value || detail::is_hydra_lambda<T2>::value),
96122Divide<T1, T2> >::type
97123operator /(T1 const & F1, T2 const & F2)
98124{
@@ -101,7 +127,7 @@ operator/(T1 const& F1, T2 const& F2)
101127
102128template <typename T, typename U>
103129inline typename std::enable_if<
104- (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value || detail::is_hydra_composite_functor<T>::value ) &&
130+ (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value ) &&
105131(std::is_arithmetic<U>::value),
106132Divide< Constant<U>, T> >::type
107133operator /(U const cte, T const & F)
@@ -111,7 +137,7 @@ operator/(U const cte, T const& F)
111137
112138template <typename T, typename U>
113139inline typename std::enable_if<
114- (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value || detail::is_hydra_composite_functor<T>::value ) &&
140+ (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value ) &&
115141(std::is_arithmetic<U>::value),
116142Divide< Constant<U>, T> >::type
117143operator /( T const & F, U cte)
@@ -121,7 +147,7 @@ operator/( T const& F, U cte)
121147
122148template <typename T, typename U>
123149inline typename std::enable_if<
124- (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value || detail::is_hydra_composite_functor<T>::value ) &&
150+ (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value ) &&
125151(std::is_arithmetic<U>::value),
126152Divide< Constant<hydra::complex <U>>, T> >::type
127153operator /(hydra::complex <U> const & cte, T const & F)
@@ -131,7 +157,7 @@ operator/(hydra::complex<U> const& cte, T const& F)
131157
132158template <typename T, typename U>
133159inline typename std::enable_if<
134- (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value || detail::is_hydra_composite_functor<T>::value ) &&
160+ (detail::is_hydra_functor<T>::value || detail::is_hydra_lambda<T>::value ) &&
135161(std::is_arithmetic<U>::value),
136162Divide< Constant<hydra::complex <U>>, T> >::type
137163operator /( T const & F, hydra::complex <U> const & cte)
@@ -143,8 +169,8 @@ operator/( T const& F, hydra::complex<U> const& cte)
143169// Convenience function
144170template <typename F1, typename F2, typename ...Fs>
145171inline typename std::enable_if<
146- (detail::is_hydra_functor<F1>::value || detail::is_hydra_lambda<F1>::value || detail::is_hydra_composite_functor<F1>::value ) &&
147- (detail::is_hydra_functor<F2>::value || detail::is_hydra_lambda<F2>::value || detail::is_hydra_composite_functor<F2>::value ),
172+ (detail::is_hydra_functor<F1>::value || detail::is_hydra_lambda<F1>::value ) &&
173+ (detail::is_hydra_functor<F2>::value || detail::is_hydra_lambda<F2>::value ),
148174Divide<F1, F2>>::type
149175divide (F1 const & f1, F2 const & f2)
150176{
0 commit comments