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:
parent
9bd1702def
commit
a24fd38f7a
1 changed files with 33 additions and 9 deletions
|
@ -1332,15 +1332,30 @@ namespace Loki
|
||||||
{
|
{
|
||||||
template <class Fctor> struct BinderFirstTraits;
|
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>
|
template <typename R, class TList, template <class> class ThreadingModel>
|
||||||
struct BinderFirstTraits< Functor<R, TList, ThreadingModel> >
|
struct BinderFirstTraits< Functor<R, TList, ThreadingModel> >
|
||||||
{
|
{
|
||||||
typedef typename TL::Erase<TList,
|
typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
|
||||||
typename TL::TypeAt<TList, 0>::Result>::Result
|
|
||||||
ParmList;
|
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 Functor<R, ParmList, ThreadingModel> BoundFunctorType;
|
||||||
|
|
||||||
typedef typename BoundFunctorType::Impl Impl;
|
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 Private::BinderFirstTraits<OriginalFunctor>::Impl Base;
|
||||||
typedef typename OriginalFunctor::ResultType ResultType;
|
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::Parm2 Parm1;
|
||||||
typedef typename OriginalFunctor::Parm3 Parm2;
|
typedef typename OriginalFunctor::Parm3 Parm2;
|
||||||
typedef typename OriginalFunctor::Parm4 Parm3;
|
typedef typename OriginalFunctor::Parm4 Parm3;
|
||||||
|
@ -1376,10 +1395,11 @@ namespace Loki
|
||||||
typedef EmptyType Parm15;
|
typedef EmptyType Parm15;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
BinderFirst(const OriginalFunctor& fun, BoundType bound)
|
BinderFirst(const OriginalFunctor& fun, BoundType bound)
|
||||||
: f_(fun), b_(bound)
|
: f_(fun), b_(bound)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
LOKI_DEFINE_CLONE_FUNCTORIMPL(BinderFirst)
|
LOKI_DEFINE_CLONE_FUNCTORIMPL(BinderFirst)
|
||||||
|
|
||||||
// operator() implementations for up to 15 arguments
|
// operator() implementations for up to 15 arguments
|
||||||
|
@ -1457,8 +1477,11 @@ namespace Loki
|
||||||
template <class Fctor>
|
template <class Fctor>
|
||||||
typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
||||||
BindFirst(
|
BindFirst(
|
||||||
const Fctor& fun,
|
const Fctor& fun,
|
||||||
typename Fctor::Parm1 bound)
|
typename Private::BinderFirstTraits<
|
||||||
|
typename Private::BinderFirstTraits<Fctor>
|
||||||
|
::OriginalParm1>
|
||||||
|
::ByRefOrValue bound)
|
||||||
{
|
{
|
||||||
typedef typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
typedef typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
||||||
Outgoing;
|
Outgoing;
|
||||||
|
@ -1621,6 +1644,7 @@ namespace Loki
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Change log:
|
// Change log:
|
||||||
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
// 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_
|
#endif // FUNCTOR_INC_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue