40 #ifndef UNARYFUNCTION_HPP
41 #define UNARYFUNCTION_HPP 1
44 #include <boost/lambda/bind.hpp>
45 #include <boost/lambda/lambda.hpp>
153 template <
typename argument_type,
154 typename result_type,
157 :
public std::unary_function<argument_type, result_type> {
236 template <
class Functor>
238 :
public std::unary_function<typename Functor::argument_type,
239 typename Functor::result_type> {
243 typedef typename Functor::argument_type argument_type;
244 typedef typename Functor::result_type result_type;
331 template <
typename Functor,
class AttributeCopier,
332 template <
typename,
typename,
typename>
class FunctorWrapper
364 template <
class Vout,
class Vin>
365 Vout*
apply(
const Vin* v)
const;
397 template <
class AttributeCopier,
399 typename,
typename>
class FunctorWrapper,
401 static UnaryFunction<Functor, AttributeCopier, FunctorWrapper>
402 makeUnaryFunction(Functor f)
404 return UnaryFunction<AttributeCopier, Functor, FunctorWrapper>(f);
429 template <
class AttributeCopier,
typename Functor>
430 static UnaryFunction<Functor, AttributeCopier>
431 makeUnaryFunction(Functor f)
433 return UnaryFunction<Functor, AttributeCopier>(f);
441 template <
typename Functor,
class AttributeCopier,
442 template <
typename,
typename,
typename>
class FunctorWrapper>
443 template <
class Vout,
class Vin>
446 FunctorWrapper>::apply(
const Vin* v)
const
448 using namespace boost::lambda;
449 typedef typename Vin::value_type Inelt;
450 typedef typename Vout::value_type Outelt;
452 FunctorWrapper<Inelt, Outelt, Functor> fwrapper(m_f);
453 std::transform(v->begin(), v->end(), ans->begin(),
454 bind<Outelt>(var(fwrapper), _1));
456 AttributeCopier::copyAttributes(ans, v);
460 #endif // UNARYFUNCTION_HPP