rttr::destructor Class - 0.9.0 |RTTR
rttr::destructor Class Reference

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

#include <destructor.h>

Public Member Functions

type get_destructed_type () const
 Returns the rttr::type for which this destructor can delete objects. More...
 
void invoke (variant &obj) const
 Destroys the given object obj. More...
 
bool is_valid () const
 Returns true whether this destructor object is valid; otherwise false. More...
 
 operator bool () const
 Convenience function to check if this destructor is valid or not. More...
 
bool operator!= (const destructor &other) const
 Returns true if this destructor is the not the same like the other. More...
 
bool operator== (const destructor &other) const
 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("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_destructed_type ( ) const

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

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

Destroys the given object obj.

Remarks
When the obj could be destroyed the given obj is invalid after calling this method; Otherwise it is still valid.
bool rttr::destructor::is_valid ( ) const

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

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

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

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: