replace tabs space
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@334 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
570f0ed652
commit
7fe4c81ff0
28 changed files with 799 additions and 778 deletions
|
@ -30,12 +30,12 @@ Example Use
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct ExtractDataType
|
struct ExtractDataType
|
||||||
{
|
{
|
||||||
some_type operator()()
|
some_type operator()()
|
||||||
{
|
{
|
||||||
return create_value_from_type<T>;
|
return create_value_from_type<T>;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Loki::IterateTypes<parameter_tl, ExtractDataType> gendata;
|
Loki::IterateTypes<parameter_tl, ExtractDataType> gendata;
|
||||||
std::vector<some_type> stuff;
|
std::vector<some_type> stuff;
|
||||||
|
@ -43,24 +43,24 @@ gendata(std::back_inserter(stuff));
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
namespace TL
|
namespace TL
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct nameof_type
|
struct nameof_type
|
||||||
{
|
{
|
||||||
const char* operator()()
|
const char* operator()()
|
||||||
{
|
{
|
||||||
return typeid(T).name();
|
return typeid(T).name();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct sizeof_type
|
struct sizeof_type
|
||||||
{
|
{
|
||||||
size_t operator()()
|
size_t operator()()
|
||||||
{
|
{
|
||||||
return sizeof(T);
|
return sizeof(T);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <class TList, template <class> class GenFunc>
|
template <class TList, template <class> class GenFunc>
|
||||||
struct IterateTypes;
|
struct IterateTypes;
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ namespace Loki
|
||||||
void operator()(II ii)
|
void operator()(II ii)
|
||||||
{
|
{
|
||||||
head.operator()(ii);
|
head.operator()(ii);
|
||||||
tail.operator()(ii);
|
tail.operator()(ii);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class AtomicType, template <class> class GenFunc>
|
template <class AtomicType, template <class> class GenFunc>
|
||||||
|
@ -99,13 +99,13 @@ namespace Loki
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Types, template <class> class UnitFunc, typename II>
|
template<typename Types, template <class> class UnitFunc, typename II>
|
||||||
void iterate_types(II ii)
|
void iterate_types(II ii)
|
||||||
{
|
{
|
||||||
Loki::TL::IterateTypes<Types, UnitFunc> it;
|
Loki::TL::IterateTypes<Types, UnitFunc> it;
|
||||||
it(ii);
|
it(ii);
|
||||||
}
|
}
|
||||||
}//ns TL
|
}//ns TL
|
||||||
}//ns Loki
|
}//ns Loki
|
||||||
|
|
||||||
#endif //DATAGENERATORS_H
|
#endif //DATAGENERATORS_H
|
||||||
|
|
|
@ -682,7 +682,7 @@ template <typename AP, typename Id, typename P1 >
|
||||||
Parm6, Parm7, Parm8, Parm9,Parm10,
|
Parm6, Parm7, Parm8, Parm9,Parm10,
|
||||||
Parm11,Parm12,Parm13,Parm14,Parm15 )
|
Parm11,Parm12,Parm13,Parm14,Parm15 )
|
||||||
= 0;
|
= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //LOKI_DISABLE_TYPELIST_MACROS
|
#endif //LOKI_DISABLE_TYPELIST_MACROS
|
||||||
|
|
||||||
|
@ -1036,6 +1036,9 @@ template <typename AP, typename Id, typename P1 >
|
||||||
#endif // FACTORY_INC_
|
#endif // FACTORY_INC_
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.9 2005/10/30 14:03:23 syntheticpp
|
||||||
|
// replace tabs space
|
||||||
|
//
|
||||||
// Revision 1.8 2005/10/30 13:49:44 syntheticpp
|
// Revision 1.8 2005/10/30 13:49:44 syntheticpp
|
||||||
// make disabling the TYPELIST macros possible
|
// make disabling the TYPELIST macros possible
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class R>
|
template<class R>
|
||||||
struct Function;
|
struct Function;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Function allows a boost/TR1 like usage of Functor.
|
// Function allows a boost/TR1 like usage of Functor.
|
||||||
|
@ -27,311 +27,311 @@ namespace Loki
|
||||||
// e.g. Functor<int,LOKI_TYPELIST_2(int,int)> becomes Function<int(int,int)>
|
// e.g. Functor<int,LOKI_TYPELIST_2(int,int)> becomes Function<int(int,int)>
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<class R>
|
template<class R>
|
||||||
struct Function<R()> : public Functor<R>
|
struct Function<R()> : public Functor<R>
|
||||||
{
|
{
|
||||||
typedef Functor<R> FBase;
|
typedef Functor<R> FBase;
|
||||||
|
|
||||||
Function() : FBase() {}
|
Function() : FBase() {}
|
||||||
|
|
||||||
Function(const Function& func) : FBase()
|
Function(const Function& func) : FBase()
|
||||||
{
|
{
|
||||||
if( !func.empty())
|
if( !func.empty())
|
||||||
FBase::operator=(func);
|
FBase::operator=(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
// emptiness
|
// emptiness
|
||||||
template<class R2>
|
template<class R2>
|
||||||
Function(Function<R2()> func) : FBase()
|
Function(Function<R2()> func) : FBase()
|
||||||
{
|
{
|
||||||
if(!func.empty())
|
if(!func.empty())
|
||||||
FBase::operator=(func);
|
FBase::operator=(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear by '= 0'
|
// clear by '= 0'
|
||||||
Function(const int i) : FBase()
|
Function(const int i) : FBase()
|
||||||
{
|
{
|
||||||
if(i==0)
|
if(i==0)
|
||||||
FBase::clear();
|
FBase::clear();
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Loki::Function(const int i): i!=0");
|
throw std::runtime_error("Loki::Function(const int i): i!=0");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Func>
|
template<class Func>
|
||||||
Function(Func func) : FBase(func) {}
|
Function(Func func) : FBase(func) {}
|
||||||
|
|
||||||
template<class Host, class Func>
|
template<class Host, class Func>
|
||||||
Function(const Host& host, const Func& func) : FBase(host,func) {}
|
Function(const Host& host, const Func& func) : FBase(host,func) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// macros for the repetitions
|
// macros for the repetitions
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define LOKI_FUNCTION_BODY \
|
#define LOKI_FUNCTION_BODY \
|
||||||
\
|
\
|
||||||
Function() : FBase() {} \
|
Function() : FBase() {} \
|
||||||
\
|
\
|
||||||
Function(const Function& func) : FBase() \
|
Function(const Function& func) : FBase() \
|
||||||
{ \
|
{ \
|
||||||
if( !func.empty()) \
|
if( !func.empty()) \
|
||||||
FBase::operator=(func); \
|
FBase::operator=(func); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
Function(const int i) : FBase() \
|
Function(const int i) : FBase() \
|
||||||
{ \
|
{ \
|
||||||
if(i==0) \
|
if(i==0) \
|
||||||
FBase::clear(); \
|
FBase::clear(); \
|
||||||
else \
|
else \
|
||||||
throw std::runtime_error( \
|
throw std::runtime_error( \
|
||||||
"Loki::Function(const int i): i!=0"); \
|
"Loki::Function(const int i): i!=0"); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
template<class Func> \
|
template<class Func> \
|
||||||
Function(Func func) : FBase(func) {} \
|
Function(Func func) : FBase(func) {} \
|
||||||
\
|
\
|
||||||
template<class Host, class Func> \
|
template<class Host, class Func> \
|
||||||
Function(const Host& host, const Func& func): FBase(host,func) {}
|
Function(const Host& host, const Func& func): FBase(host,func) {}
|
||||||
|
|
||||||
|
|
||||||
#define LOKI_FUNCTION_R2_CTOR_BODY \
|
#define LOKI_FUNCTION_R2_CTOR_BODY \
|
||||||
\
|
\
|
||||||
: FBase() \
|
: FBase() \
|
||||||
{ \
|
{ \
|
||||||
if(!func.empty()) \
|
if(!func.empty()) \
|
||||||
FBase::operator=(func); \
|
FBase::operator=(func); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// repetitions
|
// repetitions
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<class R,class P01>
|
template<class R,class P01>
|
||||||
struct Function<R(P01)>
|
struct Function<R(P01)>
|
||||||
: public Loki::Functor<R, Seq<P01> >
|
: public Loki::Functor<R, Seq<P01> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01> > FBase;
|
typedef Functor<R, Seq<P01> > FBase;
|
||||||
|
|
||||||
template<class R2,class Q01>
|
template<class R2,class Q01>
|
||||||
Function(Function<R2(Q01)> func)
|
Function(Function<R2(Q01)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R,class P01,class P02>
|
template<class R,class P01,class P02>
|
||||||
struct Function<R(P01,P02)>
|
struct Function<R(P01,P02)>
|
||||||
: public Functor<R, Seq<P01,P02> >
|
: public Functor<R, Seq<P01,P02> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02> > FBase;
|
typedef Functor<R, Seq<P01,P02> > FBase;
|
||||||
|
|
||||||
template<class R2,class Q01, class Q02>
|
template<class R2,class Q01, class Q02>
|
||||||
Function(Function<R2(Q01,Q02)> func)
|
Function(Function<R2(Q01,Q02)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R,class P01,class P02, class P03>
|
template<class R,class P01,class P02, class P03>
|
||||||
struct Function<R(P01,P02,P03)>
|
struct Function<R(P01,P02,P03)>
|
||||||
: public Functor<R, Seq<P01,P02,P03> >
|
: public Functor<R, Seq<P01,P02,P03> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03> > FBase;
|
||||||
|
|
||||||
template<class R2,class Q01, class Q02,class Q03>
|
template<class R2,class Q01, class Q02,class Q03>
|
||||||
Function(Function<R2(Q01,Q02,Q03)> func)
|
Function(Function<R2(Q01,Q02,Q03)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R,class P01,class P02, class P03,class P04>
|
template<class R,class P01,class P02, class P03,class P04>
|
||||||
struct Function<R(P01,P02,P03,P04)>
|
struct Function<R(P01,P02,P03,P04)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04> >
|
: public Functor<R, Seq<P01,P02,P03,P04> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04> > FBase;
|
||||||
|
|
||||||
template<class R2,class Q01,class Q02, class Q03,class Q04>
|
template<class R2,class Q01,class Q02, class Q03,class Q04>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R,class P01,class P02, class P03,class P04,class P05>
|
template<class R,class P01,class P02, class P03,class P04,class P05>
|
||||||
struct Function<R(P01,P02,P03,P04,P05)>
|
struct Function<R(P01,P02,P03,P04,P05)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase;
|
||||||
|
|
||||||
template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05>
|
template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06>
|
class P06>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06)>
|
struct Function<R(P01,P02,P03,P04,P05,P06)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06> > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06>
|
class Q06>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07>
|
class P06,class P07>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07>
|
class Q06,class Q07>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08>
|
class P06,class P07, class P08>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08>
|
class Q06,class Q07, class Q08>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08,class P09>
|
class P06,class P07, class P08,class P09>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09 > > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09 > > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08,class Q09>
|
class Q06,class Q07, class Q08,class Q09>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08,class P09,class P10>
|
class P06,class P07, class P08,class P09,class P10>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08,class Q09,class Q10>
|
class Q06,class Q07, class Q08,class Q09,class Q10>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08,class P09,class P10,
|
class P06,class P07, class P08,class P09,class P10,
|
||||||
class P11>
|
class P11>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||||
class Q11>
|
class Q11>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08,class P09,class P10,
|
class P06,class P07, class P08,class P09,class P10,
|
||||||
class P11,class P12>
|
class P11,class P12>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||||
class Q11,class Q12>
|
class Q11,class Q12>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08,class P09,class P10,
|
class P06,class P07, class P08,class P09,class P10,
|
||||||
class P11,class P12, class P13>
|
class P11,class P12, class P13>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||||
class Q11,class Q12, class Q13>
|
class Q11,class Q12, class Q13>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08,class P09,class P10,
|
class P06,class P07, class P08,class P09,class P10,
|
||||||
class P11,class P12, class P13,class P14>
|
class P11,class P12, class P13,class P14>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> > FBase;
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||||
class Q11,class Q12, class Q13,class Q14>
|
class Q11,class Q12, class Q13,class Q14>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||||
class P06,class P07, class P08,class P09,class P10,
|
class P06,class P07, class P08,class P09,class P10,
|
||||||
class P11,class P12, class P13,class P14,class P15>
|
class P11,class P12, class P13,class P14,class P15>
|
||||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15)>
|
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15)>
|
||||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> >
|
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> >
|
||||||
{
|
{
|
||||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> > FBase;
|
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> > FBase;
|
||||||
|
|
||||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||||
class Q11,class Q12, class Q13,class Q14,class Q15>
|
class Q11,class Q12, class Q13,class Q14,class Q15>
|
||||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14,Q15)> func)
|
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14,Q15)> func)
|
||||||
LOKI_FUNCTION_R2_CTOR_BODY
|
LOKI_FUNCTION_R2_CTOR_BODY
|
||||||
|
|
||||||
LOKI_FUNCTION_BODY
|
LOKI_FUNCTION_BODY
|
||||||
};
|
};
|
||||||
|
|
||||||
}// namespace Loki
|
}// namespace Loki
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ namespace Loki
|
||||||
virtual R operator()() = 0;
|
virtual R operator()() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// class template FunctorImpl
|
// class template FunctorImpl
|
||||||
// Specialization for 1 parameter
|
// Specialization for 1 parameter
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1111,12 +1111,12 @@ namespace Loki
|
||||||
|
|
||||||
#ifdef LOKI_ENABLE_FUNCTION
|
#ifdef LOKI_ENABLE_FUNCTION
|
||||||
|
|
||||||
class bad_function_call : public std::runtime_error
|
class bad_function_call : public std::runtime_error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bad_function_call() : std::runtime_error("bad_function_call in Loki::Functor")
|
bad_function_call() : std::runtime_error("bad_function_call in Loki::Functor")
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL if(empty()) throw bad_function_call();
|
#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL if(empty()) throw bad_function_call();
|
||||||
|
|
||||||
|
@ -1195,100 +1195,100 @@ namespace Loki
|
||||||
|
|
||||||
#ifdef LOKI_ENABLE_FUNCTION
|
#ifdef LOKI_ENABLE_FUNCTION
|
||||||
|
|
||||||
bool empty() const
|
bool empty() const
|
||||||
{
|
{
|
||||||
return spImpl_.get() == 0;
|
return spImpl_.get() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
spImpl_.reset(0);
|
spImpl_.reset(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ResultType operator()() const
|
ResultType operator()() const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)();
|
return (*spImpl_)();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1) const
|
ResultType operator()(Parm1 p1) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1);
|
return (*spImpl_)(p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2) const
|
ResultType operator()(Parm1 p1, Parm2 p2) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2);
|
return (*spImpl_)(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3) const
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3);
|
return (*spImpl_)(p1, p2, p3);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) const
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4);
|
return (*spImpl_)(p1, p2, p3, p4);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) const
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5);
|
return (*spImpl_)(p1, p2, p3, p4, p5);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||||
Parm6 p6) const
|
Parm6 p6) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6);
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||||
Parm6 p6, Parm7 p7) const
|
Parm6 p6, Parm7 p7) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8) const
|
Parm6 p6, Parm7 p7, Parm8 p8) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) const
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) const
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11) const
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||||
Parm12 p12) const
|
Parm12 p12) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||||
p12);
|
p12);
|
||||||
}
|
}
|
||||||
|
@ -1297,7 +1297,7 @@ namespace Loki
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||||
Parm12 p12, Parm13 p13) const
|
Parm12 p12, Parm13 p13) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||||
p12, p13);
|
p12, p13);
|
||||||
}
|
}
|
||||||
|
@ -1306,7 +1306,7 @@ namespace Loki
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||||
Parm12 p12, Parm13 p13, Parm14 p14) const
|
Parm12 p12, Parm13 p13, Parm14 p14) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||||
p12, p13, p14);
|
p12, p13, p14);
|
||||||
}
|
}
|
||||||
|
@ -1315,7 +1315,7 @@ namespace Loki
|
||||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||||
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15) const
|
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15) const
|
||||||
{
|
{
|
||||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||||
p12, p13, p14, p15);
|
p12, p13, p14, p15);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,18 @@ namespace Loki
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
template <class SomeLhs, class SomeRhs,
|
template <class SomeLhs, class SomeRhs,
|
||||||
class Executor, typename ResultType>
|
class Executor, typename ResultType>
|
||||||
struct InvocationTraits
|
struct InvocationTraits
|
||||||
{
|
{
|
||||||
static ResultType
|
static ResultType
|
||||||
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
|
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
|
||||||
Executor& exec, Int2Type<false>)
|
Executor& exec, Int2Type<false>)
|
||||||
{
|
{
|
||||||
return exec.Fire(lhs, rhs);
|
return exec.Fire(lhs, rhs);
|
||||||
}
|
}
|
||||||
static ResultType
|
static ResultType
|
||||||
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
|
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
|
||||||
Executor& exec, Int2Type<true>)
|
Executor& exec, Int2Type<true>)
|
||||||
{
|
{
|
||||||
return exec.Fire(rhs, lhs);
|
return exec.Fire(rhs, lhs);
|
||||||
}
|
}
|
||||||
|
@ -157,15 +157,15 @@ namespace Loki
|
||||||
|
|
||||||
// Non-inline to reduce compile time overhead...
|
// Non-inline to reduce compile time overhead...
|
||||||
template <class BaseLhs, class BaseRhs,
|
template <class BaseLhs, class BaseRhs,
|
||||||
typename ResultType, typename CallbackType>
|
typename ResultType, typename CallbackType>
|
||||||
void BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
|
void BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
|
||||||
::DoAdd(TypeInfo lhs, TypeInfo rhs, CallbackType fun)
|
::DoAdd(TypeInfo lhs, TypeInfo rhs, CallbackType fun)
|
||||||
{
|
{
|
||||||
callbackMap_[KeyType(lhs, rhs)] = fun;
|
callbackMap_[KeyType(lhs, rhs)] = fun;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class BaseLhs, class BaseRhs,
|
template <class BaseLhs, class BaseRhs,
|
||||||
typename ResultType, typename CallbackType>
|
typename ResultType, typename CallbackType>
|
||||||
bool BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
|
bool BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
|
||||||
::DoRemove(TypeInfo lhs, TypeInfo rhs)
|
::DoRemove(TypeInfo lhs, TypeInfo rhs)
|
||||||
{
|
{
|
||||||
|
@ -173,11 +173,11 @@ namespace Loki
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class BaseLhs, class BaseRhs,
|
template <class BaseLhs, class BaseRhs,
|
||||||
typename ResultType, typename CallbackType>
|
typename ResultType, typename CallbackType>
|
||||||
ResultType BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
|
ResultType BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
|
||||||
::Go(BaseLhs& lhs, BaseRhs& rhs)
|
::Go(BaseLhs& lhs, BaseRhs& rhs)
|
||||||
{
|
{
|
||||||
typename MapType::key_type k(typeid(lhs),typeid(rhs));
|
typename MapType::key_type k(typeid(lhs),typeid(rhs));
|
||||||
typename MapType::iterator i = callbackMap_.find(k);
|
typename MapType::iterator i = callbackMap_.find(k);
|
||||||
if (i == callbackMap_.end())
|
if (i == callbackMap_.end())
|
||||||
{
|
{
|
||||||
|
@ -222,7 +222,7 @@ namespace Loki
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
template <class BaseLhs, class BaseRhs,
|
template <class BaseLhs, class BaseRhs,
|
||||||
class SomeLhs, class SomeRhs,
|
class SomeLhs, class SomeRhs,
|
||||||
typename ResultType,
|
typename ResultType,
|
||||||
class CastLhs, class CastRhs,
|
class CastLhs, class CastRhs,
|
||||||
ResultType (*Callback)(SomeLhs&, SomeRhs&)>
|
ResultType (*Callback)(SomeLhs&, SomeRhs&)>
|
||||||
|
@ -266,13 +266,13 @@ namespace Loki
|
||||||
ResultType (*callback)(SomeLhs&, SomeRhs&)>
|
ResultType (*callback)(SomeLhs&, SomeRhs&)>
|
||||||
void Add()
|
void Add()
|
||||||
{
|
{
|
||||||
typedef Private::FnDispatcherHelper<
|
typedef Private::FnDispatcherHelper<
|
||||||
BaseLhs, BaseRhs,
|
BaseLhs, BaseRhs,
|
||||||
SomeLhs, SomeRhs,
|
SomeLhs, SomeRhs,
|
||||||
ResultType,
|
ResultType,
|
||||||
CastingPolicy<SomeLhs,BaseLhs>,
|
CastingPolicy<SomeLhs,BaseLhs>,
|
||||||
CastingPolicy<SomeRhs,BaseRhs>,
|
CastingPolicy<SomeRhs,BaseRhs>,
|
||||||
callback> Local;
|
callback> Local;
|
||||||
|
|
||||||
Add<SomeLhs, SomeRhs>(&Local::Trampoline);
|
Add<SomeLhs, SomeRhs>(&Local::Trampoline);
|
||||||
}
|
}
|
||||||
|
@ -282,13 +282,13 @@ namespace Loki
|
||||||
bool symmetric>
|
bool symmetric>
|
||||||
void Add(bool = true) // [gcc] dummy bool
|
void Add(bool = true) // [gcc] dummy bool
|
||||||
{
|
{
|
||||||
typedef Private::FnDispatcherHelper<
|
typedef Private::FnDispatcherHelper<
|
||||||
BaseLhs, BaseRhs,
|
BaseLhs, BaseRhs,
|
||||||
SomeLhs, SomeRhs,
|
SomeLhs, SomeRhs,
|
||||||
ResultType,
|
ResultType,
|
||||||
CastingPolicy<SomeLhs,BaseLhs>,
|
CastingPolicy<SomeLhs,BaseLhs>,
|
||||||
CastingPolicy<SomeRhs,BaseRhs>,
|
CastingPolicy<SomeRhs,BaseRhs>,
|
||||||
callback> Local;
|
callback> Local;
|
||||||
|
|
||||||
Add<SomeLhs, SomeRhs>(&Local::Trampoline);
|
Add<SomeLhs, SomeRhs>(&Local::Trampoline);
|
||||||
if (symmetric)
|
if (symmetric)
|
||||||
|
@ -316,11 +316,11 @@ namespace Loki
|
||||||
|
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
template <class BaseLhs, class BaseRhs,
|
template <class BaseLhs, class BaseRhs,
|
||||||
class SomeLhs, class SomeRhs,
|
class SomeLhs, class SomeRhs,
|
||||||
typename ResultType,
|
typename ResultType,
|
||||||
class CastLhs, class CastRhs,
|
class CastLhs, class CastRhs,
|
||||||
class Fun, bool SwapArgs>
|
class Fun, bool SwapArgs>
|
||||||
class FunctorDispatcherHelper
|
class FunctorDispatcherHelper
|
||||||
{
|
{
|
||||||
Fun fun_;
|
Fun fun_;
|
||||||
|
@ -365,33 +365,33 @@ namespace Loki
|
||||||
void Add(const Fun& fun)
|
void Add(const Fun& fun)
|
||||||
{
|
{
|
||||||
typedef Private::FunctorDispatcherHelper<
|
typedef Private::FunctorDispatcherHelper<
|
||||||
BaseLhs, BaseRhs,
|
BaseLhs, BaseRhs,
|
||||||
SomeLhs, SomeRhs,
|
SomeLhs, SomeRhs,
|
||||||
ResultType,
|
ResultType,
|
||||||
CastingPolicy<SomeLhs, BaseLhs>,
|
CastingPolicy<SomeLhs, BaseLhs>,
|
||||||
CastingPolicy<SomeRhs, BaseRhs>,
|
CastingPolicy<SomeRhs, BaseRhs>,
|
||||||
Fun, false> Adapter;
|
Fun, false> Adapter;
|
||||||
|
|
||||||
backEnd_.template Add<SomeLhs, SomeRhs>(FunctorType(Adapter(fun)));
|
backEnd_.template Add<SomeLhs, SomeRhs>(FunctorType(Adapter(fun)));
|
||||||
}
|
}
|
||||||
template <class SomeLhs, class SomeRhs, bool symmetric, class Fun>
|
template <class SomeLhs, class SomeRhs, bool symmetric, class Fun>
|
||||||
void Add(const Fun& fun)
|
void Add(const Fun& fun)
|
||||||
{
|
{
|
||||||
Add<SomeLhs,SomeRhs>(fun);
|
Add<SomeLhs,SomeRhs>(fun);
|
||||||
|
|
||||||
if (symmetric)
|
if (symmetric)
|
||||||
{
|
{
|
||||||
// Note: symmetry only makes sense where BaseLhs==BaseRhs
|
// Note: symmetry only makes sense where BaseLhs==BaseRhs
|
||||||
typedef Private::FunctorDispatcherHelper<
|
typedef Private::FunctorDispatcherHelper<
|
||||||
BaseLhs, BaseLhs,
|
BaseLhs, BaseLhs,
|
||||||
SomeLhs, SomeRhs,
|
SomeLhs, SomeRhs,
|
||||||
ResultType,
|
ResultType,
|
||||||
CastingPolicy<SomeLhs, BaseLhs>,
|
CastingPolicy<SomeLhs, BaseLhs>,
|
||||||
CastingPolicy<SomeRhs, BaseLhs>,
|
CastingPolicy<SomeRhs, BaseLhs>,
|
||||||
Fun, true> AdapterR;
|
Fun, true> AdapterR;
|
||||||
|
|
||||||
backEnd_.template Add<SomeRhs, SomeLhs>(FunctorType(AdapterR(fun)));
|
backEnd_.template Add<SomeRhs, SomeLhs>(FunctorType(AdapterR(fun)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class SomeLhs, class SomeRhs>
|
template <class SomeLhs, class SomeRhs>
|
||||||
|
|
|
@ -165,7 +165,7 @@ namespace Loki
|
||||||
};
|
};
|
||||||
|
|
||||||
template<unsigned int L, class T, typename P1>
|
template<unsigned int L, class T, typename P1>
|
||||||
class OrderedStatic<L, T, Loki::Seq<P1> > : public Private::OrderedStaticBase<T>
|
class OrderedStatic<L, T, Loki::Seq<P1> > : public Private::OrderedStaticBase<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p)
|
OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p)
|
||||||
|
|
|
@ -319,7 +319,7 @@ private:
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
const int stored = _snprintf(resultBuf,
|
const int stored = _snprintf(resultBuf,
|
||||||
#else
|
#else
|
||||||
const int stored = snprintf(resultBuf,
|
const int stored = snprintf(resultBuf,
|
||||||
#endif
|
#endif
|
||||||
sizeof(resultBuf) / sizeof(Char), fmtBuf, n);
|
sizeof(resultBuf) / sizeof(Char), fmtBuf, n);
|
||||||
if (stored < 0) {
|
if (stored < 0) {
|
||||||
|
@ -408,14 +408,14 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseDecimalUInt(unsigned int& dest) {
|
void ParseDecimalUInt(unsigned int& dest) {
|
||||||
if (!std::isdigit(*format_, std::locale())) return;
|
if (!std::isdigit(*format_, std::locale())) return;
|
||||||
unsigned int r = 0;
|
unsigned int r = 0;
|
||||||
do {
|
do {
|
||||||
// TODO: inefficient - rewrite
|
// TODO: inefficient - rewrite
|
||||||
r *= 10;
|
r *= 10;
|
||||||
r += *format_ - '0';
|
r += *format_ - '0';
|
||||||
++format_;
|
++format_;
|
||||||
} while (std::isdigit(*format_, std::locale()));
|
} while (std::isdigit(*format_, std::locale()));
|
||||||
dest = r;
|
dest = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,7 +309,7 @@ namespace Loki
|
||||||
std::size_t objectAlignSize,
|
std::size_t objectAlignSize,
|
||||||
template <class> class LifetimePolicy
|
template <class> class LifetimePolicy
|
||||||
>
|
>
|
||||||
class SmallObjectBase
|
class SmallObjectBase
|
||||||
{
|
{
|
||||||
|
|
||||||
#if (LOKI_MAX_SMALL_OBJECT_SIZE != 0) && (LOKI_DEFAULT_CHUNK_SIZE != 0) && (LOKI_DEFAULT_OBJECT_ALIGNMENT != 0)
|
#if (LOKI_MAX_SMALL_OBJECT_SIZE != 0) && (LOKI_DEFAULT_CHUNK_SIZE != 0) && (LOKI_DEFAULT_OBJECT_ALIGNMENT != 0)
|
||||||
|
@ -324,7 +324,7 @@ namespace Loki
|
||||||
/// Defines singleton made from allocator.
|
/// Defines singleton made from allocator.
|
||||||
typedef Loki::SingletonHolder< MyAllocator, Loki::CreateStatic,
|
typedef Loki::SingletonHolder< MyAllocator, Loki::CreateStatic,
|
||||||
LifetimePolicy, ThreadingModel > MyAllocatorSingleton;
|
LifetimePolicy, ThreadingModel > MyAllocatorSingleton;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Throwing single-object new throws bad_alloc when allocation fails.
|
/// Throwing single-object new throws bad_alloc when allocation fails.
|
||||||
|
@ -513,6 +513,9 @@ namespace Loki
|
||||||
// Nov. 26, 2004: re-implemented by Rich Sposato.
|
// Nov. 26, 2004: re-implemented by Rich Sposato.
|
||||||
//
|
//
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.18 2005/10/30 14:03:23 syntheticpp
|
||||||
|
// replace tabs space
|
||||||
|
//
|
||||||
// Revision 1.17 2005/10/29 08:10:13 syntheticpp
|
// Revision 1.17 2005/10/29 08:10:13 syntheticpp
|
||||||
// #undef LOKI_SMALL_OBJECT_USE_NEW_ARRAY when using a Microsoft compiler
|
// #undef LOKI_SMALL_OBJECT_USE_NEW_ARRAY when using a Microsoft compiler
|
||||||
//
|
//
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace Loki
|
||||||
{
|
{
|
||||||
Lock() {}
|
Lock() {}
|
||||||
explicit Lock(const SingleThreaded&) {}
|
explicit Lock(const SingleThreaded&) {}
|
||||||
explicit Lock(const SingleThreaded*) {}
|
explicit Lock(const SingleThreaded*) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Host VolatileType;
|
typedef Host VolatileType;
|
||||||
|
@ -125,9 +125,9 @@ namespace Loki
|
||||||
pthread_mutex_unlock(&atomic_mutex_)
|
pthread_mutex_unlock(&atomic_mutex_)
|
||||||
|
|
||||||
#define LOKI_THREADS_ATOMIC_FUNCTIONS \
|
#define LOKI_THREADS_ATOMIC_FUNCTIONS \
|
||||||
private: \
|
private: \
|
||||||
static pthread_mutex_t atomic_mutex_; \
|
static pthread_mutex_t atomic_mutex_; \
|
||||||
public: \
|
public: \
|
||||||
static IntType AtomicIncrement(volatile IntType& lval) \
|
static IntType AtomicIncrement(volatile IntType& lval) \
|
||||||
{ LOKI_THREADS_ATOMIC( lval++ ); return lval; } \
|
{ LOKI_THREADS_ATOMIC( lval++ ); return lval; } \
|
||||||
\
|
\
|
||||||
|
@ -184,7 +184,7 @@ namespace Loki
|
||||||
LOKI_THREADS_MUTEX_LOCK(&host_.mtx_);
|
LOKI_THREADS_MUTEX_LOCK(&host_.mtx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit Lock(const ObjectLevelLockable* host) : host_(*host)
|
explicit Lock(const ObjectLevelLockable* host) : host_(*host)
|
||||||
{
|
{
|
||||||
LOKI_THREADS_MUTEX_LOCK(&host_.mtx_);
|
LOKI_THREADS_MUTEX_LOCK(&host_.mtx_);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ namespace Loki
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Lock();
|
Lock();
|
||||||
Lock(const Lock&);
|
Lock(const Lock&);
|
||||||
Lock& operator=(const Lock&);
|
Lock& operator=(const Lock&);
|
||||||
const ObjectLevelLockable& host_;
|
const ObjectLevelLockable& host_;
|
||||||
|
@ -210,7 +210,7 @@ namespace Loki
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(_PTHREAD_H)
|
#if defined(_PTHREAD_H)
|
||||||
template <class Host>
|
template <class Host>
|
||||||
pthread_mutex_t ObjectLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER);
|
pthread_mutex_t ObjectLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ namespace Loki
|
||||||
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
|
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit Lock(const ClassLevelLockable*)
|
explicit Lock(const ClassLevelLockable*)
|
||||||
{
|
{
|
||||||
assert(initializer_.init_);
|
assert(initializer_.init_);
|
||||||
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
|
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
|
||||||
|
@ -290,7 +290,7 @@ namespace Loki
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(_PTHREAD_H)
|
#if defined(_PTHREAD_H)
|
||||||
template <class Host>
|
template <class Host>
|
||||||
pthread_mutex_t ClassLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER);
|
pthread_mutex_t ClassLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -314,6 +314,9 @@ namespace Loki
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.16 2005/10/30 14:03:23 syntheticpp
|
||||||
|
// replace tabs space
|
||||||
|
//
|
||||||
// Revision 1.15 2005/10/24 20:35:12 syntheticpp
|
// Revision 1.15 2005/10/24 20:35:12 syntheticpp
|
||||||
// small changes for Threads; add compile test for Threads.h
|
// small changes for Threads; add compile test for Threads.h
|
||||||
//
|
//
|
||||||
|
|
|
@ -226,7 +226,7 @@ struct SuperSubclassStrict
|
||||||
template<>
|
template<>
|
||||||
struct SuperSubclassStrict<void, void>
|
struct SuperSubclassStrict<void, void>
|
||||||
{
|
{
|
||||||
enum { value = false };
|
enum { value = false };
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class U>
|
template<class U>
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Loki
|
||||||
|
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||||
typedef LOKI_TYPELIST_4(unsigned char, unsigned short int,unsigned int, unsigned long int)
|
typedef LOKI_TYPELIST_4(unsigned char, unsigned short int,unsigned int, unsigned long int)
|
||||||
StdUnsignedInts;
|
StdUnsignedInts;
|
||||||
typedef LOKI_TYPELIST_4(signed char, short int,int, long int)
|
typedef LOKI_TYPELIST_4(signed char, short int,int, long int)
|
||||||
|
@ -75,7 +75,7 @@ namespace Loki
|
||||||
typedef LOKI_TYPELIST_3(float, double, long double)
|
typedef LOKI_TYPELIST_3(float, double, long double)
|
||||||
StdFloats;
|
StdFloats;
|
||||||
#else
|
#else
|
||||||
typedef Loki::Seq<unsigned char, unsigned short int,unsigned int, unsigned long int>::Type
|
typedef Loki::Seq<unsigned char, unsigned short int,unsigned int, unsigned long int>::Type
|
||||||
StdUnsignedInts;
|
StdUnsignedInts;
|
||||||
typedef Loki::Seq<signed char, short int,int, long int>::Type
|
typedef Loki::Seq<signed char, short int,int, long int>::Type
|
||||||
StdSignedInts;
|
StdSignedInts;
|
||||||
|
|
|
@ -211,7 +211,7 @@ namespace Loki
|
||||||
typedef NullType Result;
|
typedef NullType Result;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T> struct Append<NullType, T>
|
template <class T> struct Append<NullType, T>
|
||||||
{
|
{
|
||||||
typedef Typelist<T,NullType> Result;
|
typedef Typelist<T,NullType> Result;
|
||||||
};
|
};
|
||||||
|
|
|
@ -158,7 +158,7 @@ struct DefaultCatchAll
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define LOKI_DEFINE_VISITABLE() \
|
#define LOKI_DEFINE_VISITABLE() \
|
||||||
virtual ReturnType Accept(::Loki::BaseVisitor& guest) \
|
virtual ReturnType Accept(::Loki::BaseVisitor& guest) \
|
||||||
{ return AcceptImpl(*this, guest); }
|
{ return AcceptImpl(*this, guest); }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -66,7 +66,7 @@ typedef SingletonHolder
|
||||||
#ifndef USE_SEQUENCE
|
#ifndef USE_SEQUENCE
|
||||||
Factory< AbstractProduct, int, LOKI_TYPELIST_2( int, int ) >
|
Factory< AbstractProduct, int, LOKI_TYPELIST_2( int, int ) >
|
||||||
#else
|
#else
|
||||||
Factory< AbstractProduct, int, Seq< int, int > >
|
Factory< AbstractProduct, int, Seq< int, int > >
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
PFactory;
|
PFactory;
|
||||||
|
@ -163,7 +163,7 @@ SingletonHolder
|
||||||
#ifndef USE_SEQUENCE
|
#ifndef USE_SEQUENCE
|
||||||
Factory< AbstractProduct, int,LOKI_TYPELIST_3(CreateFunctor,int,int) >
|
Factory< AbstractProduct, int,LOKI_TYPELIST_3(CreateFunctor,int,int) >
|
||||||
#else
|
#else
|
||||||
Factory< AbstractProduct, int,Seq<CreateFunctor,int,int> >
|
Factory< AbstractProduct, int,Seq<CreateFunctor,int,int> >
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
PFactoryFunctorParm;
|
PFactoryFunctorParm;
|
||||||
|
@ -249,6 +249,9 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.5 2005/10/30 14:03:23 syntheticpp
|
||||||
|
// replace tabs space
|
||||||
|
//
|
||||||
// Revision 1.4 2005/10/30 13:49:44 syntheticpp
|
// Revision 1.4 2005/10/30 13:49:44 syntheticpp
|
||||||
// make disabling the TYPELIST macros possible
|
// make disabling the TYPELIST macros possible
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// Boost.Function library
|
// Boost.Function library
|
||||||
|
|
||||||
// Copyright Douglas Gregor 2001-2003. Use, modification and
|
// Copyright Douglas Gregor 2001-2003. Use, modification and
|
||||||
// distribution is subject to the Boost Software License, Version
|
// distribution is subject to the Boost Software License, Version
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
|
@ -44,20 +44,20 @@ struct write_three_obj{int operator()() const {global_int = 3; return 7;}};
|
||||||
struct write_three_obj{void operator()() const {global_int = 3;}};
|
struct write_three_obj{void operator()() const {global_int = 3;}};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void write_five() {global_int = 5;}
|
static void write_five() {global_int = 5;}
|
||||||
static void write_three() {global_int = 3;}
|
static void write_three() {global_int = 3;}
|
||||||
struct generate_five_obj {int operator()() const {return 5;}};
|
struct generate_five_obj {int operator()() const {return 5;}};
|
||||||
struct generate_three_obj {int operator()() const {return 3;}};
|
struct generate_three_obj {int operator()() const {return 3;}};
|
||||||
static int generate_five() {return 5;}
|
static int generate_five() {return 5;}
|
||||||
static int generate_three() {return 3;}
|
static int generate_three() {return 3;}
|
||||||
static string identity_str(const string& s){return s;}
|
static string identity_str(const string& s){return s;}
|
||||||
static string string_cat(const string& s1, const string& s2){return s1+s2;}
|
static string string_cat(const string& s1, const string& s2){return s1+s2;}
|
||||||
static int sum_ints(int x, int y){return x+y;}
|
static int sum_ints(int x, int y){return x+y;}
|
||||||
|
|
||||||
struct write_const_1_nonconst_2
|
struct write_const_1_nonconst_2
|
||||||
{
|
{
|
||||||
void operator()(){global_int = 2;}
|
void operator()(){global_int = 2;}
|
||||||
void operator()() const {global_int = 1;}
|
void operator()() const {global_int = 1;}
|
||||||
};
|
};
|
||||||
struct add_to_obj
|
struct add_to_obj
|
||||||
{
|
{
|
||||||
|
@ -645,7 +645,7 @@ static void test_member_functions()
|
||||||
Loki::Function<int ()> f1_2(&one,&X::twice);
|
Loki::Function<int ()> f1_2(&one,&X::twice);
|
||||||
BOOST_CHECK(f1_2() == 2);
|
BOOST_CHECK(f1_2() == 2);
|
||||||
|
|
||||||
f1_2 = Loki::function<int ()>(&five,&X::twice);
|
f1_2 = Loki::function<int ()>(&five,&X::twice);
|
||||||
BOOST_CHECK(f1_2() == 10);
|
BOOST_CHECK(f1_2() == 10);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -698,12 +698,12 @@ static void test_ref()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#ifndef TEST_LOKI_FUNCTION
|
#ifndef TEST_LOKI_FUNCTION
|
||||||
boost::function<int (int, int)> f(ref(atc));
|
boost::function<int (int, int)> f(ref(atc));
|
||||||
BOOST_CHECK(f(1, 3) == 4);
|
BOOST_CHECK(f(1, 3) == 4);
|
||||||
#else
|
#else
|
||||||
//TODO: implement Loki::Ref
|
//TODO: implement Loki::Ref
|
||||||
//Loki::Function<int (int, int)> f(Loki::ref(atc));
|
//Loki::Function<int (int, int)> f(Loki::ref(atc));
|
||||||
//BOOST_CHECK(f(1, 3) == 4);
|
//BOOST_CHECK(f(1, 3) == 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -731,7 +731,7 @@ static void test_exception()
|
||||||
#else
|
#else
|
||||||
catch(Loki::bad_function_call)
|
catch(Loki::bad_function_call)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// okay
|
// okay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,35 +6,35 @@
|
||||||
|
|
||||||
struct L1
|
struct L1
|
||||||
{
|
{
|
||||||
L1(){std::cout << "create L1: " << this << "\n";}
|
L1(){std::cout << "create L1: " << this << "\n";}
|
||||||
~L1(){std::cout << "delete L1: " << this <<" \n";}
|
~L1(){std::cout << "delete L1: " << this <<" \n";}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct L2
|
struct L2
|
||||||
{
|
{
|
||||||
L2(){std::cout << "create L2 \n";}
|
L2(){std::cout << "create L2 \n";}
|
||||||
~L2(){std::cout << "delete L2 \n";}
|
~L2(){std::cout << "delete L2 \n";}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct L3
|
struct L3
|
||||||
{
|
{
|
||||||
L3(){std::cout << "create L3 \n";}
|
L3(){std::cout << "create L3 \n";}
|
||||||
~L3(){std::cout << "delete L3 \n";}
|
~L3(){std::cout << "delete L3 \n";}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Loki::SetLongevity
|
Loki::SetLongevity
|
||||||
(new L1, 1);
|
(new L1, 1);
|
||||||
Loki::SetLongevity<L1, void (*)(L1*)>
|
Loki::SetLongevity<L1, void (*)(L1*)>
|
||||||
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
|
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
|
||||||
Loki::SetLongevity<L1, Loki::Private::Deleter<L1>::Type>
|
Loki::SetLongevity<L1, Loki::Private::Deleter<L1>::Type>
|
||||||
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
|
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
|
||||||
Loki::SetLongevity(new L2, 2);
|
Loki::SetLongevity(new L2, 2);
|
||||||
Loki::SetLongevity(new L1, 1);
|
Loki::SetLongevity(new L1, 1);
|
||||||
Loki::SetLongevity(new L3, 3);
|
Loki::SetLongevity(new L3, 3);
|
||||||
Loki::SetLongevity(new L1, 1);
|
Loki::SetLongevity(new L1, 1);
|
||||||
|
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,32 +27,32 @@
|
||||||
|
|
||||||
struct L1
|
struct L1
|
||||||
{
|
{
|
||||||
L1(){std::cout << "create L1: " << this << "\n";}
|
L1(){std::cout << "create L1: " << this << "\n";}
|
||||||
~L1(){std::cout << "delete L1: " << this <<" \n";}
|
~L1(){std::cout << "delete L1: " << this <<" \n";}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct L2
|
struct L2
|
||||||
{
|
{
|
||||||
L2(){std::cout << "create L2 \n";}
|
L2(){std::cout << "create L2 \n";}
|
||||||
~L2(){std::cout << "delete L2 \n";}
|
~L2(){std::cout << "delete L2 \n";}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct M1
|
struct M1
|
||||||
{
|
{
|
||||||
M1(){std::cout << "create M1 \n";}
|
M1(){std::cout << "create M1 \n";}
|
||||||
~M1(){std::cout << "delete M1 \n";}
|
~M1(){std::cout << "delete M1 \n";}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct M2
|
struct M2
|
||||||
{
|
{
|
||||||
M2(){std::cout << "create M2 \n";}
|
M2(){std::cout << "create M2 \n";}
|
||||||
~M2(){std::cout << "delete M2 \n";}
|
~M2(){std::cout << "delete M2 \n";}
|
||||||
};
|
};
|
||||||
|
|
||||||
int f()
|
int f()
|
||||||
{
|
{
|
||||||
std::cout << "f called \n";
|
std::cout << "f called \n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string func();
|
std::string func();
|
||||||
|
@ -62,8 +62,8 @@ std::string func();
|
||||||
|
|
||||||
struct MemberTest
|
struct MemberTest
|
||||||
{
|
{
|
||||||
static Loki::OrderedStatic<1,M1> m1;
|
static Loki::OrderedStatic<1,M1> m1;
|
||||||
static Loki::OrderedStatic<2,M2> m2;
|
static Loki::OrderedStatic<2,M2> m2;
|
||||||
};
|
};
|
||||||
Loki::OrderedStatic<1,M1> MemberTest::m1;
|
Loki::OrderedStatic<1,M1> MemberTest::m1;
|
||||||
Loki::OrderedStatic<2,M2> MemberTest::m2;
|
Loki::OrderedStatic<2,M2> MemberTest::m2;
|
||||||
|
@ -72,8 +72,8 @@ Loki::OrderedStatic<2,M2> MemberTest::m2;
|
||||||
Loki::OrderedStatic<1,L1> l1;
|
Loki::OrderedStatic<1,L1> l1;
|
||||||
Loki::OrderedStatic<2,L2> l2;
|
Loki::OrderedStatic<2,L2> l2;
|
||||||
|
|
||||||
Loki::OrderedStatic<1, std::string, std::string(*)() > s1( &func );
|
Loki::OrderedStatic<1, std::string, std::string(*)() > s1( &func );
|
||||||
Loki::OrderedStatic<2, std::string, Loki::Seq<char *> > s2( "s2" );
|
Loki::OrderedStatic<2, std::string, Loki::Seq<char *> > s2( "s2" );
|
||||||
|
|
||||||
Loki::OrderedStatic<1, Loki::Functor<int>, Loki::Seq<int(*)()> > f1(f);
|
Loki::OrderedStatic<1, Loki::Functor<int>, Loki::Seq<int(*)()> > f1(f);
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ Loki::OrderedStatic<1, Loki::Functor<int>, Loki::Seq<int(*)()> > f1(f);
|
||||||
|
|
||||||
struct MemberTest
|
struct MemberTest
|
||||||
{
|
{
|
||||||
static M1 m1;
|
static M1 m1;
|
||||||
static M2 m2;
|
static M2 m2;
|
||||||
};
|
};
|
||||||
M1 MemberTest::m1;
|
M1 MemberTest::m1;
|
||||||
M2 MemberTest::m2;
|
M2 MemberTest::m2;
|
||||||
|
@ -101,42 +101,42 @@ Loki::Functor<int> f1(f);
|
||||||
std::string func()
|
std::string func()
|
||||||
{
|
{
|
||||||
#ifdef TEST_ORDERED_STATIC
|
#ifdef TEST_ORDERED_STATIC
|
||||||
return *s2;
|
return *s2;
|
||||||
#else
|
#else
|
||||||
return s2;
|
return s2;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef TEST_ORDERED_STATIC
|
#ifdef TEST_ORDERED_STATIC
|
||||||
|
|
||||||
Loki::OrderedStaticManager::Instance().createObjects();
|
Loki::OrderedStaticManager::Instance().createObjects();
|
||||||
|
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
|
|
||||||
(*f1)();
|
(*f1)();
|
||||||
|
|
||||||
std::cout << "value of s1: " << (*s1).c_str() << "\n";
|
std::cout << "value of s1: " << (*s1).c_str() << "\n";
|
||||||
std::cout << "value of s2: " << (*s2).c_str() << "\n";
|
std::cout << "value of s2: " << (*s2).c_str() << "\n";
|
||||||
|
|
||||||
std::string s("text11");
|
std::string s("text11");
|
||||||
*s1=s;
|
*s1=s;
|
||||||
std::cout << "value of s1: " << (*s1).c_str() << "\n";
|
std::cout << "value of s1: " << (*s1).c_str() << "\n";
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
f1();
|
f1();
|
||||||
|
|
||||||
std::cout << "s1 = " << s1.c_str() << "\n";
|
std::cout << "s1 = " << s1.c_str() << "\n";
|
||||||
std::cout << "s2 = " << s2.c_str() << "\n";
|
std::cout << "s2 = " << s2.c_str() << "\n";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,18 +39,18 @@ public:
|
||||||
|
|
||||||
|
|
||||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||||
Functor<void,LOKI_TYPELIST_1(bool &)> function(testFunction);
|
Functor<void,LOKI_TYPELIST_1(bool &)> function(testFunction);
|
||||||
Functor<void,LOKI_TYPELIST_1(bool &)> functor(testFunctor);
|
Functor<void,LOKI_TYPELIST_1(bool &)> functor(testFunctor);
|
||||||
Functor<void,LOKI_TYPELIST_1(bool &)> classFunctor(&testClass,&TestClass::member);
|
Functor<void,LOKI_TYPELIST_1(bool &)> classFunctor(&testClass,&TestClass::member);
|
||||||
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy(function);
|
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy(function);
|
||||||
Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
|
Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
|
||||||
Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
|
Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
|
||||||
#else
|
#else
|
||||||
Functor<void,Seq<bool &> > function(testFunction);
|
Functor<void,Seq<bool &> > function(testFunction);
|
||||||
Functor<void,Seq<bool &> > functor(testFunctor);
|
Functor<void,Seq<bool &> > functor(testFunctor);
|
||||||
Functor<void,Seq<bool &> > classFunctor(&testClass,&TestClass::member);
|
Functor<void,Seq<bool &> > classFunctor(&testClass,&TestClass::member);
|
||||||
Functor<void,Seq<bool &> > functorCopy(function);
|
Functor<void,Seq<bool &> > functorCopy(function);
|
||||||
//TODO:
|
//TODO:
|
||||||
//Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
|
//Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
|
||||||
//Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
|
//Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
|
||||||
#endif
|
#endif
|
||||||
|
@ -83,8 +83,8 @@ public:
|
||||||
r=functionResult && functorResult && classFunctorResult && functorCopyResult && bindFunctorResult &&
|
r=functionResult && functorResult && classFunctorResult && functorCopyResult && bindFunctorResult &&
|
||||||
chainFunctorResult;
|
chainFunctorResult;
|
||||||
#else
|
#else
|
||||||
//TODO!
|
//TODO!
|
||||||
r=functionResult && functorResult && classFunctorResult && functorCopyResult;
|
r=functionResult && functorResult && classFunctorResult && functorCopyResult;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
testAssert("Functor",r,result);
|
testAssert("Functor",r,result);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
using namespace Loki;
|
using namespace Loki;
|
||||||
using namespace Loki::TL;
|
using namespace Loki::TL;
|
||||||
|
|
||||||
typedef Seq<char>::Type CharList;
|
typedef Seq<char>::Type CharList;
|
||||||
typedef Seq<char,int,double>::Type CharIntDoubleList;
|
typedef Seq<char,int,double>::Type CharIntDoubleList;
|
||||||
typedef Seq<char,int,double,char>::Type CharIntDoubleCharList;
|
typedef Seq<char,int,double,char>::Type CharIntDoubleCharList;
|
||||||
typedef Seq<Base,Derived1,Derived2>::Type BaseDerived1Derived2List;
|
typedef Seq<Base,Derived1,Derived2>::Type BaseDerived1Derived2List;
|
||||||
|
|
|
@ -162,12 +162,12 @@ private:
|
||||||
} smallObjectTest;
|
} smallObjectTest;
|
||||||
|
|
||||||
#ifndef SMALLOBJ_CPP
|
#ifndef SMALLOBJ_CPP
|
||||||
# define SMALLOBJ_CPP
|
# define SMALLOBJ_CPP
|
||||||
# ifdef LOKI_NONCC
|
# ifdef LOKI_NONCC
|
||||||
# include "../../include/noncc/loki/SmallObj.cpp"
|
# include "../../include/noncc/loki/SmallObj.cpp"
|
||||||
# else
|
# else
|
||||||
# include "../../src/SmallObj.cpp"
|
# include "../../src/SmallObj.cpp"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,44 +19,44 @@
|
||||||
|
|
||||||
namespace ThreadsTestPrivate
|
namespace ThreadsTestPrivate
|
||||||
{
|
{
|
||||||
class SingleLevel : public Loki::SingleThreaded<SingleLevel>
|
class SingleLevel : public Loki::SingleThreaded<SingleLevel>
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
public:
|
public:
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
Lock lock0;
|
Lock lock0;
|
||||||
Lock lock(*this);
|
Lock lock(*this);
|
||||||
Lock lockThis(this);
|
Lock lockThis(this);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClassLevel : public Loki::ClassLevelLockable<ClassLevel>
|
class ClassLevel : public Loki::ClassLevelLockable<ClassLevel>
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
public:
|
public:
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
Lock lock0;
|
Lock lock0;
|
||||||
Lock lock(*this);
|
Lock lock(*this);
|
||||||
Lock lockThis(this);
|
Lock lockThis(this);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectLevel : public Loki::ObjectLevelLockable<ObjectLevel>
|
class ObjectLevel : public Loki::ObjectLevelLockable<ObjectLevel>
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
public:
|
public:
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
//Lock lock0_must_not_compile;
|
//Lock lock0_must_not_compile;
|
||||||
Lock lock(*this);
|
Lock lock(*this);
|
||||||
Lock lockThis(this);
|
Lock lockThis(this);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThreadsTest : public Test
|
class ThreadsTest : public Test
|
||||||
|
@ -68,7 +68,7 @@ public:
|
||||||
{
|
{
|
||||||
printName(result);
|
printName(result);
|
||||||
|
|
||||||
bool r = true; // TODO some tests
|
bool r = true; // TODO some tests
|
||||||
|
|
||||||
testAssert("Threads",r,result);
|
testAssert("Threads",r,result);
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
SameType<TypeTraits<int>::ParameterType,int>::value &&
|
SameType<TypeTraits<int>::ParameterType,int>::value &&
|
||||||
SameType<TypeTraits<double>::ParameterType,double>::value &&
|
SameType<TypeTraits<double>::ParameterType,double>::value &&
|
||||||
SameType<TypeTraits<Test&>::ParameterType,Test &>::value &&
|
SameType<TypeTraits<Test&>::ParameterType,Test &>::value &&
|
||||||
SameType<TypeTraits<Test>::ParameterType,const Test &>::value;
|
SameType<TypeTraits<Test>::ParameterType,const Test &>::value;
|
||||||
|
|
||||||
testAssert("TypeTraits",r,result);
|
testAssert("TypeTraits",r,result);
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ private:
|
||||||
|
|
||||||
void testFunction();
|
void testFunction();
|
||||||
void testFunctionPointer();
|
void testFunctionPointer();
|
||||||
void testMemberFunctionPointer();
|
void testMemberFunctionPointer();
|
||||||
|
|
||||||
void testParameterType();
|
void testParameterType();
|
||||||
void testReferredType();
|
void testReferredType();
|
||||||
|
@ -220,7 +220,7 @@ inline void TypeTraitsTest2::execute(TestResult &result)
|
||||||
|
|
||||||
testFunction();
|
testFunction();
|
||||||
testFunctionPointer();
|
testFunctionPointer();
|
||||||
testMemberFunctionPointer();
|
testMemberFunctionPointer();
|
||||||
|
|
||||||
bool r = erroneousConditions_ == 0;
|
bool r = erroneousConditions_ == 0;
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ inline void TypeTraitsTest2::testFunction()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isFunction
|
#define CONDITION isFunction
|
||||||
|
|
||||||
testBegin("isFunction");
|
testBegin("isFunction");
|
||||||
|
|
||||||
PASS(void());
|
PASS(void());
|
||||||
PASS(void(int, float, ...));
|
PASS(void(int, float, ...));
|
||||||
|
@ -597,9 +597,9 @@ inline void TypeTraitsTest2::testFunctionPointer()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isFunctionPointer
|
#define CONDITION isFunctionPointer
|
||||||
|
|
||||||
testBegin("isFunctionPointer");
|
testBegin("isFunctionPointer");
|
||||||
|
|
||||||
PASS(void (*)());
|
PASS(void (*)());
|
||||||
FAIL(void (A::* const volatile)());
|
FAIL(void (A::* const volatile)());
|
||||||
FAIL(void (A::* const volatile)() const);
|
FAIL(void (A::* const volatile)() const);
|
||||||
FAIL(void (A::* const volatile)() volatile);
|
FAIL(void (A::* const volatile)() volatile);
|
||||||
|
@ -624,7 +624,7 @@ inline void TypeTraitsTest2::testMemberFunctionPointer()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isMemberFunctionPointer
|
#define CONDITION isMemberFunctionPointer
|
||||||
|
|
||||||
testBegin("isMemberFunctionPointer");
|
testBegin("isMemberFunctionPointer");
|
||||||
|
|
||||||
PASS(void (A::* const volatile)());
|
PASS(void (A::* const volatile)());
|
||||||
PASS(void (A::* const volatile)() const);
|
PASS(void (A::* const volatile)() const);
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
using namespace Loki::TL;
|
using namespace Loki::TL;
|
||||||
|
|
||||||
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
#ifndef LOKI_DISABLE_TYPELIST_MACROS
|
||||||
typedef LOKI_TYPELIST_1(char) CharList;
|
typedef LOKI_TYPELIST_1(char) CharList;
|
||||||
typedef LOKI_TYPELIST_3(char,int,double) CharIntDoubleList;
|
typedef LOKI_TYPELIST_3(char,int,double) CharIntDoubleList;
|
||||||
typedef LOKI_TYPELIST_4(char,int,double,char) CharIntDoubleCharList;
|
typedef LOKI_TYPELIST_4(char,int,double,char) CharIntDoubleCharList;
|
||||||
typedef LOKI_TYPELIST_3(Base,Derived1,Derived2) BaseDerived1Derived2List;
|
typedef LOKI_TYPELIST_3(Base,Derived1,Derived2) BaseDerived1Derived2List;
|
||||||
|
@ -43,8 +43,8 @@ public:
|
||||||
typedef LOKI_TYPELIST_4(Base,Derived1,Base,Derived2) BaseDerived1BaseDerived2List;
|
typedef LOKI_TYPELIST_4(Base,Derived1,Base,Derived2) BaseDerived1BaseDerived2List;
|
||||||
typedef LOKI_TYPELIST_4(Derived1,Base,Derived1,Derived2) Derived1BaseDerived1Derived2List;
|
typedef LOKI_TYPELIST_4(Derived1,Base,Derived1,Derived2) Derived1BaseDerived1Derived2List;
|
||||||
#else
|
#else
|
||||||
typedef Seq<char>::Type CharList;
|
typedef Seq<char>::Type CharList;
|
||||||
typedef Seq<char,int,double>::Type CharIntDoubleList;
|
typedef Seq<char,int,double>::Type CharIntDoubleList;
|
||||||
typedef Seq<char,int,double,char>::Type CharIntDoubleCharList;
|
typedef Seq<char,int,double,char>::Type CharIntDoubleCharList;
|
||||||
typedef Seq<Base,Derived1,Derived2>::Type BaseDerived1Derived2List;
|
typedef Seq<Base,Derived1,Derived2>::Type BaseDerived1Derived2List;
|
||||||
typedef Seq<Derived2,Derived1,Base>::Type Derived2Derived1BaseList;
|
typedef Seq<Derived2,Derived1,Base>::Type Derived2Derived1BaseList;
|
||||||
|
@ -179,8 +179,8 @@ public:
|
||||||
|
|
||||||
#else //LOKI_DISABLE_TYPELIST_MACROS
|
#else //LOKI_DISABLE_TYPELIST_MACROS
|
||||||
|
|
||||||
r=SameType<Append<NullType,NullType>::Result,NullType>::value &&
|
r=SameType<Append<NullType,NullType>::Result,NullType>::value &&
|
||||||
SameType<Append<NullType,char>::Result,Seq<char>::Type >::value &&
|
SameType<Append<NullType,char>::Result,Seq<char>::Type >::value &&
|
||||||
SameType<Append<NullType,CharList>::Result,CharList>::value &&
|
SameType<Append<NullType,CharList>::Result,CharList>::value &&
|
||||||
SameType<Append<CharList,NullType>::Result,CharList>::value &&
|
SameType<Append<CharList,NullType>::Result,CharList>::value &&
|
||||||
SameType<Append<CharList,int>::Result,Seq<char,int>::Type >::value &&
|
SameType<Append<CharList,int>::Result,Seq<char,int>::Type >::value &&
|
||||||
|
@ -254,7 +254,7 @@ public:
|
||||||
SameType<DerivedToFront<CharIntDoubleCharList>::Result,CharIntDoubleCharList>::value &&
|
SameType<DerivedToFront<CharIntDoubleCharList>::Result,CharIntDoubleCharList>::value &&
|
||||||
SameType<DerivedToFront<BaseDerived1Derived2List>::Result,Derived2Derived1BaseList>::value &&
|
SameType<DerivedToFront<BaseDerived1Derived2List>::Result,Derived2Derived1BaseList>::value &&
|
||||||
SameType<DerivedToFront<Derived2Derived1BaseList>::Result,Derived2Derived1BaseList>::value &&
|
SameType<DerivedToFront<Derived2Derived1BaseList>::Result,Derived2Derived1BaseList>::value &&
|
||||||
SameType<DerivedToFront<BaseDerived1BaseDerived2List>::Result,Seq<Derived2,Derived1,Base,Base>::Type >::value &&
|
SameType<DerivedToFront<BaseDerived1BaseDerived2List>::Result,Seq<Derived2,Derived1,Base,Base>::Type >::value &&
|
||||||
SameType<DerivedToFront<Derived1BaseDerived1Derived2List>::Result,Seq<Derived2,Derived1,Derived1,Base>::Type >::value;
|
SameType<DerivedToFront<Derived1BaseDerived1Derived2List>::Result,Seq<Derived2,Derived1,Derived1,Base>::Type >::value;
|
||||||
|
|
||||||
testAssert("DerivedToFront",r,result);
|
testAssert("DerivedToFront",r,result);
|
||||||
|
|
|
@ -58,7 +58,7 @@ void TestCase(const string& fmt, T value) {
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
const int i2 = _snprintf(buf, sizeof(buf), fmt.c_str(), value);
|
const int i2 = _snprintf(buf, sizeof(buf), fmt.c_str(), value);
|
||||||
#else
|
#else
|
||||||
const int i2 = snprintf(buf, sizeof(buf), fmt.c_str(), value);
|
const int i2 = snprintf(buf, sizeof(buf), fmt.c_str(), value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (i1 != i2 || s != buf) {
|
if (i1 != i2 || s != buf) {
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
//#define COMPARE_BOOST_POOL
|
//#define COMPARE_BOOST_POOL
|
||||||
#ifdef COMPARE_BOOST_POOL
|
#ifdef COMPARE_BOOST_POOL
|
||||||
#include <boost\pool\object_pool.hpp>
|
#include <boost\pool\object_pool.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -36,14 +36,14 @@ using namespace std;
|
||||||
template<unsigned int N>
|
template<unsigned int N>
|
||||||
class ThisIsASmallObject
|
class ThisIsASmallObject
|
||||||
{
|
{
|
||||||
char data[N];
|
char data[N];
|
||||||
};
|
};
|
||||||
|
|
||||||
template<unsigned int N, class T>
|
template<unsigned int N, class T>
|
||||||
struct Base : public ThisIsASmallObject<N>, public T
|
struct Base : public ThisIsASmallObject<N>, public T
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template<unsigned int N>
|
template<unsigned int N>
|
||||||
struct Base<N, void> : public ThisIsASmallObject<N>
|
struct Base<N, void> : public ThisIsASmallObject<N>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
@ -54,51 +54,51 @@ template<unsigned int N>
|
||||||
class BoostPoolNew : public Base<N,void>
|
class BoostPoolNew : public Base<N,void>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static boost::object_pool< BoostPoolNew<N> > BoostPool;
|
static boost::object_pool< BoostPoolNew<N> > BoostPool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Throwing single-object new throws bad_alloc when allocation fails.
|
/// Throwing single-object new throws bad_alloc when allocation fails.
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/// @note MSVC complains about non-empty exception specification lists.
|
/// @note MSVC complains about non-empty exception specification lists.
|
||||||
static void * operator new ( std::size_t )
|
static void * operator new ( std::size_t )
|
||||||
#else
|
#else
|
||||||
static void * operator new ( std::size_t ) throw ( std::bad_alloc )
|
static void * operator new ( std::size_t ) throw ( std::bad_alloc )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return BoostPool.malloc();
|
return BoostPool.malloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Non-throwing single-object new returns NULL if allocation fails.
|
/// Non-throwing single-object new returns NULL if allocation fails.
|
||||||
static void * operator new ( std::size_t, const std::nothrow_t & ) throw ()
|
static void * operator new ( std::size_t, const std::nothrow_t & ) throw ()
|
||||||
{
|
{
|
||||||
return BoostPool.malloc();
|
return BoostPool.malloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Placement single-object new merely calls global placement new.
|
/// Placement single-object new merely calls global placement new.
|
||||||
inline static void * operator new ( std::size_t size, void * place )
|
inline static void * operator new ( std::size_t size, void * place )
|
||||||
{
|
{
|
||||||
return ::operator new( size, place );
|
return ::operator new( size, place );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Single-object delete.
|
/// Single-object delete.
|
||||||
static void operator delete ( void * p ) throw ()
|
static void operator delete ( void * p ) throw ()
|
||||||
{
|
{
|
||||||
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
|
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Non-throwing single-object delete is only called when nothrow
|
/** Non-throwing single-object delete is only called when nothrow
|
||||||
new operator is used, and the constructor throws an exception.
|
new operator is used, and the constructor throws an exception.
|
||||||
*/
|
*/
|
||||||
static void operator delete ( void * p, const std::nothrow_t & ) throw()
|
static void operator delete ( void * p, const std::nothrow_t & ) throw()
|
||||||
{
|
{
|
||||||
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
|
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Placement single-object delete merely calls global placement delete.
|
/// Placement single-object delete merely calls global placement delete.
|
||||||
inline static void operator delete ( void * p, void * place )
|
inline static void operator delete ( void * p, void * place )
|
||||||
{
|
{
|
||||||
::operator delete ( p, place );
|
::operator delete ( p, place );
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,205 +112,208 @@ int array_test_nr = 0;
|
||||||
double t100_new = 0;
|
double t100_new = 0;
|
||||||
double t100_delete = 0;
|
double t100_delete = 0;
|
||||||
|
|
||||||
#define LOKI_SMALLOBJ_BENCH(FUNC, CODE_LOOP) \
|
#define LOKI_SMALLOBJ_BENCH(FUNC, CODE_LOOP) \
|
||||||
template<class T, int TN> \
|
template<class T, int TN> \
|
||||||
int FUNC(void**, const int N, int loop, Timer& t, const char* s) \
|
int FUNC(void**, const int N, int loop, Timer& t, const char* s) \
|
||||||
{ \
|
{ \
|
||||||
t.start(); \
|
t.start(); \
|
||||||
/****************************************************************/ \
|
/****************************************************************/ \
|
||||||
for (int i=0; i<loop; ++i) \
|
for (int i=0; i<loop; ++i) \
|
||||||
{ \
|
{ \
|
||||||
CODE_LOOP \
|
CODE_LOOP \
|
||||||
} \
|
} \
|
||||||
/****************************************************************/ \
|
/****************************************************************/ \
|
||||||
t.stop(); \
|
t.stop(); \
|
||||||
if(array_test_nr==0) \
|
if(array_test_nr==0) \
|
||||||
t.t100 = t.t(); \
|
t.t100 = t.t(); \
|
||||||
array_test_nr++; \
|
array_test_nr++; \
|
||||||
t.print(t.t(),s); \
|
t.print(t.t(),s); \
|
||||||
return t.t(); \
|
return t.t(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOKI_SMALLOBJ_BENCH_ARRAY(FUNC, CODE_DECL, CODE_NEW, CODE_DELETE) \
|
#define LOKI_SMALLOBJ_BENCH_ARRAY(FUNC, CODE_DECL, CODE_NEW, CODE_DELETE) \
|
||||||
template<class T, int TN> \
|
template<class T, int TN> \
|
||||||
int FUNC(void** arrv, const int N, int loop, Timer& t, const char* s) \
|
int FUNC(void** arrv, const int N, int loop, Timer& t, const char* s) \
|
||||||
{ \
|
{ \
|
||||||
\
|
\
|
||||||
CODE_DECL; \
|
CODE_DECL; \
|
||||||
T** arr = reinterpret_cast<T**>(arrv); \
|
T** arr = reinterpret_cast<T**>(arrv); \
|
||||||
t.start(); \
|
t.start(); \
|
||||||
/****************************************************************/ \
|
/****************************************************************/ \
|
||||||
for (int i=0; i<loop; ++i) \
|
for (int i=0; i<loop; ++i) \
|
||||||
{ \
|
{ \
|
||||||
CODE_NEW \
|
CODE_NEW \
|
||||||
} \
|
} \
|
||||||
/****************************************************************/ \
|
/****************************************************************/ \
|
||||||
t.stop(); \
|
t.stop(); \
|
||||||
cout << "1. "; \
|
cout << "1. "; \
|
||||||
if(array_test_nr==0) \
|
if(array_test_nr==0) \
|
||||||
{ \
|
{ \
|
||||||
t.t100 = t.t(); \
|
t.t100 = t.t(); \
|
||||||
t100_new = t.t100; \
|
t100_new = t.t100; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
t.t100 = t100_new; \
|
t.t100 = t100_new; \
|
||||||
t.print(t.t(),s); \
|
t.print(t.t(),s); \
|
||||||
\
|
\
|
||||||
if(array_test_nr==3) \
|
if(array_test_nr==3) \
|
||||||
{ \
|
{ \
|
||||||
cout << \
|
cout << \
|
||||||
"2. boost :\tboost::object_pool is not tested because it's too slow"\
|
"2. boost :\tboost::object_pool is not tested because it's too slow"\
|
||||||
<< endl << endl; \
|
<< endl << endl; \
|
||||||
array_test_nr++; \
|
array_test_nr++; \
|
||||||
return t.t(); \
|
return t.t(); \
|
||||||
} \
|
} \
|
||||||
t.start(); \
|
t.start(); \
|
||||||
/****************************************************************/ \
|
/****************************************************************/ \
|
||||||
for (int i=0; i<loop; ++i) \
|
for (int i=0; i<loop; ++i) \
|
||||||
{ \
|
{ \
|
||||||
CODE_DELETE \
|
CODE_DELETE \
|
||||||
} \
|
} \
|
||||||
/****************************************************************/ \
|
/****************************************************************/ \
|
||||||
t.stop(); \
|
t.stop(); \
|
||||||
cout << "2. "; \
|
cout << "2. "; \
|
||||||
if(array_test_nr==0) \
|
if(array_test_nr==0) \
|
||||||
{ \
|
{ \
|
||||||
t.t100 = t.t(); \
|
t.t100 = t.t(); \
|
||||||
t100_delete = t.t100; \
|
t100_delete = t.t100; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
t.t100 = t100_delete; \
|
t.t100 = t100_delete; \
|
||||||
t.print(t.t(),s); \
|
t.print(t.t(),s); \
|
||||||
array_test_nr++; \
|
array_test_nr++; \
|
||||||
cout << endl; \
|
cout << endl; \
|
||||||
return t.t(); \
|
return t.t(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOKI_SMALLOBJ_BENCH(delete_new ,delete new T;)
|
LOKI_SMALLOBJ_BENCH(delete_new ,delete new T;)
|
||||||
LOKI_SMALLOBJ_BENCH(delete_new_mal ,std::free(std::malloc(sizeof(T))););
|
LOKI_SMALLOBJ_BENCH(delete_new_mal ,std::free(std::malloc(sizeof(T))););
|
||||||
LOKI_SMALLOBJ_BENCH(delete_new_all ,std::allocator<T> st;st.deallocate(st.allocate(1), 1);)
|
LOKI_SMALLOBJ_BENCH(delete_new_all ,std::allocator<T> st;st.deallocate(st.allocate(1), 1);)
|
||||||
|
|
||||||
LOKI_SMALLOBJ_BENCH(delete_new_array ,delete[] new T[N];)
|
LOKI_SMALLOBJ_BENCH(delete_new_array ,delete[] new T[N];)
|
||||||
LOKI_SMALLOBJ_BENCH(delete_new_array_mal,std::free(std::malloc(sizeof(T[TN]))););
|
LOKI_SMALLOBJ_BENCH(delete_new_array_mal,std::free(std::malloc(sizeof(T[TN]))););
|
||||||
LOKI_SMALLOBJ_BENCH(delete_new_array_all,std::allocator<T[TN]> st;st.deallocate(st.allocate(1), 1);)
|
LOKI_SMALLOBJ_BENCH(delete_new_array_all,std::allocator<T[TN]> st;st.deallocate(st.allocate(1), 1);)
|
||||||
|
|
||||||
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr , , arr[i] = new T; ,
|
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr , , arr[i] = new T; ,
|
||||||
delete arr[i];)
|
delete arr[i];)
|
||||||
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr_mal, , arr[i] = static_cast<T*>(std::malloc(sizeof(T))); ,
|
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr_mal, , arr[i] = static_cast<T*>(std::malloc(sizeof(T))); ,
|
||||||
std::free(arr[i]);)
|
std::free(arr[i]);)
|
||||||
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr_all, std::allocator<T> st ,
|
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr_all, std::allocator<T> st ,
|
||||||
arr[i]=st.allocate(1); ,
|
arr[i]=st.allocate(1); ,
|
||||||
st.deallocate(arr[i], 1);)
|
st.deallocate(arr[i], 1);)
|
||||||
|
|
||||||
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a , , arr[i] = new T[TN]; ,
|
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a , , arr[i] = new T[TN]; ,
|
||||||
delete[] arr[i];)
|
delete[] arr[i];)
|
||||||
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a_mal, , arr[i] = static_cast<T*>(std::malloc(sizeof(T[TN]))); ,
|
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a_mal, , arr[i] = static_cast<T*>(std::malloc(sizeof(T[TN]))); ,
|
||||||
std::free(arr[i]);)
|
std::free(arr[i]);)
|
||||||
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a_all,std::allocator<T[TN]> st ,
|
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a_all,std::allocator<T[TN]> st ,
|
||||||
arr[i]=reinterpret_cast<T*>(st.allocate(1)); ,
|
arr[i]=reinterpret_cast<T*>(st.allocate(1)); ,
|
||||||
st.deallocate(reinterpret_cast<T(*)[TN]>(arr[i]), 1);)
|
st.deallocate(reinterpret_cast<T(*)[TN]>(arr[i]), 1);)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef COMPARE_BOOST_POOL
|
#ifndef COMPARE_BOOST_POOL
|
||||||
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
|
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
|
||||||
array_test_nr = 0; \
|
array_test_nr = 0; \
|
||||||
cout << MESSAGE << endl; \
|
cout << MESSAGE << endl; \
|
||||||
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
|
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
|
||||||
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
|
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
|
||||||
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
|
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
|
||||||
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
|
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
|
||||||
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
|
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
#else
|
#else
|
||||||
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
|
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
|
||||||
array_test_nr = 0; \
|
array_test_nr = 0; \
|
||||||
cout << MESSAGE << endl; \
|
cout << MESSAGE << endl; \
|
||||||
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
|
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
|
||||||
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
|
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
|
||||||
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
|
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
|
||||||
FUNC<D,N>(a,N,LOOP,TIMER,"boost :"); \
|
FUNC<D,N>(a,N,LOOP,TIMER,"boost :"); \
|
||||||
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
|
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
|
||||||
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
|
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<unsigned int Size, int loop>
|
template<unsigned int Size, int loop>
|
||||||
void testSize()
|
void testSize()
|
||||||
{
|
{
|
||||||
typedef Base<Size, void> A;
|
typedef Base<Size, void> A;
|
||||||
typedef Base<Size, Loki::SmallObject< Loki::SingleThreaded > > B;
|
typedef Base<Size, Loki::SmallObject< Loki::SingleThreaded > > B;
|
||||||
typedef Base<Size, Loki::SmallValueObject< Loki::SingleThreaded > > C;
|
typedef Base<Size, Loki::SmallValueObject< Loki::SingleThreaded > > C;
|
||||||
#ifdef COMPARE_BOOST_POOL
|
#ifdef COMPARE_BOOST_POOL
|
||||||
typedef BoostPoolNew<Size> D;
|
typedef BoostPoolNew<Size> D;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
cout << "Allocator Benchmark Tests with " << Size << " bytes big objects " << endl;
|
cout << "Allocator Benchmark Tests with " << Size << " bytes big objects " << endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << "new = global new/delete \tsizeof(A) = " << sizeof(A) << endl;
|
cout << "new = global new/delete \tsizeof(A) = " << sizeof(A) << endl;
|
||||||
cout << "SmallObj = Loki::SmallObject \tsizeof(B) = " << sizeof(B) << endl;
|
cout << "SmallObj = Loki::SmallObject \tsizeof(B) = " << sizeof(B) << endl;
|
||||||
cout << "ValueObj = Loki::SmallValueObject\tsizeof(C) = " << sizeof(C) << endl;
|
cout << "ValueObj = Loki::SmallValueObject\tsizeof(C) = " << sizeof(C) << endl;
|
||||||
#ifdef COMPARE_BOOST_POOL
|
#ifdef COMPARE_BOOST_POOL
|
||||||
cout << "boost = boost::object_pool \tsizeof(D) = " << sizeof(D) << endl;
|
cout << "boost = boost::object_pool \tsizeof(D) = " << sizeof(D) << endl;
|
||||||
#endif
|
#endif
|
||||||
cout << "allocator= std::allocator \tsizeof(A) = " << sizeof(A) << endl;
|
cout << "allocator= std::allocator \tsizeof(A) = " << sizeof(A) << endl;
|
||||||
cout << "malloc = std::malloc/free \tsizeof(A) = " << sizeof(A) << endl;
|
cout << "malloc = std::malloc/free \tsizeof(A) = " << sizeof(A) << endl;
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
|
|
||||||
Timer t;
|
Timer t;
|
||||||
|
|
||||||
const int N = 3;
|
const int N = 3;
|
||||||
int Narr = 1000*1000;
|
int Narr = 1000*1000;
|
||||||
|
|
||||||
void** a= new void*[Narr];
|
void** a= new void*[Narr];
|
||||||
|
|
||||||
cout << loop << " times ";
|
cout << loop << " times ";
|
||||||
LOKI_SMALLOBJBECH_ABCD(delete_new ,0,loop,t,"'delete new T'");
|
LOKI_SMALLOBJBECH_ABCD(delete_new ,0,loop,t,"'delete new T'");
|
||||||
|
|
||||||
cout << "N=" << N <<" : " << loop << " times ";
|
cout << "N=" << N <<" : " << loop << " times ";
|
||||||
LOKI_SMALLOBJBECH_ABCD(delete_new_array ,N,loop,t,"'delete[] new T[N]'");
|
LOKI_SMALLOBJBECH_ABCD(delete_new_array ,N,loop,t,"'delete[] new T[N]'");
|
||||||
|
|
||||||
cout << "i=0..." << Narr << " : ";
|
cout << "i=0..." << Narr << " : ";
|
||||||
LOKI_SMALLOBJBECH_ABCD(new_del_on_arr ,0,Narr,t,"1. 'arr[i] = new T' 2. 'delete arr[i]'");
|
LOKI_SMALLOBJBECH_ABCD(new_del_on_arr ,0,Narr,t,"1. 'arr[i] = new T' 2. 'delete arr[i]'");
|
||||||
|
|
||||||
cout << "i=0..." << Narr << ", N=" << N <<" : ";
|
cout << "i=0..." << Narr << ", N=" << N <<" : ";
|
||||||
LOKI_SMALLOBJBECH_ABCD(new_del_a_on_a ,N,Narr,t,"1. 'arr[i] = new T[N]' 2. 'delete[] arr[i]'");
|
LOKI_SMALLOBJBECH_ABCD(new_del_a_on_a ,N,Narr,t,"1. 'arr[i] = new T[N]' 2. 'delete[] arr[i]'");
|
||||||
|
|
||||||
|
|
||||||
delete [] a;
|
delete [] a;
|
||||||
|
|
||||||
cout << "_________________________________________________________________" << endl;
|
cout << "_________________________________________________________________" << endl;
|
||||||
Loki::AllocatorSingleton<>::ClearExtraMemory();
|
Loki::AllocatorSingleton<>::ClearExtraMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const int loop = 1000*1000;
|
const int loop = 1000*1000;
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
testSize< 2,loop>();
|
testSize< 2,loop>();
|
||||||
testSize< 3,loop>();
|
testSize< 3,loop>();
|
||||||
testSize< 8,loop>();
|
testSize< 8,loop>();
|
||||||
testSize< 9,loop>();
|
testSize< 9,loop>();
|
||||||
testSize<16,loop>();
|
testSize<16,loop>();
|
||||||
testSize<17,loop>();
|
testSize<17,loop>();
|
||||||
|
|
||||||
|
|
||||||
#if defined(__BORLANDC__) || defined(__GNUC__) || defined(_MSC_VER)
|
#if defined(__BORLANDC__) || defined(__GNUC__) || defined(_MSC_VER)
|
||||||
// Stop console window from closing if run from IDE.
|
// Stop console window from closing if run from IDE.
|
||||||
system("pause");
|
system("pause");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.13 2005/10/30 14:03:23 syntheticpp
|
||||||
|
// replace tabs space
|
||||||
|
//
|
||||||
// Revision 1.12 2005/10/29 12:38:22 syntheticpp
|
// Revision 1.12 2005/10/29 12:38:22 syntheticpp
|
||||||
// replace with new implementation
|
// replace with new implementation
|
||||||
//
|
//
|
||||||
|
|
|
@ -165,13 +165,16 @@ int main()
|
||||||
MortalSingleton::Instance().DoThat();
|
MortalSingleton::Instance().DoThat();
|
||||||
LongLivedSingleton::Instance().DoThat();
|
LongLivedSingleton::Instance().DoThat();
|
||||||
ImmortalSingleton::Instance().DoThat();
|
ImmortalSingleton::Instance().DoThat();
|
||||||
system("PAUSE");
|
system("PAUSE");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.3 2005/10/30 14:03:23 syntheticpp
|
||||||
|
// replace tabs space
|
||||||
|
//
|
||||||
// Revision 1.2 2005/10/29 10:21:46 syntheticpp
|
// Revision 1.2 2005/10/29 10:21:46 syntheticpp
|
||||||
// find loki include files without a correct sreach pathand some small fixes
|
// find loki include files without a correct sreach pathand some small fixes
|
||||||
//
|
//
|
||||||
|
|
|
@ -25,56 +25,59 @@ class Timer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Timer()
|
Timer()
|
||||||
{
|
{
|
||||||
t100 = 0;
|
t100 = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void start()
|
void start()
|
||||||
{
|
{
|
||||||
t0 = clock();
|
t0 = clock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop()
|
void stop()
|
||||||
{
|
{
|
||||||
t1 = clock();
|
t1 = clock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int t()
|
int t()
|
||||||
{
|
{
|
||||||
return t1-t0;
|
return t1-t0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double sec(int t)
|
double sec(int t)
|
||||||
{
|
{
|
||||||
return floor(100.0*double(t)/1000.0 )/100.0;
|
return floor(100.0*double(t)/1000.0 )/100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rel(int t)
|
int rel(int t)
|
||||||
{
|
{
|
||||||
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
|
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
|
||||||
}
|
}
|
||||||
|
|
||||||
double speedup(int t)
|
double speedup(int t)
|
||||||
{
|
{
|
||||||
double tup=t;
|
double tup=t;
|
||||||
return (tup!=0 ? floor(100.0*(t100!=0?t100:tup)/tup+0.5)/100 : 1);
|
return (tup!=0 ? floor(100.0*(t100!=0?t100:tup)/tup+0.5)/100 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
double t100;
|
double t100;
|
||||||
|
|
||||||
void print(int t, const char* s)
|
void print(int t, const char* s)
|
||||||
{
|
{
|
||||||
std::cout << s << "\tseconds: " << sec(t) << "\trelative time: " << rel(t) << "%\tspeed-up factor: " << speedup(t) << "" << std::endl;
|
std::cout << s << "\tseconds: " << sec(t) << "\trelative time: " << rel(t) << "%\tspeed-up factor: " << speedup(t) << "" << std::endl;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
int t0;
|
int t0;
|
||||||
int t1;
|
int t1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.5 2005/10/30 14:03:23 syntheticpp
|
||||||
|
// replace tabs space
|
||||||
|
//
|
||||||
// Revision 1.4 2005/10/26 00:38:49 rich_sposato
|
// Revision 1.4 2005/10/26 00:38:49 rich_sposato
|
||||||
// Added CVS keywords and header lines.
|
// Added CVS keywords and header lines.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue