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:
syntheticpp 2005-10-30 14:03:23 +00:00
parent 570f0ed652
commit 7fe4c81ff0
28 changed files with 799 additions and 778 deletions

View file

@ -30,12 +30,12 @@ Example Use
template<typename T>
struct ExtractDataType
{
some_type operator()()
{
return create_value_from_type<T>;
}
};
{
some_type operator()()
{
return create_value_from_type<T>;
}
};
Loki::IterateTypes<parameter_tl, ExtractDataType> gendata;
std::vector<some_type> stuff;
@ -43,24 +43,24 @@ gendata(std::back_inserter(stuff));
*******************************************************************************/
namespace Loki
{
namespace TL
{
template<typename T>
struct nameof_type
{
const char* operator()()
{
return typeid(T).name();
}
};
template<typename T>
struct sizeof_type
{
size_t operator()()
{
return sizeof(T);
}
};
namespace TL
{
template<typename T>
struct nameof_type
{
const char* operator()()
{
return typeid(T).name();
}
};
template<typename T>
struct sizeof_type
{
size_t operator()()
{
return sizeof(T);
}
};
template <class TList, template <class> class GenFunc>
struct IterateTypes;
@ -75,8 +75,8 @@ namespace Loki
void operator()(II ii)
{
head.operator()(ii);
tail.operator()(ii);
}
tail.operator()(ii);
}
};
template <class AtomicType, template <class> class GenFunc>
@ -99,13 +99,13 @@ namespace Loki
{}
};
template<typename Types, template <class> class UnitFunc, typename II>
void iterate_types(II ii)
{
Loki::TL::IterateTypes<Types, UnitFunc> it;
it(ii);
}
}//ns TL
template<typename Types, template <class> class UnitFunc, typename II>
void iterate_types(II ii)
{
Loki::TL::IterateTypes<Types, UnitFunc> it;
it(ii);
}
}//ns TL
}//ns Loki
#endif //DATAGENERATORS_H

View file

@ -682,7 +682,7 @@ template <typename AP, typename Id, typename P1 >
Parm6, Parm7, Parm8, Parm9,Parm10,
Parm11,Parm12,Parm13,Parm14,Parm15 )
= 0;
};
};
#endif //LOKI_DISABLE_TYPELIST_MACROS
@ -1036,6 +1036,9 @@ template <typename AP, typename Id, typename P1 >
#endif // FACTORY_INC_
// $Log$
// Revision 1.9 2005/10/30 14:03:23 syntheticpp
// replace tabs space
//
// Revision 1.8 2005/10/30 13:49:44 syntheticpp
// make disabling the TYPELIST macros possible
//

View file

@ -18,8 +18,8 @@
namespace Loki
{
template<class R>
struct Function;
template<class R>
struct Function;
////////////////////////////////////////////////////////////////////////////////
// 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)>
////////////////////////////////////////////////////////////////////////////////
template<class R>
struct Function<R()> : public Functor<R>
{
typedef Functor<R> FBase;
template<class R>
struct Function<R()> : public Functor<R>
{
typedef Functor<R> FBase;
Function() : FBase() {}
Function() : FBase() {}
Function(const Function& func) : FBase()
{
if( !func.empty())
FBase::operator=(func);
}
// emptiness
template<class R2>
Function(Function<R2()> func) : FBase()
{
if(!func.empty())
FBase::operator=(func);
}
// clear by '= 0'
Function(const int i) : FBase()
{
if(i==0)
FBase::clear();
else
throw std::runtime_error("Loki::Function(const int i): i!=0");
}
template<class Func>
Function(Func func) : FBase(func) {}
Function(const Function& func) : FBase()
{
if( !func.empty())
FBase::operator=(func);
}
// emptiness
template<class R2>
Function(Function<R2()> func) : FBase()
{
if(!func.empty())
FBase::operator=(func);
}
// clear by '= 0'
Function(const int i) : FBase()
{
if(i==0)
FBase::clear();
else
throw std::runtime_error("Loki::Function(const int i): i!=0");
}
template<class Func>
Function(Func func) : FBase(func) {}
template<class Host, class Func>
Function(const Host& host, const Func& func) : FBase(host,func) {}
template<class Host, class Func>
Function(const Host& host, const Func& func) : FBase(host,func) {}
};
};
////////////////////////////////////////////////////////////////////////////////
// macros for the repetitions
////////////////////////////////////////////////////////////////////////////////
#define LOKI_FUNCTION_BODY \
\
Function() : FBase() {} \
\
Function(const Function& func) : FBase() \
{ \
if( !func.empty()) \
FBase::operator=(func); \
} \
\
Function(const int i) : FBase() \
{ \
if(i==0) \
FBase::clear(); \
else \
throw std::runtime_error( \
"Loki::Function(const int i): i!=0"); \
} \
\
template<class Func> \
Function(Func func) : FBase(func) {} \
\
template<class Host, class Func> \
Function(const Host& host, const Func& func): FBase(host,func) {}
#define LOKI_FUNCTION_BODY \
\
Function() : FBase() {} \
\
Function(const Function& func) : FBase() \
{ \
if( !func.empty()) \
FBase::operator=(func); \
} \
\
Function(const int i) : FBase() \
{ \
if(i==0) \
FBase::clear(); \
else \
throw std::runtime_error( \
"Loki::Function(const int i): i!=0"); \
} \
\
template<class Func> \
Function(Func func) : FBase(func) {} \
\
template<class Host, class Func> \
Function(const Host& host, const Func& func): FBase(host,func) {}
#define LOKI_FUNCTION_R2_CTOR_BODY \
\
: FBase() \
{ \
if(!func.empty()) \
FBase::operator=(func); \
}
#define LOKI_FUNCTION_R2_CTOR_BODY \
\
: FBase() \
{ \
if(!func.empty()) \
FBase::operator=(func); \
}
////////////////////////////////////////////////////////////////////////////////
// repetitions
////////////////////////////////////////////////////////////////////////////////
template<class R,class P01>
struct Function<R(P01)>
: public Loki::Functor<R, Seq<P01> >
{
typedef Functor<R, Seq<P01> > FBase;
template<class R2,class Q01>
Function(Function<R2(Q01)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R,class P01>
struct Function<R(P01)>
: public Loki::Functor<R, Seq<P01> >
{
typedef Functor<R, Seq<P01> > FBase;
template<class R2,class Q01>
Function(Function<R2(Q01)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R,class P01,class P02>
struct Function<R(P01,P02)>
: public Functor<R, Seq<P01,P02> >
{
typedef Functor<R, Seq<P01,P02> > FBase;
template<class R,class P01,class P02>
struct Function<R(P01,P02)>
: public Functor<R, Seq<P01,P02> >
{
typedef Functor<R, Seq<P01,P02> > FBase;
template<class R2,class Q01, class Q02>
Function(Function<R2(Q01,Q02)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R2,class Q01, class Q02>
Function(Function<R2(Q01,Q02)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R,class P01,class P02, class P03>
struct Function<R(P01,P02,P03)>
: public Functor<R, Seq<P01,P02,P03> >
{
typedef Functor<R, Seq<P01,P02,P03> > FBase;
template<class R,class P01,class P02, class P03>
struct Function<R(P01,P02,P03)>
: public Functor<R, Seq<P01,P02,P03> >
{
typedef Functor<R, Seq<P01,P02,P03> > FBase;
template<class R2,class Q01, class Q02,class Q03>
Function(Function<R2(Q01,Q02,Q03)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R2,class Q01, class Q02,class Q03>
Function(Function<R2(Q01,Q02,Q03)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R,class P01,class P02, class P03,class P04>
struct Function<R(P01,P02,P03,P04)>
: public Functor<R, Seq<P01,P02,P03,P04> >
{
typedef Functor<R, Seq<P01,P02,P03,P04> > FBase;
template<class R,class P01,class P02, class P03,class P04>
struct Function<R(P01,P02,P03,P04)>
: public Functor<R, Seq<P01,P02,P03,P04> >
{
typedef Functor<R, Seq<P01,P02,P03,P04> > FBase;
template<class R2,class Q01,class Q02, class Q03,class Q04>
Function(Function<R2(Q01,Q02,Q03,Q04)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R2,class Q01,class Q02, class Q03,class Q04>
Function(Function<R2(Q01,Q02,Q03,Q04)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R,class P01,class P02, class P03,class P04,class P05>
struct Function<R(P01,P02,P03,P04,P05)>
: public Functor<R, Seq<P01,P02,P03,P04,P05> >
{
typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase;
template<class R,class P01,class P02, class P03,class P04,class P05>
struct Function<R(P01,P02,P03,P04,P05)>
: public Functor<R, Seq<P01,P02,P03,P04,P05> >
{
typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase;
template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06>
struct Function<R(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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06>
struct Function<R(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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07>
struct Function<R(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;
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07>
struct Function<R(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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08>
struct Function<R(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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07, class Q08>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08>
struct Function<R(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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07, class Q08>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10,
class Q11>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10,
class Q11>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
class P11,class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10,
class Q11,class Q12>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
class P11,class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10,
class Q11,class Q12>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
class P11,class P12, class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10,
class Q11,class Q12, class Q13>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
class P11,class P12, class 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> >
{
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,
class Q06,class Q07, class Q08,class Q09,class Q10,
class Q11,class Q12, class Q13>
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
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)>
: 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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07, class Q08,class Q09,class Q10,
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)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
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)>
: 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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07, class Q08,class Q09,class Q10,
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)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
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)>
: 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;
template<class R, class P01,class P02, class P03,class P04,class P05,
class P06,class P07, class P08,class P09,class P10,
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)>
: 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;
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07, class Q08,class Q09,class Q10,
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)
LOKI_FUNCTION_R2_CTOR_BODY
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
class Q06,class Q07, class Q08,class Q09,class Q10,
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)
LOKI_FUNCTION_R2_CTOR_BODY
LOKI_FUNCTION_BODY
};
LOKI_FUNCTION_BODY
};
}// namespace Loki

View file

@ -105,7 +105,7 @@ namespace Loki
virtual R operator()() = 0;
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 1 parameter
////////////////////////////////////////////////////////////////////////////////
@ -1111,12 +1111,12 @@ namespace Loki
#ifdef LOKI_ENABLE_FUNCTION
class bad_function_call : public std::runtime_error
{
public:
bad_function_call() : std::runtime_error("bad_function_call in Loki::Functor")
{}
};
class bad_function_call : public std::runtime_error
{
public:
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();
@ -1195,100 +1195,100 @@ namespace Loki
#ifdef LOKI_ENABLE_FUNCTION
bool empty() const
{
return spImpl_.get() == 0;
}
bool empty() const
{
return spImpl_.get() == 0;
}
void clear()
{
spImpl_.reset(0);
}
void clear()
{
spImpl_.reset(0);
}
#endif
ResultType operator()() const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)();
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)();
}
ResultType operator()(Parm1 p1) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1);
}
ResultType operator()(Parm1 p1, Parm2 p2) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2);
}
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3);
}
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
Parm6 p6) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
Parm6 p6, Parm7 p7) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
Parm6 p6, Parm7 p7, Parm8 p8) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) const
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
}
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
{
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
}
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
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,
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
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,
p12);
}
@ -1297,7 +1297,7 @@ namespace Loki
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
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,
p12, p13);
}
@ -1306,7 +1306,7 @@ namespace Loki
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
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,
p12, p13, p14);
}
@ -1315,7 +1315,7 @@ namespace Loki
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
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,
p12, p13, p14, p15);
}

View file

@ -37,18 +37,18 @@ namespace Loki
namespace Private
{
template <class SomeLhs, class SomeRhs,
class Executor, typename ResultType>
class Executor, typename ResultType>
struct InvocationTraits
{
static ResultType
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
Executor& exec, Int2Type<false>)
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
Executor& exec, Int2Type<false>)
{
return exec.Fire(lhs, rhs);
}
static ResultType
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
Executor& exec, Int2Type<true>)
DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
Executor& exec, Int2Type<true>)
{
return exec.Fire(rhs, lhs);
}
@ -157,15 +157,15 @@ namespace Loki
// Non-inline to reduce compile time overhead...
template <class BaseLhs, class BaseRhs,
typename ResultType, typename CallbackType>
typename ResultType, typename 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;
}
template <class BaseLhs, class BaseRhs,
typename ResultType, typename CallbackType>
typename ResultType, typename CallbackType>
bool BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
::DoRemove(TypeInfo lhs, TypeInfo rhs)
{
@ -173,11 +173,11 @@ namespace Loki
}
template <class BaseLhs, class BaseRhs,
typename ResultType, typename CallbackType>
typename ResultType, typename CallbackType>
ResultType BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
::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);
if (i == callbackMap_.end())
{
@ -222,7 +222,7 @@ namespace Loki
namespace Private
{
template <class BaseLhs, class BaseRhs,
class SomeLhs, class SomeRhs,
class SomeLhs, class SomeRhs,
typename ResultType,
class CastLhs, class CastRhs,
ResultType (*Callback)(SomeLhs&, SomeRhs&)>
@ -266,13 +266,13 @@ namespace Loki
ResultType (*callback)(SomeLhs&, SomeRhs&)>
void Add()
{
typedef Private::FnDispatcherHelper<
BaseLhs, BaseRhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs,BaseLhs>,
CastingPolicy<SomeRhs,BaseRhs>,
callback> Local;
typedef Private::FnDispatcherHelper<
BaseLhs, BaseRhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs,BaseLhs>,
CastingPolicy<SomeRhs,BaseRhs>,
callback> Local;
Add<SomeLhs, SomeRhs>(&Local::Trampoline);
}
@ -282,13 +282,13 @@ namespace Loki
bool symmetric>
void Add(bool = true) // [gcc] dummy bool
{
typedef Private::FnDispatcherHelper<
BaseLhs, BaseRhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs,BaseLhs>,
CastingPolicy<SomeRhs,BaseRhs>,
callback> Local;
typedef Private::FnDispatcherHelper<
BaseLhs, BaseRhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs,BaseLhs>,
CastingPolicy<SomeRhs,BaseRhs>,
callback> Local;
Add<SomeLhs, SomeRhs>(&Local::Trampoline);
if (symmetric)
@ -316,11 +316,11 @@ namespace Loki
namespace Private
{
template <class BaseLhs, class BaseRhs,
class SomeLhs, class SomeRhs,
typename ResultType,
class CastLhs, class CastRhs,
class Fun, bool SwapArgs>
template <class BaseLhs, class BaseRhs,
class SomeLhs, class SomeRhs,
typename ResultType,
class CastLhs, class CastRhs,
class Fun, bool SwapArgs>
class FunctorDispatcherHelper
{
Fun fun_;
@ -365,33 +365,33 @@ namespace Loki
void Add(const Fun& fun)
{
typedef Private::FunctorDispatcherHelper<
BaseLhs, BaseRhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs, BaseLhs>,
CastingPolicy<SomeRhs, BaseRhs>,
Fun, false> Adapter;
BaseLhs, BaseRhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs, BaseLhs>,
CastingPolicy<SomeRhs, BaseRhs>,
Fun, false> Adapter;
backEnd_.template Add<SomeLhs, SomeRhs>(FunctorType(Adapter(fun)));
}
}
template <class SomeLhs, class SomeRhs, bool symmetric, class Fun>
void Add(const Fun& fun)
{
Add<SomeLhs,SomeRhs>(fun);
Add<SomeLhs,SomeRhs>(fun);
if (symmetric)
{
// Note: symmetry only makes sense where BaseLhs==BaseRhs
typedef Private::FunctorDispatcherHelper<
BaseLhs, BaseLhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs, BaseLhs>,
CastingPolicy<SomeRhs, BaseLhs>,
Fun, true> AdapterR;
if (symmetric)
{
// Note: symmetry only makes sense where BaseLhs==BaseRhs
typedef Private::FunctorDispatcherHelper<
BaseLhs, BaseLhs,
SomeLhs, SomeRhs,
ResultType,
CastingPolicy<SomeLhs, BaseLhs>,
CastingPolicy<SomeRhs, BaseLhs>,
Fun, true> AdapterR;
backEnd_.template Add<SomeRhs, SomeLhs>(FunctorType(AdapterR(fun)));
}
}
}
template <class SomeLhs, class SomeRhs>

View file

@ -165,7 +165,7 @@ namespace Loki
};
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:
OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p)

View file

@ -319,7 +319,7 @@ private:
#ifdef _MSC_VER
const int stored = _snprintf(resultBuf,
#else
const int stored = snprintf(resultBuf,
const int stored = snprintf(resultBuf,
#endif
sizeof(resultBuf) / sizeof(Char), fmtBuf, n);
if (stored < 0) {
@ -408,14 +408,14 @@ private:
}
void ParseDecimalUInt(unsigned int& dest) {
if (!std::isdigit(*format_, std::locale())) return;
if (!std::isdigit(*format_, std::locale())) return;
unsigned int r = 0;
do {
// TODO: inefficient - rewrite
r *= 10;
r += *format_ - '0';
++format_;
} while (std::isdigit(*format_, std::locale()));
} while (std::isdigit(*format_, std::locale()));
dest = r;
}

View file

@ -309,7 +309,7 @@ namespace Loki
std::size_t objectAlignSize,
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)
@ -324,7 +324,7 @@ namespace Loki
/// Defines singleton made from allocator.
typedef Loki::SingletonHolder< MyAllocator, Loki::CreateStatic,
LifetimePolicy, ThreadingModel > MyAllocatorSingleton;
public:
/// Throwing single-object new throws bad_alloc when allocation fails.
@ -513,6 +513,9 @@ namespace Loki
// Nov. 26, 2004: re-implemented by Rich Sposato.
//
// $Log$
// Revision 1.18 2005/10/30 14:03:23 syntheticpp
// replace tabs space
//
// Revision 1.17 2005/10/29 08:10:13 syntheticpp
// #undef LOKI_SMALL_OBJECT_USE_NEW_ARRAY when using a Microsoft compiler
//

View file

@ -53,7 +53,7 @@ namespace Loki
{
Lock() {}
explicit Lock(const SingleThreaded&) {}
explicit Lock(const SingleThreaded*) {}
explicit Lock(const SingleThreaded*) {}
};
typedef Host VolatileType;
@ -125,9 +125,9 @@ namespace Loki
pthread_mutex_unlock(&atomic_mutex_)
#define LOKI_THREADS_ATOMIC_FUNCTIONS \
private: \
static pthread_mutex_t atomic_mutex_; \
public: \
private: \
static pthread_mutex_t atomic_mutex_; \
public: \
static IntType AtomicIncrement(volatile IntType& lval) \
{ LOKI_THREADS_ATOMIC( lval++ ); return lval; } \
\
@ -184,7 +184,7 @@ namespace Loki
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_);
}
@ -195,7 +195,7 @@ namespace Loki
}
private:
Lock();
Lock();
Lock(const Lock&);
Lock& operator=(const Lock&);
const ObjectLevelLockable& host_;
@ -210,7 +210,7 @@ namespace Loki
};
#if defined(_PTHREAD_H)
template <class Host>
template <class Host>
pthread_mutex_t ObjectLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER);
#endif
@ -264,7 +264,7 @@ namespace Loki
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
}
explicit Lock(const ClassLevelLockable*)
explicit Lock(const ClassLevelLockable*)
{
assert(initializer_.init_);
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
@ -290,7 +290,7 @@ namespace Loki
};
#if defined(_PTHREAD_H)
template <class Host>
template <class Host>
pthread_mutex_t ClassLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER);
#endif
@ -314,6 +314,9 @@ namespace Loki
#endif
// $Log$
// Revision 1.16 2005/10/30 14:03:23 syntheticpp
// replace tabs space
//
// Revision 1.15 2005/10/24 20:35:12 syntheticpp
// small changes for Threads; add compile test for Threads.h
//

View file

@ -226,7 +226,7 @@ struct SuperSubclassStrict
template<>
struct SuperSubclassStrict<void, void>
{
enum { value = false };
enum { value = false };
};
template<class U>

View file

@ -65,7 +65,7 @@ namespace Loki
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)
StdUnsignedInts;
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)
StdFloats;
#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;
typedef Loki::Seq<signed char, short int,int, long int>::Type
StdSignedInts;

View file

@ -211,7 +211,7 @@ namespace Loki
typedef NullType Result;
};
template <class T> struct Append<NullType, T>
template <class T> struct Append<NullType, T>
{
typedef Typelist<T,NullType> Result;
};

View file

@ -158,7 +158,7 @@ struct DefaultCatchAll
////////////////////////////////////////////////////////////////////////////////
#define LOKI_DEFINE_VISITABLE() \
virtual ReturnType Accept(::Loki::BaseVisitor& guest) \
virtual ReturnType Accept(::Loki::BaseVisitor& guest) \
{ return AcceptImpl(*this, guest); }
////////////////////////////////////////////////////////////////////////////////

View file

@ -66,7 +66,7 @@ typedef SingletonHolder
#ifndef USE_SEQUENCE
Factory< AbstractProduct, int, LOKI_TYPELIST_2( int, int ) >
#else
Factory< AbstractProduct, int, Seq< int, int > >
Factory< AbstractProduct, int, Seq< int, int > >
#endif
>
PFactory;
@ -163,7 +163,7 @@ SingletonHolder
#ifndef USE_SEQUENCE
Factory< AbstractProduct, int,LOKI_TYPELIST_3(CreateFunctor,int,int) >
#else
Factory< AbstractProduct, int,Seq<CreateFunctor,int,int> >
Factory< AbstractProduct, int,Seq<CreateFunctor,int,int> >
#endif
>
PFactoryFunctorParm;
@ -249,6 +249,9 @@ int main(int argc, char *argv[])
}
// $Log$
// Revision 1.5 2005/10/30 14:03:23 syntheticpp
// replace tabs space
//
// Revision 1.4 2005/10/30 13:49:44 syntheticpp
// make disabling the TYPELIST macros possible
//

View file

@ -1,9 +1,9 @@
// Boost.Function library
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// 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;}};
#endif
static void write_five() {global_int = 5;}
static void write_three() {global_int = 3;}
struct generate_five_obj {int operator()() const {return 5;}};
struct generate_three_obj {int operator()() const {return 3;}};
static int generate_five() {return 5;}
static int generate_three() {return 3;}
static void write_five() {global_int = 5;}
static void write_three() {global_int = 3;}
struct generate_five_obj {int operator()() const {return 5;}};
struct generate_three_obj {int operator()() const {return 3;}};
static int generate_five() {return 5;}
static int generate_three() {return 3;}
static string identity_str(const string& s){return s;}
static string string_cat(const string& s1, const string& s2){return s1+s2;}
static int sum_ints(int x, int y){return x+y;}
struct write_const_1_nonconst_2
{
void operator()(){global_int = 2;}
void operator()() const {global_int = 1;}
void operator()(){global_int = 2;}
void operator()() const {global_int = 1;}
};
struct add_to_obj
{
@ -645,7 +645,7 @@ static void test_member_functions()
Loki::Function<int ()> f1_2(&one,&X::twice);
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);
#endif
@ -698,12 +698,12 @@ static void test_ref()
try
{
#ifndef TEST_LOKI_FUNCTION
boost::function<int (int, int)> f(ref(atc));
BOOST_CHECK(f(1, 3) == 4);
boost::function<int (int, int)> f(ref(atc));
BOOST_CHECK(f(1, 3) == 4);
#else
//TODO: implement Loki::Ref
//Loki::Function<int (int, int)> f(Loki::ref(atc));
//BOOST_CHECK(f(1, 3) == 4);
//TODO: implement Loki::Ref
//Loki::Function<int (int, int)> f(Loki::ref(atc));
//BOOST_CHECK(f(1, 3) == 4);
#endif
}
@ -731,7 +731,7 @@ static void test_exception()
#else
catch(Loki::bad_function_call)
#endif
{
{
// okay
}
}

View file

@ -6,35 +6,35 @@
struct L1
{
L1(){std::cout << "create L1: " << this << "\n";}
~L1(){std::cout << "delete L1: " << this <<" \n";}
L1(){std::cout << "create L1: " << this << "\n";}
~L1(){std::cout << "delete L1: " << this <<" \n";}
};
struct L2
{
L2(){std::cout << "create L2 \n";}
~L2(){std::cout << "delete L2 \n";}
L2(){std::cout << "create L2 \n";}
~L2(){std::cout << "delete L2 \n";}
};
struct L3
{
L3(){std::cout << "create L3 \n";}
~L3(){std::cout << "delete L3 \n";}
L3(){std::cout << "create L3 \n";}
~L3(){std::cout << "delete L3 \n";}
};
int main()
{
Loki::SetLongevity
(new L1, 1);
Loki::SetLongevity<L1, void (*)(L1*)>
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
Loki::SetLongevity<L1, Loki::Private::Deleter<L1>::Type>
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
Loki::SetLongevity(new L2, 2);
Loki::SetLongevity(new L1, 1);
Loki::SetLongevity(new L3, 3);
Loki::SetLongevity(new L1, 1);
Loki::SetLongevity
(new L1, 1);
Loki::SetLongevity<L1, void (*)(L1*)>
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
Loki::SetLongevity<L1, Loki::Private::Deleter<L1>::Type>
(new L1, 1, Loki::Private::Deleter<L1>::Delete);
Loki::SetLongevity(new L2, 2);
Loki::SetLongevity(new L1, 1);
Loki::SetLongevity(new L3, 3);
Loki::SetLongevity(new L1, 1);
std::cout << "\n";
std::cout << "\n";
}

View file

@ -27,32 +27,32 @@
struct L1
{
L1(){std::cout << "create L1: " << this << "\n";}
~L1(){std::cout << "delete L1: " << this <<" \n";}
L1(){std::cout << "create L1: " << this << "\n";}
~L1(){std::cout << "delete L1: " << this <<" \n";}
};
struct L2
{
L2(){std::cout << "create L2 \n";}
~L2(){std::cout << "delete L2 \n";}
L2(){std::cout << "create L2 \n";}
~L2(){std::cout << "delete L2 \n";}
};
struct M1
{
M1(){std::cout << "create M1 \n";}
~M1(){std::cout << "delete M1 \n";}
M1(){std::cout << "create M1 \n";}
~M1(){std::cout << "delete M1 \n";}
};
struct M2
{
M2(){std::cout << "create M2 \n";}
~M2(){std::cout << "delete M2 \n";}
M2(){std::cout << "create M2 \n";}
~M2(){std::cout << "delete M2 \n";}
};
int f()
{
std::cout << "f called \n";
return 0;
std::cout << "f called \n";
return 0;
}
std::string func();
@ -62,8 +62,8 @@ std::string func();
struct MemberTest
{
static Loki::OrderedStatic<1,M1> m1;
static Loki::OrderedStatic<2,M2> m2;
static Loki::OrderedStatic<1,M1> m1;
static Loki::OrderedStatic<2,M2> m2;
};
Loki::OrderedStatic<1,M1> MemberTest::m1;
Loki::OrderedStatic<2,M2> MemberTest::m2;
@ -72,8 +72,8 @@ Loki::OrderedStatic<2,M2> MemberTest::m2;
Loki::OrderedStatic<1,L1> l1;
Loki::OrderedStatic<2,L2> l2;
Loki::OrderedStatic<1, std::string, std::string(*)() > s1( &func );
Loki::OrderedStatic<2, std::string, Loki::Seq<char *> > s2( "s2" );
Loki::OrderedStatic<1, std::string, std::string(*)() > s1( &func );
Loki::OrderedStatic<2, std::string, Loki::Seq<char *> > s2( "s2" );
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
{
static M1 m1;
static M2 m2;
static M1 m1;
static M2 m2;
};
M1 MemberTest::m1;
M2 MemberTest::m2;
@ -101,42 +101,42 @@ Loki::Functor<int> f1(f);
std::string func()
{
#ifdef TEST_ORDERED_STATIC
return *s2;
return *s2;
#else
return s2;
return s2;
#endif
}
int main()
{
{
#ifdef TEST_ORDERED_STATIC
Loki::OrderedStaticManager::Instance().createObjects();
std::cout << "\n";
Loki::OrderedStaticManager::Instance().createObjects();
std::cout << "\n";
(*f1)();
(*f1)();
std::cout << "value of s1: " << (*s1).c_str() << "\n";
std::cout << "value of s2: " << (*s2).c_str() << "\n";
std::string s("text11");
*s1=s;
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::string s("text11");
*s1=s;
std::cout << "value of s1: " << (*s1).c_str() << "\n";
#else
std::cout << "\n";
f1();
std::cout << "s1 = " << s1.c_str() << "\n";
std::cout << "s2 = " << s2.c_str() << "\n";
std::cout << "\n";
f1();
std::cout << "s1 = " << s1.c_str() << "\n";
std::cout << "s2 = " << s2.c_str() << "\n";
#endif
std::cout << "\n";
return 0;
std::cout << "\n";
return 0;
}

View file

@ -39,18 +39,18 @@ public:
#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 &)> classFunctor(&testClass,&TestClass::member);
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy(function);
Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
#else
Functor<void,Seq<bool &> > function(testFunction);
Functor<void,Seq<bool &> > function(testFunction);
Functor<void,Seq<bool &> > functor(testFunctor);
Functor<void,Seq<bool &> > classFunctor(&testClass,&TestClass::member);
Functor<void,Seq<bool &> > functorCopy(function);
//TODO:
//TODO:
//Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
//Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
#endif
@ -83,8 +83,8 @@ public:
r=functionResult && functorResult && classFunctorResult && functorCopyResult && bindFunctorResult &&
chainFunctorResult;
#else
//TODO!
r=functionResult && functorResult && classFunctorResult && functorCopyResult;
//TODO!
r=functionResult && functorResult && classFunctorResult && functorCopyResult;
#endif
testAssert("Functor",r,result);

View file

@ -33,7 +33,7 @@ public:
using namespace Loki;
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,char>::Type CharIntDoubleCharList;
typedef Seq<Base,Derived1,Derived2>::Type BaseDerived1Derived2List;

View file

@ -162,12 +162,12 @@ private:
} smallObjectTest;
#ifndef SMALLOBJ_CPP
# define SMALLOBJ_CPP
# ifdef LOKI_NONCC
# include "../../include/noncc/loki/SmallObj.cpp"
# else
# include "../../src/SmallObj.cpp"
# endif
# define SMALLOBJ_CPP
# ifdef LOKI_NONCC
# include "../../include/noncc/loki/SmallObj.cpp"
# else
# include "../../src/SmallObj.cpp"
# endif
#endif

View file

@ -19,44 +19,44 @@
namespace ThreadsTestPrivate
{
class SingleLevel : public Loki::SingleThreaded<SingleLevel>
{
int i;
public:
void test()
{
Lock lock0;
Lock lock(*this);
Lock lockThis(this);
i++;
}
};
class SingleLevel : public Loki::SingleThreaded<SingleLevel>
{
int i;
public:
void test()
{
Lock lock0;
Lock lock(*this);
Lock lockThis(this);
i++;
}
};
class ClassLevel : public Loki::ClassLevelLockable<ClassLevel>
{
int i;
public:
void test()
{
Lock lock0;
Lock lock(*this);
Lock lockThis(this);
i++;
}
};
class ClassLevel : public Loki::ClassLevelLockable<ClassLevel>
{
int i;
public:
void test()
{
Lock lock0;
Lock lock(*this);
Lock lockThis(this);
i++;
}
};
class ObjectLevel : public Loki::ObjectLevelLockable<ObjectLevel>
{
int i;
public:
void test()
{
//Lock lock0_must_not_compile;
Lock lock(*this);
Lock lockThis(this);
i++;
}
};
class ObjectLevel : public Loki::ObjectLevelLockable<ObjectLevel>
{
int i;
public:
void test()
{
//Lock lock0_must_not_compile;
Lock lock(*this);
Lock lockThis(this);
i++;
}
};
}
class ThreadsTest : public Test
@ -68,7 +68,7 @@ public:
{
printName(result);
bool r = true; // TODO some tests
bool r = true; // TODO some tests
testAssert("Threads",r,result);

View file

@ -105,7 +105,7 @@ public:
SameType<TypeTraits<int>::ParameterType,int>::value &&
SameType<TypeTraits<double>::ParameterType,double>::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);

View file

@ -180,7 +180,7 @@ private:
void testFunction();
void testFunctionPointer();
void testMemberFunctionPointer();
void testMemberFunctionPointer();
void testParameterType();
void testReferredType();
@ -220,7 +220,7 @@ inline void TypeTraitsTest2::execute(TestResult &result)
testFunction();
testFunctionPointer();
testMemberFunctionPointer();
testMemberFunctionPointer();
bool r = erroneousConditions_ == 0;
@ -581,7 +581,7 @@ inline void TypeTraitsTest2::testFunction()
#undef CONDITION
#define CONDITION isFunction
testBegin("isFunction");
testBegin("isFunction");
PASS(void());
PASS(void(int, float, ...));
@ -597,9 +597,9 @@ inline void TypeTraitsTest2::testFunctionPointer()
#undef CONDITION
#define CONDITION isFunctionPointer
testBegin("isFunctionPointer");
testBegin("isFunctionPointer");
PASS(void (*)());
PASS(void (*)());
FAIL(void (A::* const volatile)());
FAIL(void (A::* const volatile)() const);
FAIL(void (A::* const volatile)() volatile);
@ -624,7 +624,7 @@ inline void TypeTraitsTest2::testMemberFunctionPointer()
#undef CONDITION
#define CONDITION isMemberFunctionPointer
testBegin("isMemberFunctionPointer");
testBegin("isMemberFunctionPointer");
PASS(void (A::* const volatile)());
PASS(void (A::* const volatile)() const);

View file

@ -35,7 +35,7 @@ public:
using namespace Loki::TL;
#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_4(char,int,double,char) CharIntDoubleCharList;
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(Derived1,Base,Derived1,Derived2) Derived1BaseDerived1Derived2List;
#else
typedef Seq<char>::Type CharList;
typedef Seq<char,int,double>::Type CharIntDoubleList;
typedef Seq<char>::Type CharList;
typedef Seq<char,int,double>::Type CharIntDoubleList;
typedef Seq<char,int,double,char>::Type CharIntDoubleCharList;
typedef Seq<Base,Derived1,Derived2>::Type BaseDerived1Derived2List;
typedef Seq<Derived2,Derived1,Base>::Type Derived2Derived1BaseList;
@ -179,8 +179,8 @@ public:
#else //LOKI_DISABLE_TYPELIST_MACROS
r=SameType<Append<NullType,NullType>::Result,NullType>::value &&
SameType<Append<NullType,char>::Result,Seq<char>::Type >::value &&
r=SameType<Append<NullType,NullType>::Result,NullType>::value &&
SameType<Append<NullType,char>::Result,Seq<char>::Type >::value &&
SameType<Append<NullType,CharList>::Result,CharList>::value &&
SameType<Append<CharList,NullType>::Result,CharList>::value &&
SameType<Append<CharList,int>::Result,Seq<char,int>::Type >::value &&
@ -254,7 +254,7 @@ public:
SameType<DerivedToFront<CharIntDoubleCharList>::Result,CharIntDoubleCharList>::value &&
SameType<DerivedToFront<BaseDerived1Derived2List>::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;
testAssert("DerivedToFront",r,result);

View file

@ -58,7 +58,7 @@ void TestCase(const string& fmt, T value) {
#ifdef _MSC_VER
const int i2 = _snprintf(buf, sizeof(buf), fmt.c_str(), value);
#else
const int i2 = snprintf(buf, sizeof(buf), fmt.c_str(), value);
const int i2 = snprintf(buf, sizeof(buf), fmt.c_str(), value);
#endif
if (i1 != i2 || s != buf) {

View file

@ -27,7 +27,7 @@
//#define COMPARE_BOOST_POOL
#ifdef COMPARE_BOOST_POOL
#include <boost\pool\object_pool.hpp>
#include <boost\pool\object_pool.hpp>
#endif
using namespace std;
@ -36,14 +36,14 @@ using namespace std;
template<unsigned int N>
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
{};
template<unsigned int N>
template<unsigned int N>
struct Base<N, void> : public ThisIsASmallObject<N>
{};
@ -54,51 +54,51 @@ template<unsigned int N>
class BoostPoolNew : public Base<N,void>
{
private:
static boost::object_pool< BoostPoolNew<N> > BoostPool;
static boost::object_pool< BoostPoolNew<N> > BoostPool;
public:
/// Throwing single-object new throws bad_alloc when allocation fails.
/// Throwing single-object new throws bad_alloc when allocation fails.
#ifdef _MSC_VER
/// @note MSVC complains about non-empty exception specification lists.
static void * operator new ( std::size_t )
/// @note MSVC complains about non-empty exception specification lists.
static void * operator new ( std::size_t )
#else
static void * operator new ( std::size_t ) throw ( std::bad_alloc )
static void * operator new ( std::size_t ) throw ( std::bad_alloc )
#endif
{
return BoostPool.malloc();
}
{
return BoostPool.malloc();
}
/// Non-throwing single-object new returns NULL if allocation fails.
static void * operator new ( std::size_t, const std::nothrow_t & ) throw ()
{
return BoostPool.malloc();
}
/// Non-throwing single-object new returns NULL if allocation fails.
static void * operator new ( std::size_t, const std::nothrow_t & ) throw ()
{
return BoostPool.malloc();
}
/// Placement single-object new merely calls global placement new.
inline static void * operator new ( std::size_t size, void * place )
{
return ::operator new( size, place );
}
/// Placement single-object new merely calls global placement new.
inline static void * operator new ( std::size_t size, void * place )
{
return ::operator new( size, place );
}
/// Single-object delete.
static void operator delete ( void * p ) throw ()
{
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
}
/// Single-object delete.
static void operator delete ( void * p ) throw ()
{
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
}
/** Non-throwing single-object delete is only called when nothrow
new operator is used, and the constructor throws an exception.
*/
static void operator delete ( void * p, const std::nothrow_t & ) throw()
{
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
}
/** Non-throwing single-object delete is only called when nothrow
new operator is used, and the constructor throws an exception.
*/
static void operator delete ( void * p, const std::nothrow_t & ) throw()
{
BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
}
/// Placement single-object delete merely calls global placement delete.
inline static void operator delete ( void * p, void * place )
{
::operator delete ( p, place );
}
/// Placement single-object delete merely calls global placement delete.
inline static void operator delete ( void * p, void * place )
{
::operator delete ( p, place );
}
};
@ -112,205 +112,208 @@ int array_test_nr = 0;
double t100_new = 0;
double t100_delete = 0;
#define LOKI_SMALLOBJ_BENCH(FUNC, CODE_LOOP) \
template<class T, int TN> \
int FUNC(void**, const int N, int loop, Timer& t, const char* s) \
{ \
t.start(); \
/****************************************************************/ \
for (int i=0; i<loop; ++i) \
{ \
CODE_LOOP \
} \
/****************************************************************/ \
t.stop(); \
if(array_test_nr==0) \
t.t100 = t.t(); \
array_test_nr++; \
t.print(t.t(),s); \
return t.t(); \
#define LOKI_SMALLOBJ_BENCH(FUNC, CODE_LOOP) \
template<class T, int TN> \
int FUNC(void**, const int N, int loop, Timer& t, const char* s) \
{ \
t.start(); \
/****************************************************************/ \
for (int i=0; i<loop; ++i) \
{ \
CODE_LOOP \
} \
/****************************************************************/ \
t.stop(); \
if(array_test_nr==0) \
t.t100 = t.t(); \
array_test_nr++; \
t.print(t.t(),s); \
return t.t(); \
}
#define LOKI_SMALLOBJ_BENCH_ARRAY(FUNC, CODE_DECL, CODE_NEW, CODE_DELETE) \
template<class T, int TN> \
int FUNC(void** arrv, const int N, int loop, Timer& t, const char* s) \
{ \
\
CODE_DECL; \
T** arr = reinterpret_cast<T**>(arrv); \
t.start(); \
/****************************************************************/ \
for (int i=0; i<loop; ++i) \
{ \
CODE_NEW \
} \
/****************************************************************/ \
t.stop(); \
cout << "1. "; \
if(array_test_nr==0) \
{ \
t.t100 = t.t(); \
t100_new = t.t100; \
} \
else \
t.t100 = t100_new; \
t.print(t.t(),s); \
\
if(array_test_nr==3) \
{ \
cout << \
"2. boost :\tboost::object_pool is not tested because it's too slow"\
<< endl << endl; \
array_test_nr++; \
return t.t(); \
} \
t.start(); \
/****************************************************************/ \
for (int i=0; i<loop; ++i) \
{ \
CODE_DELETE \
} \
/****************************************************************/ \
t.stop(); \
cout << "2. "; \
if(array_test_nr==0) \
{ \
t.t100 = t.t(); \
t100_delete = t.t100; \
} \
else \
t.t100 = t100_delete; \
t.print(t.t(),s); \
array_test_nr++; \
cout << endl; \
return t.t(); \
#define LOKI_SMALLOBJ_BENCH_ARRAY(FUNC, CODE_DECL, CODE_NEW, CODE_DELETE) \
template<class T, int TN> \
int FUNC(void** arrv, const int N, int loop, Timer& t, const char* s) \
{ \
\
CODE_DECL; \
T** arr = reinterpret_cast<T**>(arrv); \
t.start(); \
/****************************************************************/ \
for (int i=0; i<loop; ++i) \
{ \
CODE_NEW \
} \
/****************************************************************/ \
t.stop(); \
cout << "1. "; \
if(array_test_nr==0) \
{ \
t.t100 = t.t(); \
t100_new = t.t100; \
} \
else \
t.t100 = t100_new; \
t.print(t.t(),s); \
\
if(array_test_nr==3) \
{ \
cout << \
"2. boost :\tboost::object_pool is not tested because it's too slow"\
<< endl << endl; \
array_test_nr++; \
return t.t(); \
} \
t.start(); \
/****************************************************************/ \
for (int i=0; i<loop; ++i) \
{ \
CODE_DELETE \
} \
/****************************************************************/ \
t.stop(); \
cout << "2. "; \
if(array_test_nr==0) \
{ \
t.t100 = t.t(); \
t100_delete = t.t100; \
} \
else \
t.t100 = t100_delete; \
t.print(t.t(),s); \
array_test_nr++; \
cout << endl; \
return t.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_all ,std::allocator<T> st;st.deallocate(st.allocate(1), 1);)
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_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_all,std::allocator<T[TN]> st;st.deallocate(st.allocate(1), 1);)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr , , arr[i] = new T; ,
delete arr[i];)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr , , arr[i] = new T; ,
delete arr[i];)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr_mal, , arr[i] = static_cast<T*>(std::malloc(sizeof(T))); ,
std::free(arr[i]);)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr_all, std::allocator<T> st ,
arr[i]=st.allocate(1); ,
st.deallocate(arr[i], 1);)
std::free(arr[i]);)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr_all, std::allocator<T> st ,
arr[i]=st.allocate(1); ,
st.deallocate(arr[i], 1);)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a , , arr[i] = new T[TN]; ,
delete[] arr[i];)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_a_on_a , , arr[i] = new T[TN]; ,
delete[] arr[i];)
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 ,
arr[i]=reinterpret_cast<T*>(st.allocate(1)); ,
st.deallocate(reinterpret_cast<T(*)[TN]>(arr[i]), 1);)
arr[i]=reinterpret_cast<T*>(st.allocate(1)); ,
st.deallocate(reinterpret_cast<T(*)[TN]>(arr[i]), 1);)
#ifndef COMPARE_BOOST_POOL
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
array_test_nr = 0; \
cout << MESSAGE << endl; \
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
cout << endl << endl;
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
array_test_nr = 0; \
cout << MESSAGE << endl; \
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
cout << endl << endl;
#else
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
array_test_nr = 0; \
cout << MESSAGE << endl; \
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
FUNC<D,N>(a,N,LOOP,TIMER,"boost :"); \
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
cout << endl << endl;
#define LOKI_SMALLOBJBECH_ABCD(FUNC,N,LOOP,TIMER,MESSAGE) \
array_test_nr = 0; \
cout << MESSAGE << endl; \
FUNC<A,N>(a,N,LOOP,TIMER,"new :"); \
FUNC<B,N>(a,N,LOOP,TIMER,"SmallObj :"); \
FUNC<C,N>(a,N,LOOP,TIMER,"ValueObj :"); \
FUNC<D,N>(a,N,LOOP,TIMER,"boost :"); \
FUNC##_all<A,N>(a,N,LOOP,TIMER,"allocator:"); \
FUNC##_mal<A,N>(a,N,LOOP,TIMER,"malloc :"); \
cout << endl << endl;
#endif
template<unsigned int Size, int loop>
void testSize()
{
typedef Base<Size, void> A;
typedef Base<Size, Loki::SmallObject< Loki::SingleThreaded > > B;
typedef Base<Size, Loki::SmallValueObject< Loki::SingleThreaded > > C;
typedef Base<Size, void> A;
typedef Base<Size, Loki::SmallObject< Loki::SingleThreaded > > B;
typedef Base<Size, Loki::SmallValueObject< Loki::SingleThreaded > > C;
#ifdef COMPARE_BOOST_POOL
typedef BoostPoolNew<Size> D;
typedef BoostPoolNew<Size> D;
#endif
cout << endl << endl;
cout << "Allocator Benchmark Tests with " << Size << " bytes big objects " << endl;
cout << endl;
cout << "new = global new/delete \tsizeof(A) = " << sizeof(A) << endl;
cout << "SmallObj = Loki::SmallObject \tsizeof(B) = " << sizeof(B) << endl;
cout << "ValueObj = Loki::SmallValueObject\tsizeof(C) = " << sizeof(C) << endl;
cout << endl << endl;
cout << "Allocator Benchmark Tests with " << Size << " bytes big objects " << endl;
cout << endl;
cout << "new = global new/delete \tsizeof(A) = " << sizeof(A) << endl;
cout << "SmallObj = Loki::SmallObject \tsizeof(B) = " << sizeof(B) << endl;
cout << "ValueObj = Loki::SmallValueObject\tsizeof(C) = " << sizeof(C) << endl;
#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
cout << "allocator= std::allocator \tsizeof(A) = " << sizeof(A) << endl;
cout << "malloc = std::malloc/free \tsizeof(A) = " << sizeof(A) << endl;
cout << endl << endl;
cout << "allocator= std::allocator \tsizeof(A) = " << sizeof(A) << endl;
cout << "malloc = std::malloc/free \tsizeof(A) = " << sizeof(A) << endl;
cout << endl << endl;
Timer t;
Timer t;
const int N = 3;
int Narr = 1000*1000;
const int N = 3;
int Narr = 1000*1000;
void** a= new void*[Narr];
void** a= new void*[Narr];
cout << loop << " times ";
LOKI_SMALLOBJBECH_ABCD(delete_new ,0,loop,t,"'delete new T'");
cout << "N=" << N <<" : " << loop << " times ";
LOKI_SMALLOBJBECH_ABCD(delete_new_array ,N,loop,t,"'delete[] new T[N]'");
cout << loop << " times ";
LOKI_SMALLOBJBECH_ABCD(delete_new ,0,loop,t,"'delete new T'");
cout << "N=" << N <<" : " << loop << " times ";
LOKI_SMALLOBJBECH_ABCD(delete_new_array ,N,loop,t,"'delete[] new T[N]'");
cout << "i=0..." << Narr << " : ";
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 <<" : ";
LOKI_SMALLOBJBECH_ABCD(new_del_a_on_a ,N,Narr,t,"1. 'arr[i] = new T[N]' 2. 'delete[] arr[i]'");
cout << "i=0..." << Narr << " : ";
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 <<" : ";
LOKI_SMALLOBJBECH_ABCD(new_del_a_on_a ,N,Narr,t,"1. 'arr[i] = new T[N]' 2. 'delete[] arr[i]'");
delete [] a;
cout << "_________________________________________________________________" << endl;
Loki::AllocatorSingleton<>::ClearExtraMemory();
delete [] a;
cout << "_________________________________________________________________" << endl;
Loki::AllocatorSingleton<>::ClearExtraMemory();
}
int main()
{
const int loop = 1000*1000;
const int loop = 1000*1000;
cout << endl;
cout << endl;
testSize< 2,loop>();
testSize< 3,loop>();
testSize< 8,loop>();
testSize< 9,loop>();
testSize<16,loop>();
testSize<17,loop>();
testSize< 2,loop>();
testSize< 3,loop>();
testSize< 8,loop>();
testSize< 9,loop>();
testSize<16,loop>();
testSize<17,loop>();
#if defined(__BORLANDC__) || defined(__GNUC__) || defined(_MSC_VER)
// Stop console window from closing if run from IDE.
system("pause");
// Stop console window from closing if run from IDE.
system("pause");
#endif
return 0;
return 0;
}
// ----------------------------------------------------------------------------
// $Log$
// Revision 1.13 2005/10/30 14:03:23 syntheticpp
// replace tabs space
//
// Revision 1.12 2005/10/29 12:38:22 syntheticpp
// replace with new implementation
//

View file

@ -165,13 +165,16 @@ int main()
MortalSingleton::Instance().DoThat();
LongLivedSingleton::Instance().DoThat();
ImmortalSingleton::Instance().DoThat();
system("PAUSE");
return 0;
system("PAUSE");
return 0;
}
// ----------------------------------------------------------------------------
// $Log$
// Revision 1.3 2005/10/30 14:03:23 syntheticpp
// replace tabs space
//
// Revision 1.2 2005/10/29 10:21:46 syntheticpp
// find loki include files without a correct sreach pathand some small fixes
//

View file

@ -25,56 +25,59 @@ class Timer
{
public:
Timer()
{
t100 = 0;
};
Timer()
{
t100 = 0;
};
void start()
{
t0 = clock();
}
{
t0 = clock();
}
void stop()
{
t1 = clock();
}
int t()
{
return t1-t0;
}
{
t1 = clock();
}
int t()
{
return t1-t0;
}
double sec(int t)
{
return floor(100.0*double(t)/1000.0 )/100.0;
}
int rel(int t)
{
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
}
double speedup(int t)
{
double tup=t;
return (tup!=0 ? floor(100.0*(t100!=0?t100:tup)/tup+0.5)/100 : 1);
}
double sec(int t)
{
return floor(100.0*double(t)/1000.0 )/100.0;
}
int rel(int t)
{
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
}
double speedup(int t)
{
double tup=t;
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;
}
}
private:
int t0;
int t1;
int t1;
};
#endif
// $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
// Added CVS keywords and header lines.
//