newobj.h File Reference

Classes

class   ForwardFree< IS_DELETABLE >
class   ForwardFree< true >
class   NewDelete< T >

Namespaces

  maxon
  maxon::details

Macros

#define  NewObj (T, ...)
#define  NewObjPtr (T, ...)
#define  DeleteObj (obj)

函数

template<typename T >
void  PrivateFreeWithDestructor (const T *obj)
Bool   PrivateClearAllWeakReferences (const void *obj)
template<typename T , typename... ARGS>
ResultPtr< T >  NewObjWithLocation ( MAXON_SOURCE_LOCATION_DECLARATION , ARGS &&... args)
template<typename T , typename... ARGS>
ResultPtr< T >  NewObjT (ARGS &&... args)
template<typename T >
MAXON_ATTRIBUTE_FORCE_INLINE void  DeleteConstPtrObj (T *o)

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)

◆  NewObjPtr

#define NewObjPtr (   T,
  ...  
)

Deprecated.

◆  DeleteObj

#define DeleteObj (   obj )

Deletes an object. This expects a pointer as argument, the object is deleted using the destructor or T::Free, depending on the type of the object. If the destructor is private System::FreeWithDestructor() cannot be called; the destructor is called inline (after clearing weak references) and then the memory is released.

注意
DeleteObj does not support objects which might throw exceptions. THREADSAFE.
参数
[in,out] obj Object pointer (can be nullptr, will be nullptr after return)