GMP 0.4.0
Generative Metaprogramming library for C++
Loading...
Searching...
No Matches
meta.hpp File Reference
#include <array>
#include <functional>
#include <optional>
#include <source_location>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <utility>
#include <gmp/meta/config.hpp>
#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
 

Concepts

concept  gmp::reflectable
 Constraint for aggregate types supported by the reflection helpers.
 

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.
 

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 E >
requires std::is_enum_v<E>
constexpr auto gmp::enum_underlying (E value) noexcept -> std::underlying_type_t< E >
 Return the underlying integer value of an enumerator.
 
template<typename E >
requires std::is_enum_v<E>
constexpr bool gmp::enum_contains (E value)
 Test whether an enumerator is present in the reflected set.
 
template<typename E , typename U >
requires std::is_enum_v<E> && std::is_integral_v<U>
constexpr bool gmp::enum_contains (U value)
 Test whether an underlying integer value is a reflected enumerator.
 
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 >
requires reflectable<T>
constexpr auto gmp::member_index (std::string_view name) -> std::optional< std::size_t >
 Find a reflected member by name.
 
template<typename T >
requires reflectable<T>
constexpr bool gmp::has_member (std::string_view name)
 Test whether an aggregate has a reflected member with the given name.
 
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 >
requires reflectable<T>
constexpr auto gmp::tie_members (T &value) noexcept
 Return a tuple of references to all members of an aggregate.
 
template<typename T , typename F >
requires reflectable<T>
constexpr decltype(autogmp::apply_members (T &value, F &&func) noexcept(noexcept(std::apply(std::forward< F >(func), tie_members(value))))
 Invoke a callable with all aggregate members as separate arguments.
 
template<typename T , typename F >
requires reflectable<T>
constexpr void gmp::for_each_member (T &&value, F &&func) noexcept(noexcept(detail::for_each_member_impl(std::forward< T >(value), std::forward< F >(func), std::make_index_sequence< member_count_v< std::remove_cvref_t< T > > >{})))
 Visit each member of an aggregate object together with its member name.
 
template<typename T , typename F >
requires reflectable<T>
constexpr bool gmp::visit_member (T &&value, std::string_view name, F &&func)
 Visit a member selected by 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.
 
template<typename T >
constexpr auto gmp::member_count_v
 Number of members in an aggregate type as an inline constant.