SOFA API  cd4ffb93
Open source framework for multi-physics simuation
sofa::core::objectmodel::New< T > Class Template Reference

#include <SPtr.h>

new operator for classes with smart pointers (such as all components deriving from Base) More...

Inheritance diagram for sofa::core::objectmodel::New< T >:

Detailed Description

template<class T>
class sofa::core::objectmodel::New< T >

new operator for classes with smart pointers (such as all components deriving from Base)

This class should be used as : MyT::SPtr p = sofa::core::objectmodel::New<MyT>(myargs); instead of : MyT* p = new MyT(myargs);

The use of this New operator and SPtr pointers insures that all created objects are :

  • destroyed (no leak),
  • only once (no double desctructions),
  • and only after the last reference to them are erased (no invalid pointers).

Public Member Functions

template<class ... Args>
 New (Args &&... args)
 

Constructor details

◆ New()

template<class T >
template<class ... Args>
sofa::core::objectmodel::New< T >::New ( Args &&...  args)
inline