2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// The Loki Library
|
|
|
|
// Copyright (c) 2001 by Andrei Alexandrescu
|
|
|
|
// This code accompanies the book:
|
2011-09-23 00:46:21 +00:00
|
|
|
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
2002-08-11 05:49:45 +00:00
|
|
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
2011-09-23 00:46:21 +00:00
|
|
|
//
|
|
|
|
// Code covered by the MIT License
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
// SOFTWARE.
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-09-26 07:33:05 +00:00
|
|
|
#ifndef LOKI_FUNCTOR_INC_
|
|
|
|
#define LOKI_FUNCTOR_INC_
|
2002-08-11 05:49:45 +00:00
|
|
|
|
2006-10-17 19:50:02 +00:00
|
|
|
// $Id$
|
|
|
|
|
2006-01-16 19:05:09 +00:00
|
|
|
|
2010-04-19 03:09:59 +00:00
|
|
|
#include <loki/Typelist.h>
|
|
|
|
#include <loki/Sequence.h>
|
|
|
|
#include <loki/EmptyType.h>
|
|
|
|
#include <loki/SmallObj.h>
|
|
|
|
#include <loki/TypeTraits.h>
|
2002-08-11 05:49:45 +00:00
|
|
|
#include <typeinfo>
|
|
|
|
#include <memory>
|
|
|
|
|
2005-11-03 12:43:55 +00:00
|
|
|
/// \defgroup FunctorGroup Function objects
|
|
|
|
|
2006-02-27 18:53:41 +00:00
|
|
|
#ifndef LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
|
|
|
|
//#define LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
|
|
|
|
#endif
|
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
#ifndef LOKI_FUNCTORS_ARE_COMPARABLE
|
|
|
|
//#define LOKI_FUNCTORS_ARE_COMPARABLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-03-08 18:22:42 +00:00
|
|
|
/// \namespace Loki
|
|
|
|
/// All classes of Loki are in the Loki namespace
|
2002-08-11 05:49:45 +00:00
|
|
|
namespace Loki
|
|
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl (internal)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
namespace Private
|
|
|
|
{
|
2006-01-22 13:31:45 +00:00
|
|
|
template <typename R, template <class, class> class ThreadingModel>
|
2011-09-23 00:46:21 +00:00
|
|
|
struct FunctorImplBase
|
2006-02-27 18:53:41 +00:00
|
|
|
#ifdef LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
|
2002-08-11 05:49:45 +00:00
|
|
|
{
|
2006-02-27 18:53:41 +00:00
|
|
|
#else
|
|
|
|
: public SmallValueObject<ThreadingModel>
|
|
|
|
{
|
|
|
|
inline FunctorImplBase() :
|
|
|
|
SmallValueObject<ThreadingModel>() {}
|
|
|
|
inline FunctorImplBase(const FunctorImplBase&) :
|
|
|
|
SmallValueObject<ThreadingModel>() {}
|
|
|
|
#endif
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
typedef R ResultType;
|
2006-06-01 12:33:05 +00:00
|
|
|
typedef FunctorImplBase<R, ThreadingModel> FunctorImplBaseType;
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
typedef EmptyType Parm1;
|
|
|
|
typedef EmptyType Parm2;
|
|
|
|
typedef EmptyType Parm3;
|
|
|
|
typedef EmptyType Parm4;
|
|
|
|
typedef EmptyType Parm5;
|
|
|
|
typedef EmptyType Parm6;
|
|
|
|
typedef EmptyType Parm7;
|
|
|
|
typedef EmptyType Parm8;
|
|
|
|
typedef EmptyType Parm9;
|
|
|
|
typedef EmptyType Parm10;
|
|
|
|
typedef EmptyType Parm11;
|
|
|
|
typedef EmptyType Parm12;
|
|
|
|
typedef EmptyType Parm13;
|
|
|
|
typedef EmptyType Parm14;
|
|
|
|
typedef EmptyType Parm15;
|
|
|
|
|
2006-02-27 18:53:41 +00:00
|
|
|
|
|
|
|
virtual ~FunctorImplBase()
|
|
|
|
{}
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
virtual FunctorImplBase* DoClone() const = 0;
|
2006-02-27 18:53:41 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
template <class U>
|
|
|
|
static U* Clone(U* pObj)
|
|
|
|
{
|
|
|
|
if (!pObj) return 0;
|
|
|
|
U* pClone = static_cast<U*>(pObj->DoClone());
|
|
|
|
assert(typeid(*pClone) == typeid(*pObj));
|
|
|
|
return pClone;
|
|
|
|
}
|
2006-06-01 12:33:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
|
|
|
|
|
|
|
virtual bool operator==(const FunctorImplBase&) const = 0;
|
2011-09-23 00:46:21 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
};
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-09-26 07:33:05 +00:00
|
|
|
// macro LOKI_DEFINE_CLONE_FUNCTORIMPL
|
2002-08-11 05:49:45 +00:00
|
|
|
// Implements the DoClone function for a functor implementation
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-09-26 07:33:05 +00:00
|
|
|
#define LOKI_DEFINE_CLONE_FUNCTORIMPL(Cls) \
|
2002-08-11 05:49:45 +00:00
|
|
|
virtual Cls* DoClone() const { return new Cls(*this); }
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// The base class for a hierarchy of functors. The FunctorImpl class is not used
|
|
|
|
// directly; rather, the Functor class manages and forwards to a pointer to
|
|
|
|
// FunctorImpl
|
|
|
|
// You may want to derive your own functors from FunctorImpl.
|
|
|
|
// Specializations of FunctorImpl for up to 15 parameters follow
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-23 00:46:21 +00:00
|
|
|
template <typename R, class TList,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
|
2002-08-11 05:49:45 +00:00
|
|
|
class FunctorImpl;
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 0 (zero) parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-01-22 13:31:45 +00:00
|
|
|
template <typename R, template <class, class> class ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
class FunctorImpl<R, NullType, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
virtual R operator()() = 0;
|
|
|
|
};
|
|
|
|
|
2005-10-30 14:03:23 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-10-30 13:49:44 +00:00
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 1 parameter
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-01-22 13:31:45 +00:00
|
|
|
template <typename R, typename P1, template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1>, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
virtual R operator()(Parm1) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 2 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-23 00:46:21 +00:00
|
|
|
template <typename R, typename P1, typename P2,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2>, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
virtual R operator()(Parm1, Parm2) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 3 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3>, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 4 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3, P4>, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 5 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3, P4, P5>, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 6 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6>, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 7 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7>, ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 8 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 9 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8, Parm9) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 10 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 11 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R,
|
|
|
|
Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 12 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R,
|
|
|
|
Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 13 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12, typename P13,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R,
|
|
|
|
Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
|
|
|
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 14 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12, typename P13, typename P14,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R,
|
|
|
|
Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
|
|
|
|
P14>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
|
|
|
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
|
|
|
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 15 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12, typename P13, typename P14,
|
2006-01-22 13:31:45 +00:00
|
|
|
typename P15, template <class, class> class ThreadingModel>
|
2005-10-30 13:49:44 +00:00
|
|
|
class FunctorImpl<R,
|
|
|
|
Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
|
|
|
|
P14, P15>,
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
|
|
|
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
|
|
|
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
|
|
|
typedef typename TypeTraits<P15>::ParameterType Parm15;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2005-10-30 13:49:44 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
|
|
|
|
Parm15) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 1 parameter
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-01-22 13:31:45 +00:00
|
|
|
template <typename R, typename P1, template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_1(P1), ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
virtual R operator()(Parm1) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 2 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-23 00:46:21 +00:00
|
|
|
template <typename R, typename P1, typename P2,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_2(P1, P2), ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
virtual R operator()(Parm1, Parm2) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 3 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_3(P1, P2, P3), ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 4 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_4(P1, P2, P3, P4), ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 5 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_5(P1, P2, P3, P4, P5), ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 6 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_6(P1, P2, P3, P4, P5, P6), ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 7 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_7(P1, P2, P3, P4, P5, P6, P7), ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 8 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_8(P1, P2, P3, P4, P5, P6, P7, P8),
|
2002-08-11 05:49:45 +00:00
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 9 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_9(P1, P2, P3, P4, P5, P6, P7, P8, P9),
|
2002-08-11 05:49:45 +00:00
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8, Parm9) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 10 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2005-09-26 07:33:05 +00:00
|
|
|
class FunctorImpl<R, LOKI_TYPELIST_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10),
|
2002-08-11 05:49:45 +00:00
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 11 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
class FunctorImpl<R,
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_TYPELIST_11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11),
|
2002-08-11 05:49:45 +00:00
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 12 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
class FunctorImpl<R,
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_TYPELIST_12(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12),
|
2002-08-11 05:49:45 +00:00
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 13 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12, typename P13,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
class FunctorImpl<R,
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_TYPELIST_13(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13),
|
2002-08-11 05:49:45 +00:00
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
|
|
|
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 14 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12, typename P13, typename P14,
|
2006-01-22 13:31:45 +00:00
|
|
|
template <class, class> class ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
class FunctorImpl<R,
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_TYPELIST_14(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
|
2002-08-11 05:49:45 +00:00
|
|
|
P14),
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
|
|
|
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
|
|
|
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorImpl
|
|
|
|
// Specialization for 15 parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4,
|
|
|
|
typename P5, typename P6, typename P7, typename P8, typename P9,
|
|
|
|
typename P10, typename P11, typename P12, typename P13, typename P14,
|
2006-01-22 13:31:45 +00:00
|
|
|
typename P15, template <class, class> class ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
class FunctorImpl<R,
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_TYPELIST_15(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
|
2002-08-11 05:49:45 +00:00
|
|
|
P14, P15),
|
|
|
|
ThreadingModel>
|
|
|
|
: public Private::FunctorImplBase<R, ThreadingModel>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef typename TypeTraits<P1>::ParameterType Parm1;
|
|
|
|
typedef typename TypeTraits<P2>::ParameterType Parm2;
|
|
|
|
typedef typename TypeTraits<P3>::ParameterType Parm3;
|
|
|
|
typedef typename TypeTraits<P4>::ParameterType Parm4;
|
|
|
|
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
|
|
|
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
|
|
|
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
|
|
|
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
|
|
|
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
|
|
|
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
|
|
|
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
|
|
|
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
|
|
|
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
|
|
|
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
|
|
|
typedef typename TypeTraits<P15>::ParameterType Parm15;
|
2011-09-23 00:46:21 +00:00
|
|
|
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
2002-08-11 05:49:45 +00:00
|
|
|
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
|
|
|
|
Parm15) = 0;
|
|
|
|
};
|
|
|
|
|
2005-10-30 13:49:44 +00:00
|
|
|
#endif //LOKI_DISABLE_TYPELIST_MACROS
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorHandler
|
|
|
|
// Wraps functors and pointers to functions
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <class ParentFunctor, typename Fun>
|
|
|
|
class FunctorHandler
|
|
|
|
: public ParentFunctor::Impl
|
|
|
|
{
|
|
|
|
typedef typename ParentFunctor::Impl Base;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef typename Base::ResultType ResultType;
|
|
|
|
typedef typename Base::Parm1 Parm1;
|
|
|
|
typedef typename Base::Parm2 Parm2;
|
|
|
|
typedef typename Base::Parm3 Parm3;
|
|
|
|
typedef typename Base::Parm4 Parm4;
|
|
|
|
typedef typename Base::Parm5 Parm5;
|
|
|
|
typedef typename Base::Parm6 Parm6;
|
|
|
|
typedef typename Base::Parm7 Parm7;
|
|
|
|
typedef typename Base::Parm8 Parm8;
|
|
|
|
typedef typename Base::Parm9 Parm9;
|
|
|
|
typedef typename Base::Parm10 Parm10;
|
|
|
|
typedef typename Base::Parm11 Parm11;
|
|
|
|
typedef typename Base::Parm12 Parm12;
|
|
|
|
typedef typename Base::Parm13 Parm13;
|
|
|
|
typedef typename Base::Parm14 Parm14;
|
|
|
|
typedef typename Base::Parm15 Parm15;
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
FunctorHandler(const Fun& fun) : f_(fun) {}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_DEFINE_CLONE_FUNCTORIMPL(FunctorHandler)
|
2002-08-11 05:49:45 +00:00
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
|
|
|
|
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
|
|
|
|
|
|
|
|
|
|
|
bool operator==(const typename Base::FunctorImplBaseType& rhs) const
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
// there is no static information if Functor holds a member function
|
2006-06-09 12:58:44 +00:00
|
|
|
// or a free function; this is the main difference to tr1::function
|
|
|
|
if(typeid(*this) != typeid(rhs))
|
|
|
|
return false; // cannot be equal
|
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
const FunctorHandler& fh = static_cast<const FunctorHandler&>(rhs);
|
|
|
|
// if this line gives a compiler error, you are using a function object.
|
|
|
|
// you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
|
|
|
|
return f_==fh.f_;
|
|
|
|
}
|
|
|
|
#endif
|
2002-08-11 05:49:45 +00:00
|
|
|
// operator() implementations for up to 15 arguments
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()()
|
|
|
|
{ return f_(); }
|
|
|
|
|
|
|
|
ResultType operator()(Parm1 p1)
|
|
|
|
{ return f_(p1); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2)
|
|
|
|
{ return f_(p1, p2); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
|
|
|
{ return f_(p1, p2, p3); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
|
|
|
{ return f_(p1, p2, p3, p4); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6, p7); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13)
|
|
|
|
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
2002-08-11 05:49:45 +00:00
|
|
|
p14);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
2002-08-11 05:49:45 +00:00
|
|
|
p14, p15);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
private:
|
|
|
|
Fun f_;
|
|
|
|
};
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// class template FunctorHandler
|
|
|
|
// Wraps pointers to member functions
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <class ParentFunctor, typename PointerToObj,
|
|
|
|
typename PointerToMemFn>
|
|
|
|
class MemFunHandler : public ParentFunctor::Impl
|
|
|
|
{
|
|
|
|
typedef typename ParentFunctor::Impl Base;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef typename Base::ResultType ResultType;
|
|
|
|
typedef typename Base::Parm1 Parm1;
|
|
|
|
typedef typename Base::Parm2 Parm2;
|
|
|
|
typedef typename Base::Parm3 Parm3;
|
|
|
|
typedef typename Base::Parm4 Parm4;
|
|
|
|
typedef typename Base::Parm5 Parm5;
|
|
|
|
typedef typename Base::Parm6 Parm6;
|
|
|
|
typedef typename Base::Parm7 Parm7;
|
|
|
|
typedef typename Base::Parm8 Parm8;
|
|
|
|
typedef typename Base::Parm9 Parm9;
|
|
|
|
typedef typename Base::Parm10 Parm10;
|
|
|
|
typedef typename Base::Parm11 Parm11;
|
|
|
|
typedef typename Base::Parm12 Parm12;
|
|
|
|
typedef typename Base::Parm13 Parm13;
|
|
|
|
typedef typename Base::Parm14 Parm14;
|
|
|
|
typedef typename Base::Parm15 Parm15;
|
|
|
|
|
2011-09-23 00:46:21 +00:00
|
|
|
MemFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn)
|
2002-08-11 05:49:45 +00:00
|
|
|
: pObj_(pObj), pMemFn_(pMemFn)
|
|
|
|
{}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_DEFINE_CLONE_FUNCTORIMPL(MemFunHandler)
|
2006-06-01 12:33:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
|
|
|
|
|
|
|
bool operator==(const typename Base::FunctorImplBaseType& rhs) const
|
|
|
|
{
|
2006-06-09 12:58:44 +00:00
|
|
|
if(typeid(*this) != typeid(rhs))
|
2011-09-23 00:46:21 +00:00
|
|
|
return false; // cannot be equal
|
2006-06-09 12:58:44 +00:00
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
const MemFunHandler& mfh = static_cast<const MemFunHandler&>(rhs);
|
|
|
|
// if this line gives a compiler error, you are using a function object.
|
|
|
|
// you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
|
|
|
|
return pObj_==mfh.pObj_ && pMemFn_==mfh.pMemFn_;
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
#endif
|
2006-06-01 12:33:05 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()()
|
|
|
|
{ return ((*pObj_).*pMemFn_)(); }
|
|
|
|
|
|
|
|
ResultType operator()(Parm1 p1)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
|
|
|
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
2002-08-11 05:49:45 +00:00
|
|
|
p11);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
2002-08-11 05:49:45 +00:00
|
|
|
p11, p12);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
2002-08-11 05:49:45 +00:00
|
|
|
p11, p12, p13);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
2002-08-11 05:49:45 +00:00
|
|
|
p11, p12, p13, p14);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
2002-08-11 05:49:45 +00:00
|
|
|
p11, p12, p13, p14, p15);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
private:
|
|
|
|
PointerToObj pObj_;
|
|
|
|
PointerToMemFn pMemFn_;
|
|
|
|
};
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2005-10-24 15:40:22 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TR1 exception
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef LOKI_ENABLE_FUNCTION
|
|
|
|
|
2005-10-30 14:03:23 +00:00
|
|
|
class bad_function_call : public std::runtime_error
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bad_function_call() : std::runtime_error("bad_function_call in Loki::Functor")
|
|
|
|
{}
|
|
|
|
};
|
2005-10-24 15:40:22 +00:00
|
|
|
|
|
|
|
#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL if(empty()) throw bad_function_call();
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2011-09-23 00:46:21 +00:00
|
|
|
#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2005-10-24 15:40:22 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-11-03 12:43:55 +00:00
|
|
|
/// \class Functor
|
|
|
|
///
|
|
|
|
/// \ingroup FunctorGroup
|
|
|
|
/// A generalized functor implementation with value semantics
|
2006-05-20 10:23:07 +00:00
|
|
|
///
|
|
|
|
/// \par Macro: LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
|
2011-09-23 00:46:21 +00:00
|
|
|
/// Define
|
2006-05-20 10:23:07 +00:00
|
|
|
/// \code LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT \endcode
|
2011-09-23 00:46:21 +00:00
|
|
|
/// to avoid static instantiation/delete
|
2006-05-20 10:23:07 +00:00
|
|
|
/// order problems.
|
|
|
|
/// It often helps against crashes when using static Functors and multi threading.
|
|
|
|
/// Defining also removes problems when unloading Dlls which hosts
|
|
|
|
/// static Functor objects.
|
2006-06-01 12:33:05 +00:00
|
|
|
///
|
|
|
|
/// \par Macro: LOKI_FUNCTORS_ARE_COMPARABLE
|
|
|
|
/// To enable the operator== define the macro
|
|
|
|
/// \code LOKI_FUNCTORS_ARE_COMPARABLE \endcode
|
2011-09-23 00:46:21 +00:00
|
|
|
/// The macro is disabled by default, because it breaks compiling functor
|
2006-06-01 12:33:05 +00:00
|
|
|
/// objects which have no operator== implemented, keep in mind when you enable
|
|
|
|
/// operator==.
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-11-01 11:11:52 +00:00
|
|
|
template <typename R = void, class TList = NullType,
|
2006-01-22 13:31:45 +00:00
|
|
|
template<class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
|
2002-08-11 05:49:45 +00:00
|
|
|
class Functor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Handy type definitions for the body type
|
|
|
|
typedef FunctorImpl<R, TList, ThreadingModel> Impl;
|
|
|
|
typedef R ResultType;
|
|
|
|
typedef TList ParmList;
|
|
|
|
typedef typename Impl::Parm1 Parm1;
|
|
|
|
typedef typename Impl::Parm2 Parm2;
|
|
|
|
typedef typename Impl::Parm3 Parm3;
|
|
|
|
typedef typename Impl::Parm4 Parm4;
|
|
|
|
typedef typename Impl::Parm5 Parm5;
|
|
|
|
typedef typename Impl::Parm6 Parm6;
|
|
|
|
typedef typename Impl::Parm7 Parm7;
|
|
|
|
typedef typename Impl::Parm8 Parm8;
|
|
|
|
typedef typename Impl::Parm9 Parm9;
|
|
|
|
typedef typename Impl::Parm10 Parm10;
|
|
|
|
typedef typename Impl::Parm11 Parm11;
|
|
|
|
typedef typename Impl::Parm12 Parm12;
|
|
|
|
typedef typename Impl::Parm13 Parm13;
|
|
|
|
typedef typename Impl::Parm14 Parm14;
|
|
|
|
typedef typename Impl::Parm15 Parm15;
|
|
|
|
|
|
|
|
// Member functions
|
|
|
|
|
|
|
|
Functor() : spImpl_(0)
|
|
|
|
{}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get()))
|
|
|
|
{}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
Functor(std::auto_ptr<Impl> spImpl) : spImpl_(spImpl)
|
|
|
|
{}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
template <typename Fun>
|
|
|
|
Functor(Fun fun)
|
|
|
|
: spImpl_(new FunctorHandler<Functor, Fun>(fun))
|
|
|
|
{}
|
|
|
|
|
|
|
|
template <class PtrObj, typename MemFn>
|
|
|
|
Functor(const PtrObj& p, MemFn memFn)
|
|
|
|
: spImpl_(new MemFunHandler<Functor, PtrObj, MemFn>(p, memFn))
|
|
|
|
{}
|
|
|
|
|
2003-02-03 11:54:05 +00:00
|
|
|
typedef Impl * (std::auto_ptr<Impl>::*unspecified_bool_type)() const;
|
2003-01-17 01:23:08 +00:00
|
|
|
|
|
|
|
operator unspecified_bool_type() const
|
2002-12-31 00:04:21 +00:00
|
|
|
{
|
2003-02-03 11:54:05 +00:00
|
|
|
return spImpl_.get() ? &std::auto_ptr<Impl>::get : 0;
|
2002-12-31 00:04:21 +00:00
|
|
|
}
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
Functor& operator=(const Functor& rhs)
|
|
|
|
{
|
|
|
|
Functor copy(rhs);
|
|
|
|
// swap auto_ptrs by hand
|
|
|
|
Impl* p = spImpl_.release();
|
|
|
|
spImpl_.reset(copy.spImpl_.release());
|
|
|
|
copy.spImpl_.reset(p);
|
|
|
|
return *this;
|
|
|
|
}
|
2005-10-24 15:40:22 +00:00
|
|
|
|
|
|
|
#ifdef LOKI_ENABLE_FUNCTION
|
|
|
|
|
2005-10-30 14:03:23 +00:00
|
|
|
bool empty() const
|
|
|
|
{
|
|
|
|
return spImpl_.get() == 0;
|
|
|
|
}
|
2005-10-24 15:40:22 +00:00
|
|
|
|
2005-10-30 14:03:23 +00:00
|
|
|
void clear()
|
|
|
|
{
|
|
|
|
spImpl_.reset(0);
|
|
|
|
}
|
2005-10-24 15:40:22 +00:00
|
|
|
#endif
|
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
|
|
|
|
|
|
|
bool operator==(const Functor& rhs) const
|
|
|
|
{
|
|
|
|
if(spImpl_.get()==0 && rhs.spImpl_.get()==0)
|
|
|
|
return true;
|
|
|
|
if(spImpl_.get()!=0 && rhs.spImpl_.get()!=0)
|
|
|
|
return *spImpl_.get() == *rhs.spImpl_.get();
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const Functor& rhs) const
|
|
|
|
{
|
|
|
|
return !(*this==rhs);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// operator() implementations for up to 15 arguments
|
|
|
|
|
2004-11-17 15:54:59 +00:00
|
|
|
ResultType operator()() const
|
2005-10-24 15:40:22 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)();
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2002-08-11 05:49:45 +00:00
|
|
|
|
2004-11-17 15:54:59 +00:00
|
|
|
ResultType operator()(Parm1 p1) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2004-11-17 15:54:59 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2004-11-17 15:54:59 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2004-11-17 15:54:59 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2004-11-17 15:54:59 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm6 p6) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm6 p6, Parm7 p7) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11) const
|
2011-09-23 00:46:21 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
|
2005-10-30 14:03:23 +00:00
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm12 p12) const
|
2002-08-11 05:49:45 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
2002-08-11 05:49:45 +00:00
|
|
|
p12);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm12 p12, Parm13 p13) const
|
2002-08-11 05:49:45 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2002-08-11 05:49:45 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
|
|
|
p12, p13);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14) const
|
2002-08-11 05:49:45 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
2002-08-11 05:49:45 +00:00
|
|
|
p12, p13, p14);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
2004-11-17 15:54:59 +00:00
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15) const
|
2002-08-11 05:49:45 +00:00
|
|
|
{
|
2005-10-30 14:03:23 +00:00
|
|
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
2011-09-23 00:46:21 +00:00
|
|
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
2002-08-11 05:49:45 +00:00
|
|
|
p12, p13, p14, p15);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::auto_ptr<Impl> spImpl_;
|
|
|
|
};
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2011-09-23 00:46:21 +00:00
|
|
|
//
|
|
|
|
// BindersFirst and Chainer
|
2006-06-01 12:33:05 +00:00
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
namespace Private
|
|
|
|
{
|
|
|
|
template <class Fctor> struct BinderFirstTraits;
|
|
|
|
|
2006-01-22 13:31:45 +00:00
|
|
|
template <typename R, class TList, template <class, class> class ThreadingModel>
|
2002-08-11 05:49:45 +00:00
|
|
|
struct BinderFirstTraits< Functor<R, TList, ThreadingModel> >
|
|
|
|
{
|
2006-01-01 18:00:05 +00:00
|
|
|
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;
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
typedef Functor<R, ParmList, ThreadingModel> BoundFunctorType;
|
2006-01-01 18:00:05 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
typedef typename BoundFunctorType::Impl Impl;
|
2006-01-01 18:00:05 +00:00
|
|
|
|
2011-09-23 00:46:21 +00:00
|
|
|
};
|
2006-01-01 18:00:05 +00:00
|
|
|
|
2006-01-02 08:36:51 +00:00
|
|
|
|
2006-01-09 07:27:01 +00:00
|
|
|
template<class T>
|
2006-01-02 08:36:51 +00:00
|
|
|
struct BinderFirstBoundTypeStorage;
|
|
|
|
|
2006-01-09 07:27:01 +00:00
|
|
|
template<class T>
|
2006-01-02 08:36:51 +00:00
|
|
|
struct BinderFirstBoundTypeStorage
|
|
|
|
{
|
|
|
|
typedef typename TypeTraits<T>::ParameterType RefOrValue;
|
|
|
|
};
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2006-01-22 13:31:45 +00:00
|
|
|
template <typename R, class TList, template <class, class> class ThreadingModel>
|
2006-01-02 08:36:51 +00:00
|
|
|
struct BinderFirstBoundTypeStorage< Functor<R, TList, ThreadingModel> >
|
|
|
|
{
|
2006-01-09 07:27:01 +00:00
|
|
|
typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
|
2006-01-02 10:43:22 +00:00
|
|
|
typedef const typename TypeTraits<OriginalFunctor>::ReferredType RefOrValue;
|
2011-09-23 00:46:21 +00:00
|
|
|
};
|
2006-01-02 08:36:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace Private
|
2002-08-11 05:49:45 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-11-03 12:43:55 +00:00
|
|
|
/// \class BinderFirst
|
2011-09-23 00:46:21 +00:00
|
|
|
///
|
2005-11-03 12:43:55 +00:00
|
|
|
/// \ingroup FunctorGroup
|
|
|
|
/// Binds the first parameter of a Functor object to a specific value
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <class OriginalFunctor>
|
2011-09-23 00:46:21 +00:00
|
|
|
class BinderFirst
|
2002-08-11 05:49:45 +00:00
|
|
|
: public Private::BinderFirstTraits<OriginalFunctor>::Impl
|
|
|
|
{
|
|
|
|
typedef typename Private::BinderFirstTraits<OriginalFunctor>::Impl Base;
|
|
|
|
typedef typename OriginalFunctor::ResultType ResultType;
|
|
|
|
|
2006-01-09 07:27:01 +00:00
|
|
|
typedef typename OriginalFunctor::Parm1 BoundType;
|
2006-01-02 08:36:51 +00:00
|
|
|
|
|
|
|
typedef typename Private::BinderFirstBoundTypeStorage<
|
2006-01-01 18:00:05 +00:00
|
|
|
typename Private::BinderFirstTraits<OriginalFunctor>
|
|
|
|
::OriginalParm1>
|
2006-01-02 08:36:51 +00:00
|
|
|
::RefOrValue
|
|
|
|
BoundTypeStorage;
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
typedef typename OriginalFunctor::Parm2 Parm1;
|
|
|
|
typedef typename OriginalFunctor::Parm3 Parm2;
|
|
|
|
typedef typename OriginalFunctor::Parm4 Parm3;
|
|
|
|
typedef typename OriginalFunctor::Parm5 Parm4;
|
|
|
|
typedef typename OriginalFunctor::Parm6 Parm5;
|
|
|
|
typedef typename OriginalFunctor::Parm7 Parm6;
|
|
|
|
typedef typename OriginalFunctor::Parm8 Parm7;
|
|
|
|
typedef typename OriginalFunctor::Parm9 Parm8;
|
|
|
|
typedef typename OriginalFunctor::Parm10 Parm9;
|
|
|
|
typedef typename OriginalFunctor::Parm11 Parm10;
|
|
|
|
typedef typename OriginalFunctor::Parm12 Parm11;
|
|
|
|
typedef typename OriginalFunctor::Parm13 Parm12;
|
|
|
|
typedef typename OriginalFunctor::Parm14 Parm13;
|
|
|
|
typedef typename OriginalFunctor::Parm15 Parm14;
|
|
|
|
typedef EmptyType Parm15;
|
|
|
|
|
|
|
|
public:
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
BinderFirst(const OriginalFunctor& fun, BoundType bound)
|
|
|
|
: f_(fun), b_(bound)
|
|
|
|
{}
|
2006-01-01 18:00:05 +00:00
|
|
|
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_DEFINE_CLONE_FUNCTORIMPL(BinderFirst)
|
2006-06-01 12:33:05 +00:00
|
|
|
|
|
|
|
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
bool operator==(const typename Base::FunctorImplBaseType& rhs) const
|
|
|
|
{
|
2006-06-09 12:58:44 +00:00
|
|
|
if(typeid(*this) != typeid(rhs))
|
2011-09-23 00:46:21 +00:00
|
|
|
return false; // cannot be equal
|
2006-06-01 12:33:05 +00:00
|
|
|
// if this line gives a compiler error, you are using a function object.
|
|
|
|
// you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
|
|
|
|
return f_ == ((static_cast<const BinderFirst&> (rhs)).f_) &&
|
|
|
|
b_ == ((static_cast<const BinderFirst&> (rhs)).b_);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
// operator() implementations for up to 15 arguments
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()()
|
|
|
|
{ return f_(b_); }
|
|
|
|
|
|
|
|
ResultType operator()(Parm1 p1)
|
|
|
|
{ return f_(b_, p1); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2)
|
|
|
|
{ return f_(b_, p1, p2); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
|
|
|
{ return f_(b_, p1, p2, p3); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13)
|
|
|
|
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
2002-08-11 05:49:45 +00:00
|
|
|
p14);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
private:
|
|
|
|
OriginalFunctor f_;
|
2006-01-02 08:36:51 +00:00
|
|
|
BoundTypeStorage b_;
|
2002-08-11 05:49:45 +00:00
|
|
|
};
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-11-03 12:43:55 +00:00
|
|
|
/// Binds the first parameter of a Functor object to a specific value
|
|
|
|
/// \ingroup FunctorGroup
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <class Fctor>
|
|
|
|
typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
|
|
|
BindFirst(
|
2011-09-23 00:46:21 +00:00
|
|
|
const Fctor& fun,
|
2006-01-09 07:27:01 +00:00
|
|
|
typename Fctor::Parm1 bound)
|
2002-08-11 05:49:45 +00:00
|
|
|
{
|
|
|
|
typedef typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
|
|
|
Outgoing;
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
return Outgoing(std::auto_ptr<typename Outgoing::Impl>(
|
|
|
|
new BinderFirst<Fctor>(fun, bound)));
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-11-03 12:43:55 +00:00
|
|
|
/// \class Chainer
|
|
|
|
///
|
|
|
|
/// \ingroup FunctorGroup
|
|
|
|
/// Chains two functor calls one after another
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename Fun1, typename Fun2>
|
|
|
|
class Chainer : public Fun2::Impl
|
|
|
|
{
|
|
|
|
typedef Fun2 Base;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef typename Base::ResultType ResultType;
|
|
|
|
typedef typename Base::Parm1 Parm1;
|
|
|
|
typedef typename Base::Parm2 Parm2;
|
|
|
|
typedef typename Base::Parm3 Parm3;
|
|
|
|
typedef typename Base::Parm4 Parm4;
|
|
|
|
typedef typename Base::Parm5 Parm5;
|
|
|
|
typedef typename Base::Parm6 Parm6;
|
|
|
|
typedef typename Base::Parm7 Parm7;
|
|
|
|
typedef typename Base::Parm8 Parm8;
|
|
|
|
typedef typename Base::Parm9 Parm9;
|
|
|
|
typedef typename Base::Parm10 Parm10;
|
|
|
|
typedef typename Base::Parm11 Parm11;
|
|
|
|
typedef typename Base::Parm12 Parm12;
|
|
|
|
typedef typename Base::Parm13 Parm13;
|
|
|
|
typedef typename Base::Parm14 Parm14;
|
|
|
|
typedef typename Base::Parm15 Parm15;
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
Chainer(const Fun1& fun1, const Fun2& fun2) : f1_(fun1), f2_(fun2) {}
|
|
|
|
|
2005-09-26 07:33:05 +00:00
|
|
|
LOKI_DEFINE_CLONE_FUNCTORIMPL(Chainer)
|
2002-08-11 05:49:45 +00:00
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2006-06-01 12:33:05 +00:00
|
|
|
bool operator==(const typename Base::Impl::FunctorImplBaseType& rhs) const
|
|
|
|
{
|
2006-06-09 12:58:44 +00:00
|
|
|
if(typeid(*this) != typeid(rhs))
|
2011-09-23 00:46:21 +00:00
|
|
|
return false; // cannot be equal
|
2006-06-01 12:33:05 +00:00
|
|
|
// if this line gives a compiler error, you are using a function object.
|
|
|
|
// you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
|
|
|
|
return f1_ == ((static_cast<const Chainer&> (rhs)).f2_) &&
|
|
|
|
f2_ == ((static_cast<const Chainer&> (rhs)).f1_);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
// operator() implementations for up to 15 arguments
|
|
|
|
|
|
|
|
ResultType operator()()
|
|
|
|
{ return f1_(), f2_(); }
|
|
|
|
|
|
|
|
ResultType operator()(Parm1 p1)
|
|
|
|
{ return f1_(p1), f2_(p1); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2)
|
|
|
|
{ return f1_(p1, p2), f2_(p1, p2); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
|
|
|
{ return f1_(p1, p2, p3), f2_(p1, p2, p3); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
|
|
|
{ return f1_(p1, p2, p3, p4), f2_(p1, p2, p3, p4); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
|
|
|
{ return f1_(p1, p2, p3, p4, p5), f2_(p1, p2, p3, p4, p5); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6)
|
|
|
|
{ return f1_(p1, p2, p3, p4, p5, p6), f2_(p1, p2, p3, p4, p5, p6); }
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7)
|
|
|
|
{
|
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7),
|
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8)
|
|
|
|
{
|
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8),
|
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
|
|
|
{
|
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9),
|
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
|
|
|
{
|
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10),
|
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
|
|
|
{
|
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11),
|
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12)
|
|
|
|
{
|
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12),
|
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13)
|
|
|
|
{
|
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13),
|
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
2002-08-11 05:49:45 +00:00
|
|
|
p14),
|
2011-09-23 00:46:21 +00:00
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
2002-08-11 05:49:45 +00:00
|
|
|
p14);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
|
|
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
|
|
|
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
|
|
|
|
{
|
2011-09-23 00:46:21 +00:00
|
|
|
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
2002-08-11 05:49:45 +00:00
|
|
|
p14, p15),
|
2011-09-23 00:46:21 +00:00
|
|
|
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
2002-08-11 05:49:45 +00:00
|
|
|
p14, p15);
|
|
|
|
}
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
private:
|
|
|
|
Fun1 f1_;
|
|
|
|
Fun2 f2_;
|
|
|
|
};
|
2011-09-23 00:46:21 +00:00
|
|
|
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-11-03 12:43:55 +00:00
|
|
|
/// Chains two functor calls one after another
|
|
|
|
/// \ingroup FunctorGroup
|
2002-08-11 05:49:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
template <class Fun1, class Fun2>
|
|
|
|
Fun2 Chain(
|
|
|
|
const Fun1& fun1,
|
|
|
|
const Fun2& fun2)
|
|
|
|
{
|
|
|
|
return Fun2(std::auto_ptr<typename Fun2::Impl>(
|
|
|
|
new Chainer<Fun1, Fun2>(fun1, fun2)));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Loki
|
|
|
|
|
|
|
|
|
2006-10-17 19:31:33 +00:00
|
|
|
#endif // end file guardian
|
2006-01-16 19:05:09 +00:00
|
|
|
|