@@ -50,6 +50,169 @@ _FNAME_ (const T &rhs) {
5050 functors:: _FNAME_ < typename hook< T >::const_iterator, hook< T >::NA >()); \
5151}
5252
53+ #define RCPP_HONEY_GENERATE_BINARY_FUNCTION (_FNAME_, _FUNCTOR_ ) \
54+ template < typename T, typename T_ITER, typename T_RESULT, typename U, typename U_ITER, typename U_RESULT > \
55+ inline RcppHoney::binary_operator< T_ITER, U_ITER, \
56+ RcppHoney::functors:: _FUNCTOR_ < T_ITER, U_ITER, (T::NA || U::NA) >, \
57+ (T::NA || U::NA) \
58+ > \
59+ _FNAME_ (const RcppHoney::operand< T, T_ITER, T_RESULT > &lhs, \
60+ const RcppHoney::operand< U, U_ITER, U_RESULT > &rhs) { \
61+ \
62+ return RcppHoney::make_binary_operator< (T::NA || U::NA) >()( \
63+ lhs, rhs, \
64+ RcppHoney::functors:: _FUNCTOR_ < T_ITER, U_ITER, (T::NA || U::NA) >()); \
65+ } \
66+ \
67+ template < typename T, typename T_ITER, typename T_RESULT, typename U > \
68+ inline typename RcppHoney::traits::enable_if< RcppHoney::traits::is_primitive< U >::value, \
69+ RcppHoney::binary_operator< T_ITER, typename RcppHoney::scalar_operator< U >::const_iterator, \
70+ RcppHoney::functors:: _FUNCTOR_ < T_ITER, typename RcppHoney::scalar_operator< U >::const_iterator, T::NA >, \
71+ T::NA \
72+ > \
73+ >::type \
74+ _FNAME_ (const RcppHoney::operand< T, T_ITER, T_RESULT > &lhs, const U &rhs) { \
75+ return RcppHoney::make_binary_operator< T::NA >()(lhs, RcppHoney::make_scalar_operator ()(rhs), \
76+ RcppHoney::functors:: _FUNCTOR_ < T_ITER, typename RcppHoney::scalar_operator< U >::const_iterator, T::NA >());\
77+ } \
78+ \
79+ template < typename T, typename U, typename U_ITER, typename U_RESULT > \
80+ inline typename RcppHoney::traits::enable_if< RcppHoney::traits::is_primitive< T >::value, \
81+ RcppHoney::binary_operator< typename RcppHoney::scalar_operator< T >::const_iterator, U_ITER, \
82+ RcppHoney::functors:: _FUNCTOR_ < typename RcppHoney::scalar_operator< T >::const_iterator, U_ITER, U::NA >, \
83+ U::NA \
84+ > \
85+ >::type \
86+ _FNAME_ (const T &lhs, const RcppHoney::operand< U, U_ITER, U_RESULT > &rhs) { \
87+ return RcppHoney::make_binary_operator< U::NA >()(RcppHoney::make_scalar_operator ()(lhs), rhs, \
88+ RcppHoney::functors:: _FUNCTOR_ < typename RcppHoney::scalar_operator< T >::const_iterator, U_ITER, U::NA >());\
89+ } \
90+ \
91+ template < typename T, typename U > \
92+ inline typename RcppHoney::traits::enable_if< \
93+ (RcppHoney::hook< T >::value && RcppHoney::hook< U >::value), \
94+ RcppHoney::binary_operator< \
95+ typename RcppHoney::hook< T >::const_iterator, \
96+ typename RcppHoney::hook< U >::const_iterator, \
97+ RcppHoney::functors:: _FUNCTOR_ < \
98+ typename RcppHoney::hook< T >::const_iterator, \
99+ typename RcppHoney::hook< U >::const_iterator, \
100+ (RcppHoney::hook< T >::NA || RcppHoney::hook< U >::NA) \
101+ >, \
102+ (RcppHoney::hook< T >::NA || RcppHoney::hook< U >::NA) \
103+ > \
104+ >::type \
105+ _FNAME_ (const T &lhs, const U &rhs) { \
106+ return RcppHoney::make_binary_operator< (RcppHoney::hook< T >::NA || RcppHoney::hook< U >::NA) >()( \
107+ lhs, \
108+ rhs, \
109+ RcppHoney::functors:: _FUNCTOR_ < \
110+ typename RcppHoney::hook< T >::const_iterator, \
111+ typename RcppHoney::hook< U >::const_iterator, \
112+ (RcppHoney::hook< T >::NA || RcppHoney::hook< U >::NA) \
113+ >()); \
114+ } \
115+ \
116+ template < typename T, typename T_ITER, typename T_RESULT, typename U > \
117+ inline typename RcppHoney::traits::enable_if< RcppHoney::hook< U >::value, \
118+ RcppHoney::binary_operator< \
119+ T_ITER, \
120+ typename RcppHoney::hook< U >::const_iterator, \
121+ RcppHoney::functors:: _FUNCTOR_ < \
122+ T_ITER, \
123+ typename RcppHoney::hook< U >::const_iterator, \
124+ (T::NA || RcppHoney::hook< U >::NA) \
125+ >, \
126+ (T::NA || RcppHoney::hook< U >::NA) \
127+ > \
128+ >::type \
129+ _FNAME_ (const RcppHoney::operand< T, T_ITER, T_RESULT > &lhs, const U &rhs) { \
130+ return RcppHoney::make_binary_operator< (T::NA || RcppHoney::hook< U >::NA) >()( \
131+ lhs, \
132+ rhs, \
133+ RcppHoney::functors:: _FUNCTOR_ < \
134+ T_ITER, \
135+ typename RcppHoney::hook< U >::const_iterator, \
136+ (T::NA || RcppHoney::hook< U >::NA) \
137+ >()); \
138+ } \
139+ \
140+ template < typename T, typename U, typename U_ITER, typename U_RESULT > \
141+ inline typename RcppHoney::traits::enable_if< RcppHoney::hook< T >::value, \
142+ RcppHoney::binary_operator< \
143+ typename RcppHoney::hook< T >::const_iterator, \
144+ U_ITER, \
145+ RcppHoney::functors:: _FUNCTOR_ < \
146+ typename RcppHoney::hook< T >::const_iterator, \
147+ U_ITER, \
148+ (U::NA || RcppHoney::hook< T >::NA) \
149+ >, \
150+ (U::NA || RcppHoney::hook< T >::NA) \
151+ > \
152+ >::type \
153+ _FNAME_ (const T &lhs, const RcppHoney::operand< U, U_ITER, U_RESULT > &rhs) { \
154+ return RcppHoney::make_binary_operator< (U::NA || RcppHoney::hook< T >::NA) >()( \
155+ lhs, \
156+ rhs, \
157+ RcppHoney::functors:: _FUNCTOR_ < \
158+ typename RcppHoney::hook< T >::const_iterator, \
159+ U_ITER, \
160+ (U::NA || RcppHoney::hook< T >::NA) \
161+ >()); \
162+ } \
163+ \
164+ template < typename T, typename U > \
165+ inline typename RcppHoney::traits::enable_if< \
166+ RcppHoney::traits::is_primitive< T >::value \
167+ && RcppHoney::hook< U >::value, \
168+ RcppHoney::binary_operator< \
169+ typename RcppHoney::scalar_operator< T >::const_iterator, \
170+ typename RcppHoney::hook< U >::const_iterator, \
171+ RcppHoney::functors:: _FUNCTOR_ < \
172+ typename RcppHoney::scalar_operator< T >::const_iterator, \
173+ typename RcppHoney::hook< U >::const_iterator, \
174+ RcppHoney::hook< U >::NA \
175+ >, \
176+ RcppHoney::hook< U >::NA \
177+ > \
178+ >::type \
179+ _FNAME_ (const T &lhs, const U &rhs) { \
180+ return RcppHoney::make_binary_operator< RcppHoney::hook< U >::NA >()( \
181+ RcppHoney::make_scalar_operator ()(lhs), \
182+ rhs, \
183+ RcppHoney::functors:: _FUNCTOR_ < \
184+ typename RcppHoney::scalar_operator< T >::const_iterator, \
185+ typename RcppHoney::hook< U >::const_iterator, \
186+ RcppHoney::hook< U >::NA \
187+ >()); \
188+ } \
189+ \
190+ template < typename T, typename U > \
191+ inline typename RcppHoney::traits::enable_if< \
192+ RcppHoney::traits::is_primitive< U >::value \
193+ && RcppHoney::hook< T >::value, \
194+ RcppHoney::binary_operator< \
195+ typename RcppHoney::hook< T >::const_iterator, \
196+ typename RcppHoney::scalar_operator< U >::const_iterator, \
197+ RcppHoney::functors:: _FUNCTOR_ < \
198+ typename RcppHoney::hook< T >::const_iterator, \
199+ typename RcppHoney::scalar_operator< U >::const_iterator, \
200+ RcppHoney::hook< T >::NA \
201+ >, \
202+ RcppHoney::hook< T >::NA \
203+ > \
204+ >::type \
205+ _FNAME_ (const T &lhs, const U &rhs) { \
206+ return RcppHoney::make_binary_operator< RcppHoney::hook< T >::NA >()( \
207+ lhs, \
208+ RcppHoney::make_scalar_operator ()(rhs), \
209+ RcppHoney::functors:: _FUNCTOR_ < \
210+ typename RcppHoney::hook< T >::const_iterator, \
211+ typename RcppHoney::scalar_operator< U >::const_iterator, \
212+ RcppHoney::hook< T >::NA \
213+ >()); \
214+ }
215+
53216RCPP_HONEY_GENERATE_UNARY_FUNCTION (log)
54217RCPP_HONEY_GENERATE_UNARY_FUNCTION (exp)
55218RCPP_HONEY_GENERATE_UNARY_FUNCTION (sqrt)
@@ -84,6 +247,11 @@ RCPP_HONEY_GENERATE_UNARY_FUNCTION(trunc)
84247
85248
86249
250+
251+ RCPP_HONEY_GENERATE_BINARY_FUNCTION (pow, pow)
252+
253+
254+
87255// diff
88256template < typename T, typename T_ITER, typename T_RESULT >
89257unary_operator< T_ITER, functors::diff< T_ITER, T::NA >, T::NA >
0 commit comments