17 #include <boost/call_traits.hpp> 22 namespace til {
namespace functor
27 template <
typename T >
28 struct Abs :
public std::unary_function<T,T>
30 typedef std::unary_function<T,T>
Base;
57 template <
typename T,
unsigned int D >
59 :
public std::unary_function<T,T>
61 typedef std::unary_function<T,T>
Base;
74 template <
typename T >
76 :
public std::unary_function<T,T>
78 typedef std::unary_function<T,T>
Base;
88 template <
typename T >
90 :
public std::unary_function<T,T>
92 typedef std::unary_function<T,T>
Base;
96 class InvalidArgument :
public std::exception {};
100 if (x == 0)
throw InvalidArgument();
106 template <
typename T >
108 :
public std::unary_function<T,T>
110 typedef std::unary_function<T,T>
Base;
121 template <
typename T >
123 :
public std::unary_function<T,T>
125 typedef std::unary_function<T,T>
Base;
135 template <
typename TTo,
typename TFrom >
137 :
public std::binary_function<TTo &, typename boost::call_traits<TFrom>::param_type, void>
139 typedef std::binary_function<TTo &, typename boost::call_traits<TFrom>::param_type,
void>
Base;
143 void operator()(first_argument_type x, second_argument_type y)
const { x = y; }
147 template <
typename TFrom >
150 Convertor(
typename boost::call_traits<TFrom>::param_type from) : m_from(from) {}
152 template <
typename TTo >
158 typename boost::call_traits<TFrom>::param_type
m_from;
162 template <
typename TTo,
typename TFrom >
164 :
public std::unary_function<typename boost::call_traits<TFrom>::param_type, TTo>
166 typedef std::unary_function<typename boost::call_traits<TFrom>::param_type,TTo>
Base;
185 template <
typename T >
187 :
public std::unary_function<T, typename deref<T>::type>
189 typedef std::unary_function<T, typename deref<T>::type>
Base;
199 template <
typename T1,
typename T2 >
201 :
public std::binary_function<typename boost::add_reference<T1>::type,typename boost::call_traits<T2>::param_type,void>
203 typedef std::binary_function<typename boost::add_reference<T1>::type,
typename boost::call_traits<T2>::param_type,
void>
Base;
207 result_type
operator()(first_argument_type x, second_argument_type y)
const 214 template <
typename T1,
typename T2 >
216 :
public std::binary_function<typename boost::add_reference<T1>::type,typename boost::call_traits<T2>::param_type,void>
218 typedef std::binary_function<typename boost::add_reference<T1>::type,
typename boost::call_traits<T2>::param_type,
void>
Base;
222 result_type
operator()(first_argument_type x, second_argument_type y)
const 229 template <
typename T1,
typename T2 >
231 :
public std::binary_function<typename boost::add_reference<T1>::type,typename boost::call_traits<T2>::param_type,void>
233 typedef std::binary_function<typename boost::add_reference<T1>::type,
typename boost::call_traits<T2>::param_type,
void>
Base;
237 result_type
operator()(first_argument_type x, second_argument_type y)
const 244 template <
typename T1,
typename T2 >
246 :
public std::binary_function<typename boost::add_reference<T1>::type,typename boost::call_traits<T2>::param_type,void>
248 typedef std::binary_function<typename boost::add_reference<T1>::type,
typename boost::call_traits<T2>::param_type,
void>
Base;
252 result_type
operator()(first_argument_type x, second_argument_type y)
const 262 template < typename T1, typename T2, typename TRes = typename combine<T1,T2>::type >
264 :
public std::binary_function<typename boost::call_traits<T1>::param_type, typename boost::call_traits<T2>::param_type, TRes>
266 typedef std::binary_function<typename boost::call_traits<T1>::param_type,
typename boost::call_traits<T2>::param_type, TRes>
Base;
270 result_type
operator()(first_argument_type x, second_argument_type y)
const 277 template < typename T1, typename T2, typename TRes = typename combine<T1,T2>::type >
279 :
public std::binary_function<typename boost::call_traits<T1>::param_type, typename boost::call_traits<T2>::param_type, TRes>
281 typedef std::binary_function<typename boost::call_traits<T1>::param_type,
typename boost::call_traits<T2>::param_type, TRes>
Base;
285 result_type
operator()(first_argument_type x, second_argument_type y)
const 292 template < typename T1, typename T2, typename TRes = typename combine<T1,T2>::type >
294 :
public std::binary_function<typename boost::call_traits<T1>::param_type, typename boost::call_traits<T2>::param_type, TRes>
296 typedef std::binary_function<typename boost::call_traits<T1>::param_type,
typename boost::call_traits<T2>::param_type, TRes>
Base;
300 result_type
operator()(first_argument_type x, second_argument_type y)
const 307 template < typename T1, typename T2, typename TRes = typename combine<T1,T2>::type >
309 :
public std::binary_function<typename boost::call_traits<T1>::param_type, typename boost::call_traits<T2>::param_type, TRes>
311 typedef std::binary_function<typename boost::call_traits<T1>::param_type,
typename boost::call_traits<T2>::param_type, TRes>
Base;
315 result_type
operator()(first_argument_type x, second_argument_type y)
const 323 template <
typename TFunctor,
typename T >
325 :
public std::binary_function<TFunctor, T, typename TFunctor::result_type>
327 typedef std::binary_function<TFunctor, T, typename TFunctor::result_type>
Base;
331 result_type
operator()(first_argument_type x, second_argument_type y)
const 338 template <
typename T >
340 :
public std::binary_function<typename boost::add_reference<T>::type,typename boost::call_traits<T>::param_type,void>
342 typedef std::binary_function<typename boost::add_reference<T>::type,
typename boost::call_traits<T>::param_type,
void>
Base;
346 result_type
operator()(first_argument_type x, second_argument_type y)
393 template <
typename TRes,
typename T1,
typename T2 >
394 inline TRes
add(T1 x, T2 y)
397 template <
typename TRes,
typename T1,
typename T2 >
398 inline TRes
sub(T1 x, T2 y)
401 template <
typename TRes,
typename T1,
typename T2 >
402 inline TRes
mul(T1 x, T2 y)
405 template <
typename TRes,
typename T1,
typename T2 >
406 inline TRes
div(T1 x, T2 y)
409 template <
typename TTo,
typename TFrom >
413 template <
typename TTo,
typename TFrom >
417 template <
typename T >
result_type operator()(first_argument_type x, second_argument_type y) const
Base::second_argument_type second_argument_type
std::unary_function< T, T > Base
Base::result_type result_type
Base::result_type result_type
void convert(TTo &x, const TFrom &y)
Base::first_argument_type first_argument_type
void sqrt(const TImage &in, TImage &out)
Base::result_type result_type
Base::result_type result_type
result_type operator()(argument_type x) const
Base::result_type result_type
Base::result_type result_type
result_type operator()(first_argument_type x, second_argument_type y) const
std::binary_function< typename boost::add_reference< T >::type, typename boost::call_traits< T >::param_type, void > Base
Base::first_argument_type first_argument_type
std::binary_function< typename boost::call_traits< T1 >::param_type, typename boost::call_traits< T2 >::param_type, TRes > Base
Base::result_type result_type
Base::second_argument_type second_argument_type
std::binary_function< TTo &, typename boost::call_traits< TFrom >::param_type, void > Base
Base::second_argument_type second_argument_type
Belongs to package Box Do not include directly, include til/Box.h instead.
Base::first_argument_type first_argument_type
Base::argument_type argument_type
In-place addition functor.
std::unary_function< T, T > Base
Base::result_type result_type
Base::second_argument_type second_argument_type
result_type operator()(first_argument_type x, second_argument_type y) const
boost::enable_if_c< std::numeric_limits< T1 >::is_specialized &&std::numeric_limits< T2 >::is_specialized >::type sub(T1 x, T2 y, T3 &z)
functor::Convertor< T > convert2(const T &from)
result_type operator()(first_argument_type x, second_argument_type y) const
Dereferenciation functor.
Base::result_type result_type
numeric_array< T, D > abs(const numeric_array< T, D > &a)
Absolute value, element-wise.
Base::second_argument_type second_argument_type
Base::argument_type argument_type
Two-step static class functor.
Base::first_argument_type first_argument_type
result_type operator()(argument_type x) const
Base::first_argument_type first_argument_type
std::binary_function< typename boost::call_traits< T1 >::param_type, typename boost::call_traits< T2 >::param_type, TRes > Base
Base::first_argument_type first_argument_type
Base::second_argument_type second_argument_type
In-place multiplication functor.
Base::argument_type argument_type
result_type operator()(argument_type x) const
Base::first_argument_type first_argument_type
Base::first_argument_type first_argument_type
std::binary_function< TFunctor, T, typename TFunctor::result_type > Base
std::unary_function< T, T > Base
Base::argument_type argument_type
result_type operator()(first_argument_type x, second_argument_type y) const
result_type operator()(argument_type x) const
Base::first_argument_type first_argument_type
boost::call_traits< TFrom >::param_type m_from
Base::argument_type argument_type
Convertor(typename boost::call_traits< TFrom >::param_type from)
Base::argument_type argument_type
Base::second_argument_type second_argument_type
result_type operator()(first_argument_type x, second_argument_type y) const
Base::second_argument_type second_argument_type
Base::second_argument_type second_argument_type
result_type operator()(first_argument_type x, second_argument_type y) const
In-place subtraction functor.
result_type operator()(argument_type x) const
std::binary_function< typename boost::add_reference< T1 >::type, typename boost::call_traits< T2 >::param_type, void > Base
Base::argument_type argument_type
Base::first_argument_type first_argument_type
boost::enable_if_c< std::numeric_limits< T1 >::is_specialized &&std::numeric_limits< T2 >::is_specialized >::type add(T1 x, T2 y, T3 &z)
The following functions are necessary for the coming functors.
Base::first_argument_type first_argument_type
Base::result_type result_type
result_type operator()(first_argument_type x, second_argument_type y)
Base::result_type result_type
std::unary_function< T, T > Base
std::binary_function< typename boost::add_reference< T1 >::type, typename boost::call_traits< T2 >::param_type, void > Base
Base::second_argument_type second_argument_type
std::unary_function< T, T > Base
result_type operator()(argument_type x) const
result_type operator()(argument_type x) const
Base::second_argument_type second_argument_type
Base::result_type result_type
std::binary_function< typename boost::add_reference< T1 >::type, typename boost::call_traits< T2 >::param_type, void > Base
std::unary_function< T, T > Base
Base::argument_type argument_type
Base::result_type result_type
void square(const TImage &in, TImage &out)
Base::result_type result_type
Base::result_type result_type
Base::result_type result_type
Base::result_type result_type
std::unary_function< typename boost::call_traits< TFrom >::param_type, TTo > Base
result_type operator()(argument_type x) const
boost::enable_if_c< std::numeric_limits< T1 >::is_specialized &&std::numeric_limits< T2 >::is_specialized >::type div(T1 x, T2 y, T3 &z)
void operator()(first_argument_type x, second_argument_type y) const
In-place division functor.
Base::result_type result_type
std::binary_function< typename boost::add_reference< T1 >::type, typename boost::call_traits< T2 >::param_type, void > Base
std::binary_function< typename boost::call_traits< T1 >::param_type, typename boost::call_traits< T2 >::param_type, TRes > Base
boost::enable_if_c< std::numeric_limits< T1 >::is_specialized &&std::numeric_limits< T2 >::is_specialized >::type mul(T1 x, T2 y, T3 &z)
std::binary_function< typename boost::call_traits< T1 >::param_type, typename boost::call_traits< T2 >::param_type, TRes > Base
result_type operator()(first_argument_type x, second_argument_type y) const
Base::result_type result_type
std::unary_function< T, typename deref< T >::type > Base
result_type operator()(first_argument_type x, second_argument_type y) const