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
This commit is contained in:
syntheticpp 2006-01-01 18:00:05 +00:00
parent 9bd1702def
commit a24fd38f7a

View file

@ -1332,15 +1332,30 @@ namespace Loki
{
template <class Fctor> struct BinderFirstTraits;
template<class T>
struct BinderFirstTraits
{
typedef typename TypeTraits<T>::ParameterType ByRefOrValue;
};
template <typename R, class TList, template <class> class ThreadingModel>
struct BinderFirstTraits< Functor<R, TList, ThreadingModel> >
{
typedef typename TL::Erase<TList,
typename TL::TypeAt<TList, 0>::Result>::Result
ParmList;
typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
typedef typename TL::Erase<TList,typename TL::TypeAt<TList, 0>::Result>
::Result
ParmList;
typedef typename TL::TypeAt<TList, 0>::Result OriginalParm1;
typedef Functor<R, ParmList, ThreadingModel> BoundFunctorType;
typedef typename BoundFunctorType::Impl Impl;
};
typedef typename TypeTraits<OriginalFunctor>::ReferredType ByRefOrValue;
};
}
////////////////////////////////////////////////////////////////////////////////
@ -1357,8 +1372,12 @@ namespace Loki
typedef typename Private::BinderFirstTraits<OriginalFunctor>::Impl Base;
typedef typename OriginalFunctor::ResultType ResultType;
typedef typename OriginalFunctor::Parm1 BoundType;
typedef typename Private::BinderFirstTraits<
typename Private::BinderFirstTraits<OriginalFunctor>
::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 <class Fctor>
typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
BindFirst(
const Fctor& fun,
typename Fctor::Parm1 bound)
const Fctor& fun,
typename Private::BinderFirstTraits<
typename Private::BinderFirstTraits<Fctor>
::OriginalParm1>
::ByRefOrValue bound)
{
typedef typename Private::BinderFirstTraits<Fctor>::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_