From a24fd38f7a5a8ea050af7e5a10565081718c0e2d Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Sun, 1 Jan 2006 18:00:05 +0000 Subject: [PATCH] pass Functor arguments in BindFirst by value, Peter Kmmel git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@389 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/Functor.h | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/include/loki/Functor.h b/include/loki/Functor.h index 18def96..c3f0726 100644 --- a/include/loki/Functor.h +++ b/include/loki/Functor.h @@ -1332,15 +1332,30 @@ namespace Loki { template struct BinderFirstTraits; + template + struct BinderFirstTraits + { + typedef typename TypeTraits::ParameterType ByRefOrValue; + }; + template class ThreadingModel> struct BinderFirstTraits< Functor > { - typedef typename TL::Erase::Result>::Result - ParmList; + typedef Functor OriginalFunctor; + + typedef typename TL::Erase::Result> + ::Result + ParmList; + + typedef typename TL::TypeAt::Result OriginalParm1; + typedef Functor BoundFunctorType; + typedef typename BoundFunctorType::Impl Impl; - }; + + typedef typename TypeTraits::ReferredType ByRefOrValue; + }; + } //////////////////////////////////////////////////////////////////////////////// @@ -1357,8 +1372,12 @@ namespace Loki typedef typename Private::BinderFirstTraits::Impl Base; typedef typename OriginalFunctor::ResultType ResultType; - typedef typename OriginalFunctor::Parm1 BoundType; - + typedef typename Private::BinderFirstTraits< + typename Private::BinderFirstTraits + ::OriginalParm1> + ::ByRefOrValue + BoundType; + typedef typename OriginalFunctor::Parm2 Parm1; typedef typename OriginalFunctor::Parm3 Parm2; typedef typename OriginalFunctor::Parm4 Parm3; @@ -1376,10 +1395,11 @@ namespace Loki typedef EmptyType Parm15; public: + BinderFirst(const OriginalFunctor& fun, BoundType bound) : f_(fun), b_(bound) {} - + LOKI_DEFINE_CLONE_FUNCTORIMPL(BinderFirst) // operator() implementations for up to 15 arguments @@ -1457,8 +1477,11 @@ namespace Loki template typename Private::BinderFirstTraits::BoundFunctorType BindFirst( - const Fctor& fun, - typename Fctor::Parm1 bound) + const Fctor& fun, + typename Private::BinderFirstTraits< + typename Private::BinderFirstTraits + ::OriginalParm1> + ::ByRefOrValue bound) { typedef typename Private::BinderFirstTraits::BoundFunctorType Outgoing; @@ -1621,6 +1644,7 @@ namespace Loki //////////////////////////////////////////////////////////////////////////////// // Change log: // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! +// January 1, 2006: pass Functor arguments in BindFirst by value, Peter Kümmel //////////////////////////////////////////////////////////////////////////////// #endif // FUNCTOR_INC_