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

const detail::discard_return rttr::policy::meth::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; }
{
(
);
}
int main()
{
method meth = type::get_global_method("my_func");
std::cout << meth.get_return_type().get_name(); // prints "void"
std::cout << var.is_type<void>(); // prints "true"
return 0;
}
The array_range class provides a view into an underlying data structure with lower and upper limits.
Definition array_range.h:64
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:122
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, Visitor_List > 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:199
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

const detail::return_as_ptr rttr::policy::meth::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; }
{
(
);
}
int main()
{
method meth = type::get_global_method("get_text");
std::cout << meth.get_return_type().get_name(); // prints "std::string*"
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: