refl-cpp |

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
refl::descriptor::field_descriptor< T, N > Class Template Reference

Represents a reflected field. More...

`#include <refl.hpp>`

## Public Types
typedef member::value_type | value_type
| Type value type of the member. More...

## Public Member Functions
template<typename... Args>
constexpr auto | operator() (Args &&... args) const noexcept -> decltype(invoker::invoke(std::forward< Args >(args)...))
| A synonym for get(). More...

## Static Public Member Functions
template<decltype(nullptr) = nullptr>
static constexpr decltype(auto) | get () noexcept
| Returns the value of the field. More...
template<typename U >
static constexpr decltype(auto) | get (U &&target) noexcept
| Returns the value of the field. More...

## Static Public Attributes
static constexpr bool | is_static { !std::is_member_object_pointer_v<decltype(member::pointer)> }
| Whether the field is static or not. More...
static constexpr bool | is_writable { !std::is_const_v<value_type> }
| Whether the field is const or not. More...
static constexpr auto | pointer { member::pointer }
| A member pointer to the reflected field of the appropriate type. More...

## Detailed Description

### template<typename T, size_t N>
class refl::descriptor::field_descriptor< T, N >

Represents a reflected field.

## Member Typedef Documentation

## ◆ value_type

template<typename T , size_t N>

typedef member::value_type refl::descriptor::field_descriptor< T, N >::value_type

Type value type of the member.

struct Foo { const int* x; };
REFL_AUTO(type(Foo), field(x))
get_t<0, member_list<Foo>>::value_type -> const int*

## Member Function Documentation

## ◆ get() [1/2]

template<typename T , size_t N>
template<decltype(nullptr) = nullptr>

static constexpr decltype(auto) refl::descriptor::field_descriptor< T, N >::get | ( |  | ) |
| inline static constexpr noexcept

Returns the value of the field.

(for static fields).

struct Foo {
int bar = 1;
static int baz = 5;
void foobar(int x) { return x * 2; }
static void foobaz(int x) { return x * 3; }
};
REFL_AUTO(type(Foo), field(bar), field(baz), func(foobar), func(foobaz))
invoke(get_t<0, member_list<Foo>(), Foo()) -> 1 (Foo().bar)
invoke(get_t<1, member_list<Foo>>()) -> 5 (Foo::baz)
invoke(get_t<2, member_list<Foo>(), Foo(), 10) -> 20 (Foo().foobar())
invoke(get_t<3, member_list<Foo>>()) -> 30 (Foo::foobaz())

## ◆ get() [2/2]

template<typename T , size_t N>
template<typename U >

static constexpr decltype(auto) refl::descriptor::field_descriptor< T, N >::get | ( | U && | target | ) |
| inline static constexpr noexcept

Returns the value of the field.

(for instance fields).

struct Foo {
int bar = 1;
static int baz = 5;
void foobar(int x) { return x * 2; }
static void foobaz(int x) { return x * 3; }
};
REFL_AUTO(type(Foo), field(bar), field(baz), func(foobar), func(foobaz))
invoke(get_t<0, member_list<Foo>(), Foo()) -> 1 (Foo().bar)
invoke(get_t<1, member_list<Foo>>()) -> 5 (Foo::baz)
invoke(get_t<2, member_list<Foo>(), Foo(), 10) -> 20 (Foo().foobar())
invoke(get_t<3, member_list<Foo>>()) -> 30 (Foo::foobaz())

## ◆ operator()()

template<typename T , size_t N>
template<typename... Args>

constexpr auto refl::descriptor::field_descriptor< T, N >::operator() | ( | Args &&... | args | ) | const -> decltype(invoker::invoke(std::forward<Args>(args)...))
| inline constexpr noexcept

A synonym for get().

struct Foo {
int bar = 1;
static int baz = 5;
void foobar(int x) { return x * 2; }
static void foobaz(int x) { return x * 3; }
};
REFL_AUTO(type(Foo), field(bar), field(baz), func(foobar), func(foobaz))
invoke(get_t<0, member_list<Foo>(), Foo()) -> 1 (Foo().bar)
invoke(get_t<1, member_list<Foo>>()) -> 5 (Foo::baz)
invoke(get_t<2, member_list<Foo>(), Foo(), 10) -> 20 (Foo().foobar())
invoke(get_t<3, member_list<Foo>>()) -> 30 (Foo::foobaz())

## Member Data Documentation

## ◆ is_static

template<typename T , size_t N>

constexpr bool refl::descriptor::field_descriptor< T, N >::is_static { !std::is_member_object_pointer_v<decltype(member::pointer)> }
| static constexpr

Whether the field is static or not.

struct Foo {
int bar;
static int baz;
};
REFL_AUTO(type(Foo), field(bar), field(baz))
is_static(get_t<0, member_list<Foo>>()) -> false
is_static(get_t<1, member_list<Foo>>()) -> true

## ◆ is_writable

template<typename T , size_t N>

constexpr bool refl::descriptor::field_descriptor< T, N >::is_writable { !std::is_const_v<value_type> }
| static constexpr

Whether the field is const or not.

See also
  refl::descriptor::is_const

## ◆ pointer

template<typename T , size_t N>

constexpr auto refl::descriptor::field_descriptor< T, N >::pointer { member::pointer }
| static constexpr

A member pointer to the reflected field of the appropriate type.

When the member is a function, the return value might be nullptr if the type of the function pointer cannot be resolved.

See also
  is_resolved
  can_resolve
  resolve

struct Foo {
int bar;
static int baz;
};
REFL_AUTO(type(Foo), field(bar), field(baz))
get_pointer(get_t<0, member_list<Foo>>()) -> (int Foo::*) &Foo::bar
get_pointer(get_t<1, member_list<Foo>>()) -> (int*) &Foo::baz

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

- include/refl.hpp

refl::descriptor::invoke
constexpr auto invoke(MemberDescriptor d, Args &&... args) noexcept -> decltype(d(std::forward< Args >(args)...))
Invokes the member with the specified arguments.
Definition: refl.hpp:2844
refl::descriptor::get_pointer
constexpr auto get_pointer(MemberDescriptor d) noexcept
Returns a pointer to the reflected field/function.
Definition: refl.hpp:2820
refl::trait::get_t
typename get< N, TypeList >::type get_t
The N-th type in the provided type_list.
Definition: refl.hpp:800
refl::descriptor::field_descriptor::value_type
member::value_type value_type
Type value type of the member.
Definition: refl.hpp:2398
refl::descriptor::field_descriptor::is_static
static constexpr bool is_static
Whether the field is static or not.
Definition: refl.hpp:2418