The ctor class groups all policies that can be used during registration of constructors. More...
#include <policy.h>
Static Public Attributes | |
static const detail::as_object | as_object |
The as_object policy will create an instance of a class with automatic storage. More... | |
static const detail::as_raw_pointer | as_raw_ptr |
The as_raw_ptr policy will create an instance of a class as raw pointer. More... | |
static const detail::as_std_shared_ptr | as_std_shared_ptr |
The as_std_shared_ptr policy will create an instance of a class through std::make_shared<T>. More... | |
Detailed Description
The ctor class groups all policies that can be used during registration of constructors.
Member Data Documentation
|
static |
The as_object policy will create an instance of a class with automatic storage.
Objects with automatic storage duration are automatically destroyed when the block in which they are created exits. Which is in our case the variant. However, that means also you don't have to deal with pointers or wrappers. In order to use this creation policy, the object must be copy constructible.
See following example code:
|
static |
The as_raw_ptr policy will create an instance of a class as raw pointer.
That means the object is created with a new-expression and its lifetime lasts until it is destroyed using a delete-expression. In order to invoke the delete expression use the corresponding destructor.
See following example code:
|
static |
The as_std_shared_ptr policy will create an instance of a class through std::make_shared<T>.
That means the object is wrapped into a std::shared_ptr<T>. The wrapped object is destroyed and its memory deallocated when either of the following happens:
- the last remaining variant owning the shared_ptr is destroyed
- the last remaining variant owning the shared_ptr is assigned another data or variant
The object is destroyed using the default deleter of std::shared_ptr.
See following example code:
The documentation for this struct was generated from the following file: