rttr::policy::meth Struct Reference
The meth class groups all policies that can be used during registration of methods. More...
#include <policy.h>
Static Public Attributes | |
static const detail::discard_return | discard_return |
This policy should be used when the return value of a method should not be forwarded to the caller. | |
static const detail::return_as_ptr | return_ref_as_ptr |
This policy can be used when a method return a reference to an object and the caller should be able to access this object via the returned variant. | |
Detailed Description
The meth class groups all policies that can be used during registration of methods.
Member Data Documentation
◆ discard_return
|
static |
This policy should be used when the return value of a method should not be forwarded to the caller.
For the caller it looks like the method has no return value, the return type will be void.
See following example code:
using namespace rttr;
int my_func() { return 42; }
{
registration::method("my_func", &my_func)
(
);
}
int main()
{
return 0;
}
The instance class is used for forwarding the instance of an object to invoke a property or method.
Definition: instance.h:48
The method class provides several meta information about a method and can be invoked.
Definition: method.h:121
type get_return_type() const noexcept
Returns the type object of the return type.
variant invoke(instance object) const
Invokes the method represented by the current instance object.
static bind< detail::meth, detail::invalid_type, F, detail::public_access > method(string_view name, F f)
Register a method to this class.
static method get_global_method(string_view name) noexcept
Returns a global method with the name name.
string_view get_name() const noexcept
Returns the unique and human-readable name of the type.
The variant class allows to store data of any type and convert between these types transparently.
Definition: variant.h:198
bool is_type() const
Returns true if the containing variant data is of the given template type T.
Definition: access_levels.h:34
#define RTTR_REGISTRATION
Use this macro to automatically register your reflection information to RTTR before main is called.
Definition: registration.h:745
static const detail::discard_return discard_return
This policy should be used when the return value of a method should not be forwarded to the caller.
Definition: policy.h:116
◆ return_ref_as_ptr
|
static |
This policy can be used when a method return a reference to an object and the caller should be able to access this object via the returned variant.
Reference cannot be copied directly in a variant, therefore it is possible transform the reference to a pointer.
See following example code:
std::string& get_text() { static std:string text("hello world"); return text; }
{
registration::method("get_text", &get_text)
(
);
}
int main()
{
std::cout << var.is_type<std::string*>(); // prints "true"
return 0;
}
static const detail::return_as_ptr return_ref_as_ptr
This policy can be used when a method return a reference to an object and the caller should be able t...
Definition: policy.h:86
The documentation for this struct was generated from the following file:
Generated on Thu Jun 27 2019 00:00:00 for rttr - 0.9.6 by doxygen.