1 #ifndef _CONSTRUCTOR_H_
2 #define _CONSTRUCTOR_H_
4 #include <util/kernel_cpp.h>
6 template <class DataType
>
9 typedef DataType
* Pointer
;
10 typedef const DataType
* ConstPointer
;
11 typedef DataType
& Reference
;
12 typedef const DataType
& ConstReference
;
14 /*! Constructs the object pointed to by \a object via a
15 zero-parameter constructor.
18 void Construct(Pointer object
) {
20 new(reinterpret_cast<void*>(object
)) DataType();
23 /*! Constructs the object pointed to by \a object via a
24 one-parameter constructor using the given argument.
26 template <typename ArgType1
>
28 void Construct(Pointer object
, ArgType1 arg1
) {
30 new(reinterpret_cast<void*>(object
)) DataType(arg1
);
33 /*! Constructs the object pointed to by \a object via a
34 two-parameter constructor using the given arguments.
36 template <typename ArgType1
, typename ArgType2
>
38 void Construct(Pointer object
, ArgType1 arg1
, ArgType2 arg2
) {
40 new(reinterpret_cast<void*>(object
)) DataType(arg1
, arg2
);
43 /*! Constructs the object pointed to by \a object via a
44 three-parameter constructor using the given arguments.
46 template <typename ArgType1
, typename ArgType2
, typename ArgType3
>
48 void Construct(Pointer object
, ArgType1 arg1
, ArgType2 arg2
, ArgType3 arg3
) {
50 new(reinterpret_cast<void*>(object
)) DataType(arg1
, arg2
, arg3
);
53 /*! Constructs the object pointed to by \a object via a
54 four-parameter constructor using the given arguments.
56 template <typename ArgType1
, typename ArgType2
, typename ArgType3
,
59 void Construct(Pointer object
, ArgType1 arg1
, ArgType2 arg2
, ArgType3 arg3
,
62 new(reinterpret_cast<void*>(object
)) DataType(arg1
, arg2
, arg3
, arg4
);
65 /*! Calls the destructor for the object pointed to be \a object.
68 void Destruct(Pointer object
) {
76 #endif // _CONSTRUCTOR_H_