Macro Definition Documentation
◆
NewObj
#define NewObj
|
(
|
|
T,
|
|
|
|
...
|
|
)
|
|
|
Creates an object with constructor parameters (using new or T::Alloc, depending on the type). This does not throw any kind of exception, it returns null if the allocation fails. NewObj does not clear the memory. Usage: MyType* x =
NewObj(MyType, optional constructor parameters)
;
-
注意
-
Creating a template object will not compile if the template contains a comma, e.g.
NewObj(MyType<1,2>)
. This is due to the nature of how the preprocessor works. To make it work either use
NewObjT<>()
or declare an alias using MyAllocType = MyType<1,2>; and then pass MyAllocType for the allocation itself.
-
NewObj does not support objects which might throw exceptions. THREADSAFE.
-
参数
-
[in]
|
T
|
Type of object.
|
[in]
|
...
|
Additional constructor parameters.
|
-
返回
-
Pointer to object (null if allocation failed)