refl-cpp
refl.hpp File Reference
#include <stddef.h>
#include <cstring>
#include <array>
#include <utility>
#include <optional>
#include <tuple>
#include <type_traits>
#include <ostream>
#include <sstream>
#include <iomanip>
#include <memory>
#include <complex>

Go to the source code of this file.

Classes

struct  refl::util::const_string< N >
 Represents a compile-time string. More...
 
struct  refl::util::type_list< Ts >
 Represents a compile-time list of types provided as variadic template parameters. More...
 
struct  refl::util::type_list< T >
 
struct  refl::member::field
 An empty type which is equivalent to refl::member_descriptor_base::member_type when the reflected member is a field. More...
 
struct  refl::member::function
 An empty type which is equivalent to refl::member_descriptor_base::member_type when the reflected member is a function. More...
 
class  refl::descriptor::type_descriptor< T >
 Represents a reflected type. More...
 
class  refl::descriptor::field_descriptor< T, N >
 Represents a reflected field. More...
 
class  refl::descriptor::function_descriptor< T, N >
 Represents a reflected function. More...
 
struct  refl::trait::remove_qualifiers< T >
 Removes all reference and cv-qualifiers from T. More...
 
struct  refl::trait::is_reflectable< T >
 Checks whether there is reflection metadata for the type T. More...
 
struct  refl::trait::is_container< T >
 Checks whether objects of the type T support member .begin() and .end() operations. More...
 
struct  refl::trait::get< N, type_list< Ts... > >
 Provides a member typedef type which is the N-th type in the provided type_list. More...
 
struct  refl::trait::skip< N, type_list< Ts... > >
 Skips the first N types in the provided type_list. More...
 
struct  refl::trait::as_type_list< T< Ts... > >
 Provides a member typedef type which is a type_list with template type parameters equivalent to the type parameters of the provided type. More...
 
struct  refl::trait::as_tuple< T< Ts... > >
 Provides a member typedef which is a std::tuple specialization with template type parameters equivalent to the type parameters of the provided type. More...
 
struct  refl::trait::reverse< TypeList >
 Reverses a list of types. More...
 
struct  refl::trait::concat<... >
 Concatenates N lists together. More...
 
struct  refl::trait::append< T, TypeList >
 Appends a type to the list. More...
 
struct  refl::trait::prepend< T, TypeList >
 Prepends a type to the list. More...
 
struct  refl::trait::prepend< T, TypeList >
 Prepends a type to the list. More...
 
struct  refl::trait::filter< Predicate, type_list< Ts... > >
 Filters a type_list according to a predicate template. More...
 
struct  refl::trait::map< Mapper, type_list< Ts... > >
 Transforms a type_list according to a predicate template. More...
 
struct  refl::trait::is_instance< T >
 Detects whether T is a template specialization. More...
 
struct  refl::trait::is_instance_of< T, U >
 Detects whther the type U is a template specialization of T. More...
 
struct  refl::trait::contains< T, type_list< Ts... > >
 Checks whether T is contained in the list of types. More...
 
struct  refl::trait::contains_instance< T, type_list< Ts... > >
 Checks whether an instance of the template T is contained in the list of types. More...
 
struct  refl::trait::contains_base< T, type_list< Ts... > >
 Checks whether a type deriving from T is contained in the list of types. More...
 
struct  refl::trait::index_of< T, type_list< Ts... > >
 The index of the type in the type list, -1 if it doesn't exist. More...
 
struct  refl::trait::index_of_base< T, type_list< Ts... > >
 The index of the type in the type list that is derived from T, -1 if it doesn't exist. More...
 
struct  refl::trait::index_of_instance< T, type_list< Ts... > >
 The index of the type in the type list that is a template instance of T, -1 if it doesn't exist. More...
 
struct  refl::trait::unique< T >
 Creates a new list containing the repeating elements in the source list only once. More...
 
struct  refl::attr::usage::type
 Specifies that an attribute type inheriting from this type can only be used with REFL_TYPE() More...
 
struct  refl::attr::usage::function
 Specifies that an attribute type inheriting from this type can only be used with REFL_FUNC() More...
 
struct  refl::attr::usage::field
 Specifies that an attribute type inheriting from this type can only be used with REFL_FIELD() More...
 
struct  refl::attr::usage::member
 Specifies that an attribute type inheriting from this type can only be used with REFL_FUNC or REFL_FIELD. More...
 
struct  refl::attr::usage::any
 Specifies that an attribute type inheriting from this type can only be used with any one of REFL_TYPE, REFL_FIELD, REFL_FUNC. More...
 
struct  refl::attr::property
 Used to decorate a function that serves as a property. More...
 
struct  refl::attr::debug< F >
 Used to specify how a type should be displayed in debugging contexts. More...
 
struct  refl::attr::base_types< Ts >
 Used to specify the base types of the target type. More...
 
struct  refl::trait::is_member< T >
 A trait for detecting whether the type 'T' is a member descriptor. More...
 
struct  refl::trait::is_field< T >
 A trait for detecting whether the type 'T' is a field descriptor. More...
 
struct  refl::trait::is_function< T >
 A trait for detecting whether the type 'T' is a function descriptor. More...
 
struct  refl::trait::is_type< T >
 Detects whether the type T is a type_descriptor. More...
 
struct  refl::trait::is_descriptor< T >
 A trait for detecting whether the type 'T' is a refl-cpp descriptor. More...
 
struct  refl::trait::is_property< T >
 Checks whether T is marked as a property. More...
 
class  refl::descriptor::member_descriptor_base< T, N >
 The base type for member descriptors. More...
 
class  refl::descriptor::field_descriptor< T, N >
 Represents a reflected field. More...
 
class  refl::descriptor::function_descriptor< T, N >
 Represents a reflected function. More...
 
class  refl::descriptor::type_descriptor< T >
 Represents a reflected type. More...
 
struct  refl::runtime::proxy< Derived, Target >
 A proxy object that has a static interface identical to the reflected functions and fields of the target. More...
 
struct  refl::trait::is_proxy< T >
 
struct  refl::trait::is_proxy< T >
 

Namespaces

 refl
 The top-level refl-cpp namespace It contains a few core refl-cpp namespaces and directly exposes core classes and functions.
 
 refl::util
 Contains utility types and functions for working with those types.
 
 refl::member
 Contains tag types denoting the different types of reflectable members.
 
 refl::descriptor
 Contains the basic reflection primitives as well as functions operating on those primitives.
 
 refl::trait
 Provides type-level operations for refl-cpp related use-cases.
 
 refl::attr
 Contains the definitions of the built-in attributes.
 
 refl::attr::usage
 Contains a number of constraints applicable to refl-cpp attributes.
 
 refl::runtime
 Contains utilities that can have runtime-overhead (like proxy, debug, invoke)
 

Macros

#define REFL_MAKE_CONST_STRING(CString)   (::refl::util::detail::copy_from_unsized<::refl::util::detail::strlen(CString)>(CString))
 Converts a compile-time available const char* value to a const_string<N>. More...
 
#define REFL_DETAIL_FORCE_EBO
 
#define REFL_DETAIL_STR_IMPL(...)   #__VA_ARGS__
 
#define REFL_DETAIL_STR(...)   REFL_DETAIL_STR_IMPL(__VA_ARGS__)
 Used to stringify input separated by commas (e.g. More...
 
#define REFL_DETAIL_GROUP(...)   __VA_ARGS__
 Used to group input containing commas (e.g. More...
 
#define REFL_DETAIL_ATTRIBUTES(DeclType, ...)   static constexpr auto attributes{ ::refl::detail::make_attributes<::refl::attr::usage:: DeclType>(__VA_ARGS__) }; \
 Expands to the appropriate attributes static member variable. More...
 
#define REFL_DETAIL_TYPE_BODY(TypeName, ...)
 Expands to the body of a type_info__ specialization. More...
 
#define REFL_TYPE(TypeName, ...)
 Creates reflection information for a specified type. More...
 
#define REFL_TEMPLATE(TemplateDeclaration, TypeName, ...)
 Creates reflection information for a specified type template. More...
 

Typedefs

template<typename T >
using refl::util::type_tag = type_list< T >
 
template<typename T >
using refl::trait::remove_qualifiers_t = typename remove_qualifiers< T >::type
 Removes all reference and cv-qualifiers from T. More...
 
template<size_t N, typename TypeList >
using refl::trait::get_t = typename get< N, TypeList >::type
 The N-th type in the provided type_list. More...
 
template<size_t N, typename TypeList >
using refl::trait::skip_t = typename skip< N, TypeList >::type
 Skips the first N types in the provided type_list. More...
 
template<typename T >
using refl::trait::as_type_list_t = typename as_type_list< T >::type
 A typedef for a type_list with template type parameters equivalent to the type parameters of the provided type. More...
 
template<typename T >
using refl::trait::as_tuple_t = typename as_tuple< T >::type
 A typedef for a std::tuple specialization with template type parameters equivalent to the type parameters of the provided type. More...
 
template<typename TypeList >
using refl::trait::first = get< 0, TypeList >
 Accesses first type in the list. More...
 
template<typename TypeList >
using refl::trait::first_t = typename first< TypeList >::type
 Accesses last type in the list. More...
 
template<typename TypeList >
using refl::trait::last = get< TypeList::size - 1, TypeList >
 Accesses last type in the list. More...
 
template<typename TypeList >
using refl::trait::last_t = typename last< TypeList >::type
 Accesses last type in the list. More...
 
template<typename TypeList >
using refl::trait::tail = skip< 1, TypeList >
 Returns all but the first element of the list. More...
 
template<typename TypeList >
using refl::trait::tail_t = typename tail< TypeList >::type
 Returns all but the first element of the list. More...
 
template<size_t N, typename TypeList >
using refl::trait::take = detail::take< type_list<>, N, TypeList >
 Returns the first N elements of the list. More...
 
template<size_t N, typename TypeList >
using refl::trait::take_t = typename take< N, TypeList >::type
 Returns the first N elements of the list. More...
 
template<typename TypeList >
using refl::trait::init = take< TypeList::size - 1, TypeList >
 Returns all but the last element of the list. More...
 
template<typename TypeList >
using refl::trait::init_t = typename init< TypeList >::type
 Returns all but the last element of the list. More...
 
template<typename TypeList >
using refl::trait::reverse_t = typename reverse< TypeList >::type
 Reverses a list of types. More...
 
template<typename... Ts>
using refl::trait::concat_t = typename concat< Ts... >::type
 Concatenates two lists together. More...
 
template<typename T , typename TypeList >
using refl::trait::append_t = typename append< T, TypeList >::type
 Appends a type to the list. More...
 
template<typename T , typename TypeList >
using refl::trait::prepend_t = typename prepend< T, TypeList >::type
 Prepends a type to the list. More...
 
template<template< typename > typename Predicate, typename TypeList >
using refl::trait::filter_t = typename filter< Predicate, TypeList >::type
 Filters a type_list according to a predicate template with a static boolean member named "value" (e.g. More...
 
template<template< typename > typename Mapper, typename... Ts>
using refl::trait::map_t = typename map< Mapper, Ts... >::type
 Transforms a type_list according to a predicate template with a typedef named "type" (e.g. More...
 
template<typename T >
using refl::trait::unique_t = typename unique< T >::type
 Creates a new list containing the repeating elements in the source list only once. More...
 
template<typename T >
using refl::descriptor::declared_member_list = typename detail::declared_member_list< T >::type
 A type_list of the declared member descriptors of the target type T. More...
 
template<typename T >
using refl::descriptor::member_list = typename detail::member_list< T >::type
 A type_list of the declared and inherited member descriptors of the target type T. More...
 
template<typename FunctionDescriptor , typename... Args>
using refl::descriptor::result_type = typename FunctionDescriptor::template result_type< Args... >
 The return type when invoking the specified descriptor using the provided argument types. More...
 

Functions

constexpr const_string< 0 > refl::util::make_const_string () noexcept
 Creates an empty instance of const_string<N> More...
 
template<size_t N>
constexpr const_string< N - 1 > refl::util::make_const_string (const char(&str)[N]) noexcept
 Creates an instance of const_string<N> More...
 
constexpr const_string< 1 > refl::util::make_const_string (char ch) noexcept
 Creates an instance of const_string<N> More...
 
template<size_t N, size_t M>
constexpr const_string< N+M > refl::util::operator+ (const const_string< N > &a, const const_string< M > &b) noexcept
 Concatenates two const_strings together. More...
 
template<size_t N, size_t M>
constexpr const_string< N+M - 1 > refl::util::operator+ (const const_string< N > &a, const char(&b)[M]) noexcept
 Concatenates a const_string with a C-style string. More...
 
template<size_t N, size_t M>
constexpr const_string< N+M - 1 > refl::util::operator+ (const char(&a)[N], const const_string< M > &b) noexcept
 Concatenates a C-style string with a const_string. More...
 
template<size_t N, size_t M>
constexpr bool refl::util::operator== (const const_string< N > &a, const const_string< M > &b) noexcept
 Compares two const_strings for equality. More...
 
template<size_t N, size_t M>
constexpr bool refl::util::operator!= (const const_string< N > &a, const const_string< M > &b) noexcept
 Compares two const_strings for equality. More...
 
template<size_t N, size_t M>
constexpr bool refl::util::operator== (const const_string< N > &a, const char(&b)[M]) noexcept
 Compares a const_string with a C-style string for equality. More...
 
template<size_t N, size_t M>
constexpr bool refl::util::operator!= (const const_string< N > &a, const char(&b)[M]) noexcept
 Compares a const_string with a C-style string for equality. More...
 
template<size_t N, size_t M>
constexpr bool refl::util::operator== (const char(&a)[N], const const_string< M > &b) noexcept
 Compares a C-style string with a const_string for equality. More...
 
template<size_t N, size_t M>
constexpr bool refl::util::operator!= (const char(&a)[N], const const_string< M > &b) noexcept
 Compares a C-style string with a const_string for equality. More...
 
template<size_t N>
constexpr std::ostream & refl::util::operator<< (std::ostream &os, const const_string< N > &str) noexcept
 
template<typename T = int, typename... Ts>
constexpr int refl::util::ignore (Ts &&...) noexcept
 Ignores all parameters. More...
 
template<typename T >
constexpr decltype(auto) refl::util::identity (T &&t) noexcept
 Returns the input paratemeter as-is. More...
 
template<typename T >
constexpr const T & refl::util::make_const (const T &value) noexcept
 Adds const to the input reference. More...
 
template<typename T >
constexpr const T & refl::util::make_const (T &value) noexcept
 Adds const to the input reference. More...
 
template<typename T , typename... Ts>
constexpr std::array< T, sizeof...(Ts)> refl::util::to_array (const std::tuple< Ts... > &tuple) noexcept
 Creates an array of type 'T' from the provided tuple. More...
 
template<typename T , size_t N>
constexpr auto refl::util::to_tuple (const std::array< T, N > &array) noexcept
 Creates a tuple from the provided array. More...
 
template<typename... Ts>
constexpr std::tuple< Ts... > refl::util::as_tuple (type_list< Ts... >) noexcept
 Creates a matching std::tuple from a type_list. More...
 
template<typename... Ts>
constexpr type_list< Ts... > refl::util::as_type_list (const std::tuple< Ts... > &) noexcept
 Creates a matching type_list from a std::tuple. More...
 
template<typename F , typename... Ts>
constexpr auto refl::util::map_to_tuple (type_list< Ts... > list, F &&f)
 Applies function F to each type in the type_list, aggregating the results in a tuple. More...
 
template<typename T , typename F , typename... Ts>
constexpr auto refl::util::map_to_array (type_list< Ts... > list, F &&f)
 Applies function F to each type in the type_list, aggregating the results in an array. More...
 
template<typename F , typename... Ts>
constexpr void refl::util::for_each (type_list< Ts... > list, F &&f)
 Applies function F to each type in the type_list. More...
 
template<typename R , typename F , typename T , typename... Ts>
constexpr auto refl::util::accumulate (type_list< T, Ts... >, F &&f, R &&initial_value)
 
template<typename F , typename... Ts>
constexpr size_t refl::util::count_if (type_list< Ts... > list, F &&f)
 Counts the number of times the predicate F returns true. More...
 
template<typename F , typename... Ts>
constexpr auto refl::util::filter (type_list< Ts... > list, F &&f)
 Filters the list according to a constexpr predicate. More...
 
template<typename F , typename... Ts>
constexpr auto refl::util::find_first (type_list< Ts... > list, F &&f)
 Returns the first instance that matches the constexpr predicate. More...
 
template<typename F , typename... Ts>
constexpr auto refl::util::find_one (type_list< Ts... > list, F &&f)
 Returns the only instance that matches the constexpr predicate. More...
 
template<typename F , typename... Ts>
constexpr bool refl::util::contains (type_list< Ts... > list, F &&f)
 Returns true if any item in the list matches the predicate. More...
 
template<typename T , typename... Ts>
constexpr bool refl::util::contains (type_list< Ts... >)
 Returns true if the type_list contains the specified type. More...
 
template<typename T , typename... Ts>
constexpr bool refl::util::contains_base (const std::tuple< Ts... > &)
 Returns true if the tuple contains the specified type or a supertype. More...
 
template<template< typename... > typename T, typename... Ts>
constexpr bool refl::util::contains_instance (const std::tuple< Ts... > &)
 Returns true if the tuple contains an instance of the specified type. More...
 
template<typename... Ts, typename F >
constexpr auto refl::util::apply (type_list< Ts... >, F &&f)
 Applies a function to the elements of the type_list. More...
 
template<size_t N, typename... Ts>
constexpr auto & refl::util::get (std::tuple< Ts... > &ts) noexcept
 A synonym for std::get<N>(tuple). More...
 
template<size_t N, typename... Ts>
constexpr const auto & refl::util::get (const std::tuple< Ts... > &ts) noexcept
 A synonym for std::get<N>(tuple). More...
 
template<typename T , typename... Ts>
constexpr T & refl::util::get (std::tuple< Ts... > &ts) noexcept
 A synonym for std::get<T>(tuple). More...
 
template<typename T , typename... Ts>
constexpr const T & refl::util::get (const std::tuple< Ts... > &ts) noexcept
 A synonym for std::get<T>(tuple). More...
 
template<template< typename... > typename T, typename... Ts>
constexpr auto & refl::util::get_instance (std::tuple< Ts... > &ts) noexcept
 Returns the value of type U, where U is a template instance of T. More...
 
template<template< typename... > typename T, typename... Ts>
constexpr const auto & refl::util::get_instance (const std::tuple< Ts... > &ts) noexcept
 Returns the value of type U, where U is a template instance of T. More...
 
template<typename... Ts>
constexpr type_list< descriptor::type_descriptor< Ts >... > refl::util::reflect_types (type_list< Ts... >) noexcept
 Converts a type_list of types to a type_list of the type_descriptors for these types. More...
 
template<typename... Ts>
constexpr type_list< Ts... > refl::util::unreflect_types (type_list< descriptor::type_descriptor< Ts >... >) noexcept
 Converts a type_list of type_descriptors to a type_list of the target types. More...
 
template<typename Descriptor >
constexpr auto refl::descriptor::get_name (Descriptor d) noexcept
 Returns the full name of the descriptor. More...
 
template<typename Descriptor >
constexpr const auto & refl::descriptor::get_attributes (Descriptor d) noexcept
 Returns a const reference to the descriptor's attribute tuple. More...
 
template<typename Descriptor >
constexpr auto refl::descriptor::get_attribute_types (Descriptor d) noexcept
 Returns a type_list of the descriptor's attribute types. More...
 
template<typename TypeDescriptor >
constexpr auto refl::descriptor::get_declared_base_types (TypeDescriptor t) noexcept
 Returns a type_list of the declared base types of the type. More...
 
template<typename TypeDescriptor >
constexpr auto refl::descriptor::get_base_types (TypeDescriptor t) noexcept
 Returns a type_list of the declared and inherited base types of the type. More...
 
template<typename TypeDescriptor >
constexpr auto refl::descriptor::get_declared_members (TypeDescriptor t) noexcept
 Returns a type_list of the declared members of the type. More...
 
template<typename TypeDescriptor >
constexpr auto refl::descriptor::get_members (TypeDescriptor t) noexcept
 Returns a type_list of the declared and inherited members of the type. More...
 
template<typename MemberDescriptor >
constexpr auto refl::descriptor::get_declarator (MemberDescriptor d) noexcept
 Returns the type_descriptor of declaring type of the member. More...
 
template<typename MemberDescriptor >
constexpr auto refl::descriptor::get_pointer (MemberDescriptor d) noexcept
 Returns a pointer to the reflected field/function. More...
 
template<typename MemberDescriptor , typename... Args>
constexpr auto refl::descriptor::invoke (MemberDescriptor d, Args &&... args) noexcept -> decltype(d(std::forward< Args >(args)...))
 Invokes the member with the specified arguments. More...
 
template<typename FieldDescriptor >
constexpr auto refl::descriptor::is_static (FieldDescriptor d) noexcept
 Checks whether the field is declared as static. More...
 
template<typename FieldDescriptor >
constexpr auto refl::descriptor::is_const (FieldDescriptor d) noexcept
 Checks whether the value type of the field is const-qualified. More...
 
template<typename FunctionDescriptor >
constexpr auto refl::descriptor::is_resolved (FunctionDescriptor d) noexcept
 Checks whether the function pointer was automatically resolved. More...
 
template<typename Pointer , typename FunctionDescriptor >
constexpr auto refl::descriptor::can_resolve (FunctionDescriptor d) noexcept
 Checks whether the function pointer can be resolved as a pointer of the specified type. More...
 
template<typename Pointer , typename FunctionDescriptor >
constexpr auto refl::descriptor::resolve (FunctionDescriptor d) noexcept
 Resolves the function pointer as a pointer of the specified type. More...
 
template<typename Descriptor >
constexpr bool refl::descriptor::is_field (Descriptor) noexcept
 Checks whether T is a field descriptor. More...
 
template<typename Descriptor >
constexpr bool refl::descriptor::is_function (Descriptor) noexcept
 Checks whether T is a function descriptor. More...
 
template<typename Descriptor >
constexpr bool refl::descriptor::is_type (Descriptor) noexcept
 Checks whether T is a type descriptor. More...
 
template<typename A , typename Descriptor >
constexpr bool refl::descriptor::has_attribute (Descriptor) noexcept
 Checks whether T has an attribute of type A. More...
 
template<typename A , typename Descriptor >
constexpr const A & refl::descriptor::get_attribute (Descriptor d) noexcept
 Returns the value of the attribute A on T. More...
 
template<template< typename... > typename A, typename Descriptor >
constexpr const auto & refl::descriptor::get_attribute (Descriptor d) noexcept
 Returns the value of the attribute A on T. More...
 
template<typename MemberDescriptor >
constexpr bool refl::descriptor::is_property (MemberDescriptor d) noexcept
 Checks whether T is a member descriptor marked with the property attribute. More...
 
template<typename FunctionDescriptor >
constexpr attr::property refl::descriptor::get_property (FunctionDescriptor d) noexcept
 Gets the property attribute. More...
 
template<typename MemberDescriptor >
constexpr bool refl::descriptor::is_readable (MemberDescriptor) noexcept
 Checks if T is a 0-arg const-qualified member function with a property attribute or a field. More...
 
template<typename MemberDescriptor >
constexpr bool refl::descriptor::is_writable (MemberDescriptor) noexcept
 Checks if T is a 1-arg non-const-qualified member function with a property attribute or a non-const field. More...
 
template<typename TypeDescriptor >
constexpr auto refl::descriptor::has_bases (TypeDescriptor t) noexcept
 Checks if a type has a bases attribute. More...
 
template<typename TypeDescriptor >
constexpr auto refl::descriptor::get_bases (TypeDescriptor t) noexcept
 Returns a list of the type_descriptor<T>s of the base types of the target, as specified by the bases<A, B, ...> attribute. More...
 
template<typename TypeDescriptor >
constexpr auto refl::descriptor::get_simple_name (TypeDescriptor t)
 Returns the unqualified name of the type, discarding the namespace and typenames (if a template type). More...
 
template<typename MemberDescriptor >
constexpr auto refl::descriptor::get_debug_name_const (MemberDescriptor d)
 Returns the debug name of T (In the form of 'declaring_type::member_name') as a const_string. More...
 
template<typename MemberDescriptor >
const char * refl::descriptor::get_debug_name (MemberDescriptor d)
 Returns the debug name of T. More...
 
template<typename Descriptor >
const char * refl::descriptor::get_display_name (Descriptor d) noexcept
 Returns the display name of T. More...
 
template<typename Descriptor >
constexpr auto refl::descriptor::get_display_name_const (Descriptor d) noexcept
 Returns the display name of T as a const_string<N>. More...
 
template<typename ReadableMember >
constexpr bool refl::descriptor::has_writer (ReadableMember member)
 Checks if there exists a member that has the same display name as the one provied and is writable. More...
 
template<typename WritableMember >
constexpr bool refl::descriptor::has_reader (WritableMember member)
 Checks if there exists a member that has the same display name as the one provied and is readable. More...
 
template<typename ReadableMember >
constexpr auto refl::descriptor::get_writer (ReadableMember member)
 Returns a member that has the same display name as the one provied and is writable. More...
 
template<typename WritableMember >
constexpr auto refl::descriptor::get_reader (WritableMember member)
 Returns a member that has the same display name as the one provied and is readable. More...
 
template<typename T >
constexpr bool refl::is_reflectable () noexcept
 Returns true if the type T is reflectable. More...
 
template<typename T >
constexpr bool refl::is_reflectable (const T &) noexcept
 Returns true if the non-qualified type T is reflectable. More...
 
template<typename T >
constexpr type_descriptor< T > refl::reflect () noexcept
 Returns the type descriptor for the type T. More...
 
template<typename T >
constexpr type_descriptor< T > refl::reflect (const T &) noexcept
 Returns the type descriptor for the non-qualified type T. More...
 
template<typename CharT , typename T >
void refl::runtime::debug (std::basic_ostream< CharT > &os, const T &value, bool compact=false)
 
template<typename CharT , typename T >
void refl::runtime::debug (std::basic_ostream< CharT > &os, const T &value, [[maybe_unused]] bool compact)
 Writes the debug representation of value to the given std::ostream. More...
 
template<typename CharT , typename... Ts>
void refl::runtime::debug_all (std::basic_ostream< CharT > &os, const Ts &... values)
 Writes the compact debug representation of the provided values to the given std::ostream. More...
 
template<typename CharT = char, typename T >
std::basic_string< CharT > refl::runtime::debug_str (const T &value, bool compact=false)
 Writes the debug representation of the provided value to an std::string and returns it. More...
 
template<typename CharT = char, typename... Ts>
std::basic_string< CharT > refl::runtime::debug_all_str (const Ts &... values)
 Writes the compact debug representation of the provided values to an std::string and returns it. More...
 
template<typename U , typename T , typename... Args>
refl::runtime::invoke (T &&target, const char *name, Args &&... args)
 Invokes the specified member with the provided arguments. More...
 

Variables

template<typename T >
constexpr bool refl::trait::is_type_v { is_type<T>::value }
 Detects whether the type T is a type_descriptor. More...
 
template<typename Derived , typename Target >
struct REFL_DETAIL_FORCE_EBO refl::runtime::proxy
 

Macro Definition Documentation

◆ REFL_DETAIL_ATTRIBUTES

#define REFL_DETAIL_ATTRIBUTES (   DeclType,
  ... 
)    static constexpr auto attributes{ ::refl::detail::make_attributes<::refl::attr::usage:: DeclType>(__VA_ARGS__) }; \

Expands to the appropriate attributes static member variable.

DeclType must be the name of one of the constraints defined in attr::usage. VA_ARGS is the list of attributes.

◆ REFL_DETAIL_FORCE_EBO

#define REFL_DETAIL_FORCE_EBO

◆ REFL_DETAIL_GROUP

#define REFL_DETAIL_GROUP (   ...)    __VA_ARGS__

Used to group input containing commas (e.g.

template specializations with multiple types).

◆ REFL_DETAIL_STR

#define REFL_DETAIL_STR (   ...)    REFL_DETAIL_STR_IMPL(__VA_ARGS__)

Used to stringify input separated by commas (e.g.

template specializations with multiple types).

◆ REFL_DETAIL_STR_IMPL

#define REFL_DETAIL_STR_IMPL (   ...)    #__VA_ARGS__

◆ REFL_DETAIL_TYPE_BODY

#define REFL_DETAIL_TYPE_BODY (   TypeName,
  ... 
)
Value:
typedef REFL_DETAIL_GROUP TypeName type; \
REFL_DETAIL_ATTRIBUTES(type, __VA_ARGS__) \
static constexpr auto name{ ::refl::util::make_const_string(REFL_DETAIL_STR(REFL_DETAIL_GROUP TypeName)) }; \
static constexpr size_t member_index_offset = __COUNTER__ + 1; \
template <size_t, typename = void> \
struct member {};

Expands to the body of a type_info__ specialization.

◆ REFL_MAKE_CONST_STRING

#define REFL_MAKE_CONST_STRING (   CString)    (::refl::util::detail::copy_from_unsized<::refl::util::detail::strlen(CString)>(CString))

Converts a compile-time available const char* value to a const_string<N>.

The argument must be a core constant expression and be null-terminated.

See also
refl::util::const_string

◆ REFL_TEMPLATE

#define REFL_TEMPLATE (   TemplateDeclaration,
  TypeName,
  ... 
)
Value:
namespace refl_impl::metadata { template <REFL_DETAIL_GROUP TemplateDeclaration> struct type_info__<REFL_DETAIL_GROUP TypeName> { \
REFL_DETAIL_TYPE_BODY(TypeName, __VA_ARGS__)

Creates reflection information for a specified type template.

Takes an optional attribute list. TemplateDeclaration must be a panenthesis-enclosed list declaring the template parameters. (e.g. (typename A, typename B)). TypeName must be the fully-specialized type name and should also be enclosed in panenthesis. (e.g. (MyType<A, B>)) This macro must only be expanded in the global namespace.

Examples:

REFL_TEMPLATE((typename T), (std::vector<T>))
...
REFL_END

◆ REFL_TYPE

#define REFL_TYPE (   TypeName,
  ... 
)
Value:
namespace refl_impl::metadata { template<> struct type_info__<TypeName> { \
REFL_DETAIL_TYPE_BODY((TypeName), __VA_ARGS__)

Creates reflection information for a specified type.

Takes an optional attribute list. This macro must only be expanded in the global namespace.

Examples:

REFL_TYPE(Point)
...
REFL_END
REFL_TEMPLATE
#define REFL_TEMPLATE(TemplateDeclaration, TypeName,...)
Creates reflection information for a specified type template.
Definition: refl.hpp:4316
REFL_DETAIL_GROUP
#define REFL_DETAIL_GROUP(...)
Used to group input containing commas (e.g.
Definition: refl.hpp:4267
REFL_DETAIL_STR
#define REFL_DETAIL_STR(...)
Used to stringify input separated by commas (e.g.
Definition: refl.hpp:4265
refl::util::make_const_string
constexpr const_string< 1 > make_const_string(char ch) noexcept
Creates an instance of const_string<N>
Definition: refl.hpp:279
REFL_TYPE
#define REFL_TYPE(TypeName,...)
Creates reflection information for a specified type.
Definition: refl.hpp:4299