GMP 0.3.0
Generative Metaprogramming library for C++
Loading...
Searching...
No Matches
meta.hpp File Reference
#include <optional>
#include <source_location>
#include <gmp/meta/type_name.hpp>
#include <gmp/meta/detail/member_ref.hpp>

Go to the source code of this file.

Classes

struct  gmp::enum_traits< E >
 Customize the reflection range or explicit values for an enumeration. More...
 

Namespaces

namespace  gmp
 

Macros

#define GMP_ENUM_RANGE(Enum, Min, Max)
 Specialize gmp::enum_traits with an explicit scan range.
 
#define GMP_ENUM_VALUES(Enum, ...)
 Specialize gmp::enum_traits with an explicit enumerator list.
 
#define GMP_FOR_EACH_MEMBER_DEFINE(N)
 

Typedefs

template<std::size_t I, typename T >
using gmp::member_type_t = std::remove_cvref_t< decltype(*detail::field_getter< I, T >(constant_arg< member_count< T >()>))>
 Alias for the type of the I-th member of an aggregate type.
 

Functions

template<typename E , fixed_string P = type_name<E>() + fixed_string("::")>
consteval auto gmp::enum_values ()
 Get all enumerator values of an enumeration type at compile-time.
 
template<typename E , fixed_string P = type_name<E>() + fixed_string("::")>
consteval auto gmp::enum_count ()
 Count the number of enumerators in an enumeration type at compile-time.
 
template<auto E, fixed_string P = fixed_string("::")>
consteval auto gmp::enum_name ()
 Get the name of an enumerator at compile-time.
 
template<typename E >
consteval auto gmp::enum_names ()
 Get all enumerator names of an enumeration type at compile-time.
 
template<typename E >
consteval auto gmp::enum_entries ()
 Get all enumerator entries (value, name) of an enumeration type at compile-time.
 
template<typename E >
constexpr auto gmp::enum_index (E value) -> std::optional< std::size_t >
 Get the index of an enumerator value in enum_values<E>().
 
template<typename E >
constexpr auto gmp::enum_cast (std::string_view name) -> std::optional< E >
 Cast an enumerator name to its corresponding enumerator value.
 
template<typename T , typename... Args>
requires std::is_aggregate_v<std::remove_cvref_t<T>>
consteval int gmp::member_count ()
 Count the number of members in an aggregate type at compile-time.
 
template<std::size_t I, typename T >
requires std::is_aggregate_v<T> && (I < member_count<T>()) && (member_count<T>() <= GMP_MAX_SUPPORTED_FIELDS)
consteval auto gmp::member_name () noexcept
 Get the name of a specific member of an aggregate type at compile-time.
 
template<typename T >
consteval auto gmp::member_names ()
 Get all member names of an aggregate type at compile-time.
 
template<typename T >
constexpr auto gmp::member_type_names ()
 Returns an array of string_view containing the type names of all members of aggregate type T.
 
template<std::size_t I, typename T , typename UnqualifiedT = std::remove_cvref_t<T>>
requires std::is_aggregate_v<UnqualifiedT> && (I < member_count<UnqualifiedT>()) && (member_count<UnqualifiedT>() <= GMP_MAX_SUPPORTED_FIELDS)
decltype(autogmp::member_ref (T &&value) noexcept
 Get a reference to the I-th member of an aggregate object.
 
template<typename T , typename F >
requires std::is_aggregate_v<std::remove_cvref_t<T>>
void gmp::for_each_member (T &&value, F &&func) noexcept
 Visit each member of an aggregate object together with its member name.
 

Variables

template<typename E >
constexpr int gmp::enum_min_v
 The minimum reflection scan value for enumeration type E.
 
template<typename E >
constexpr int gmp::enum_max_v
 The maximum reflection scan value for enumeration type E.
 

Macro Definition Documentation

◆ GMP_FOR_EACH_MEMBER_DEFINE

#define GMP_FOR_EACH_MEMBER_DEFINE (   N)

Definition at line 660 of file meta.hpp.