rttr::destructor Class Reference

The destructor class provides a destructor for registered types. More...

#include <destructor.h>

Public Member Functions

type get_declaring_type () const noexcept
 Returns the class that declares this destructor. More...
 
type get_destructed_type () const noexcept
 Returns the rttr::type for which this destructor can delete objects. More...
 
bool invoke (variant &obj) const noexcept
 Destroys the contained object in the variant obj. More...
 
bool is_valid () const noexcept
 Returns true whether this destructor object is valid; otherwise false. More...
 
 operator bool () const noexcept
 Convenience function to check if this destructor is valid or not. More...
 
bool operator!= (const destructor &other) const noexcept
 Returns true if this destructor is the not the same like the other. More...
 
bool operator== (const destructor &other) const noexcept
 Returns true if this destructor is the same like the other. More...
 

Detailed Description

The destructor class provides a destructor for registered types.

A instance of a destructor class can only be obtained from the type class. See type::get_destructor().

Copying and Assignment

A destructor object is lightweight and can be copied by value. However, each copy will refer to the same underlying destructor.

Typical Usage

constructor string_ctor == type::get_by_name("std::string").get_constructor({type::get<const char*>()});
variant my_string = string_ctor.invoke("Hello World"); // returns an ptr to the object on the heap
type::get("std::string").get_destructor().invoke(my_string);
my_string.is_valid(); // yield to false
See also
method, property, enumeration, constructor and type

Member Function Documentation

type rttr::destructor::get_declaring_type ( ) const
noexcept

Returns the class that declares this destructor.

Remarks
When this destructor is not valid, this function will return an invalid type object (see type::is_valid).
Returns
Type of the declaring class/struct for this destructor.
type rttr::destructor::get_destructed_type ( ) const
noexcept

Returns the rttr::type for which this destructor can delete objects.

Returns
The type of this destructor.
bool rttr::destructor::invoke ( variant obj) const
noexcept

Destroys the contained object in the variant obj.

Remarks
When the obj could be destroyed the given obj is invalid after calling this method; Otherwise it is still valid.
Returns
True if the destructor of the object could be invoked, otherwise false.
bool rttr::destructor::is_valid ( ) const
noexcept

Returns true whether this destructor object is valid; otherwise false.

Returns
Returns true when the destructor is valid; otherwise false.
rttr::destructor::operator bool ( ) const
explicitnoexcept

Convenience function to check if this destructor is valid or not.

Returns
True if this destructor is valid, otherwise false.
bool rttr::destructor::operator!= ( const destructor other) const
noexcept

Returns true if this destructor is the not the same like the other.

Returns
True if both destructors are different, otherwise false.
bool rttr::destructor::operator== ( const destructor other) const
noexcept

Returns true if this destructor is the same like the other.

Returns
True if both destructors are equal, otherwise false.

The documentation for this class was generated from the following file: