mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 03:45:30 +07:00
distinguish between function types and function pointer types
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
- type conversions
|
||||
- non-linear search of methods/functions/...
|
||||
- register base types by `META_HPP_ENABLE_POLY_INFO`
|
||||
- distinguish between function types and function pointer types
|
||||
- add the library version to sources
|
||||
- fix all includes to work with the library more flexible
|
||||
- `try_invoke`/`is_invocable` should return error codes
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace
|
||||
TEST_CASE("meta/meta_manuals/function/type") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
// resolves a function type by pointer
|
||||
const meta::function_type add_function_type = meta::resolve_type(&add);
|
||||
// resolves a function type by reference
|
||||
const meta::function_type add_function_type = meta::resolve_type(add);
|
||||
|
||||
// also, it can be resolved by static function type declaration
|
||||
CHECK(add_function_type == meta::resolve_type<int(*)(int, int)>());
|
||||
CHECK(add_function_type == meta::resolve_type<int(int, int)>());
|
||||
|
||||
// checks a return value type
|
||||
CHECK(add_function_type.get_return_type() == meta::resolve_type<int>());
|
||||
@@ -55,7 +55,7 @@ TEST_CASE("meta/meta_manuals/function/usage") {
|
||||
CHECK(sub_function == math_scope.get_function_with<int, int>("sub"));
|
||||
|
||||
// checks a type of the found function
|
||||
CHECK(sub_function.get_type() == meta::resolve_type<int(*)(int, int)>());
|
||||
CHECK(sub_function.get_type() == meta::resolve_type<int(int, int)>());
|
||||
|
||||
// checks the ability to call the function with specific arguments
|
||||
CHECK(sub_function.is_invocable_with(60, 18));
|
||||
|
||||
@@ -504,18 +504,30 @@ namespace meta_hpp::detail
|
||||
|
||||
#ifdef __COUNTER__
|
||||
# define META_HPP_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __COUNTER__) { ::meta_hpp::detail::make_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __COUNTER__) { \
|
||||
::meta_hpp::detail::make_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_ERROR_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __COUNTER__) { ::meta_hpp::detail::make_error_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __COUNTER__) { \
|
||||
::meta_hpp::detail::make_error_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_RETURN_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __COUNTER__) { ::meta_hpp::detail::make_return_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __COUNTER__) { \
|
||||
::meta_hpp::detail::make_return_defer(__VA_ARGS__) \
|
||||
}
|
||||
#else
|
||||
# define META_HPP_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __LINE__) { ::meta_hpp::detail::make_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __LINE__) { \
|
||||
::meta_hpp::detail::make_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_ERROR_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __LINE__) { ::meta_hpp::detail::make_error_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __LINE__) { \
|
||||
::meta_hpp::detail::make_error_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_RETURN_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __LINE__) { ::meta_hpp::detail::make_return_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __LINE__) { \
|
||||
::meta_hpp::detail::make_return_defer(__VA_ARGS__) \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(META_HPP_NO_EXCEPTIONS)
|
||||
@@ -1502,7 +1514,7 @@ namespace meta_hpp::detail
|
||||
concept enum_kind = std::is_enum_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept function_pointer_kind = (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>);
|
||||
concept function_kind = std::is_function_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept member_pointer_kind = std::is_member_object_pointer_v<T>;
|
||||
@@ -1517,7 +1529,7 @@ namespace meta_hpp::detail
|
||||
concept number_kind = std::is_arithmetic_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept pointer_kind = (std::is_pointer_v<T> && !std::is_function_v<std::remove_pointer_t<T>>);
|
||||
concept pointer_kind = std::is_pointer_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept reference_kind = std::is_reference_v<T>;
|
||||
@@ -1529,7 +1541,13 @@ namespace meta_hpp::detail
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename T >
|
||||
concept non_pointer_kind = (!pointer_kind<T>);
|
||||
concept non_pointer_kind = !std::is_pointer_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept function_pointer_kind = std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>;
|
||||
|
||||
template < typename T >
|
||||
concept non_function_pointer_kind = std::is_pointer_v<T> && !std::is_function_v<std::remove_pointer_t<T>>;
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
@@ -1556,7 +1574,7 @@ namespace meta_hpp::detail
|
||||
if constexpr ( array_kind<T> ) { return type_kind::array_; }
|
||||
if constexpr ( class_kind<T> ) { return type_kind::class_; }
|
||||
if constexpr ( enum_kind<T> ) { return type_kind::enum_; }
|
||||
if constexpr ( function_pointer_kind<T> ) { return type_kind::function_; }
|
||||
if constexpr ( function_kind<T> ) { return type_kind::function_; }
|
||||
if constexpr ( member_pointer_kind<T> ) { return type_kind::member_; }
|
||||
if constexpr ( method_pointer_kind<T> ) { return type_kind::method_; }
|
||||
if constexpr ( nullptr_kind<T> ) { return type_kind::nullptr_; }
|
||||
@@ -2021,11 +2039,11 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
struct function_traits;
|
||||
|
||||
template < typename R, typename... Args >
|
||||
struct function_traits<R (*)(Args...)> {
|
||||
struct function_traits<R(Args...)> {
|
||||
static constexpr std::size_t arity{sizeof...(Args)};
|
||||
|
||||
using return_type = R;
|
||||
@@ -2037,7 +2055,7 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
template < typename R, typename... Args >
|
||||
struct function_traits<R (*)(Args...) noexcept> : function_traits<R (*)(Args...)> {
|
||||
struct function_traits<R(Args...) noexcept> : function_traits<R(Args...)> {
|
||||
[[nodiscard]] static constexpr function_bitflags make_flags() noexcept {
|
||||
return function_flags::is_noexcept;
|
||||
}
|
||||
@@ -2867,7 +2885,9 @@ namespace meta_hpp
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
struct type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const type_kind kind;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
metadata_map metadata{};
|
||||
|
||||
@@ -2884,19 +2904,23 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct array_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const array_bitflags flags;
|
||||
const std::size_t extent;
|
||||
const any_type data_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < array_kind Array >
|
||||
explicit array_type_data(type_list<Array>);
|
||||
};
|
||||
|
||||
struct class_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const class_bitflags flags;
|
||||
const std::size_t size;
|
||||
const std::size_t align;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
class_list base_classes;
|
||||
class_list derived_classes;
|
||||
@@ -2951,25 +2975,31 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct constructor_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const constructor_bitflags flags;
|
||||
const class_type owner_type;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < class_kind Class, typename... Args >
|
||||
explicit constructor_type_data(type_list<Class>, type_list<Args...>);
|
||||
};
|
||||
|
||||
struct destructor_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const destructor_bitflags flags;
|
||||
const class_type owner_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < class_kind Class >
|
||||
explicit destructor_type_data(type_list<Class>);
|
||||
};
|
||||
|
||||
struct enum_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const enum_bitflags flags;
|
||||
const number_type underlying_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
evalue_list evalues;
|
||||
|
||||
@@ -2978,28 +3008,34 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct function_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const function_bitflags flags;
|
||||
const any_type return_type;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
explicit function_type_data(type_list<Function>);
|
||||
};
|
||||
|
||||
struct member_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const member_bitflags flags;
|
||||
const class_type owner_type;
|
||||
const any_type value_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < member_pointer_kind Member >
|
||||
explicit member_type_data(type_list<Member>);
|
||||
};
|
||||
|
||||
struct method_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const method_bitflags flags;
|
||||
const class_type owner_type;
|
||||
const any_type return_type;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < method_pointer_kind Method >
|
||||
explicit method_type_data(type_list<Method>);
|
||||
@@ -3011,25 +3047,31 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct number_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const number_bitflags flags;
|
||||
const std::size_t size;
|
||||
const std::size_t align;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < number_kind Number >
|
||||
explicit number_type_data(type_list<Number>);
|
||||
};
|
||||
|
||||
struct pointer_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const pointer_bitflags flags;
|
||||
const any_type data_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < pointer_kind Pointer >
|
||||
explicit pointer_type_data(type_list<Pointer>);
|
||||
};
|
||||
|
||||
struct reference_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const reference_bitflags flags;
|
||||
const any_type data_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < reference_kind Reference >
|
||||
explicit reference_type_data(type_list<Reference>);
|
||||
@@ -4178,7 +4220,7 @@ namespace meta_hpp::detail
|
||||
if constexpr ( array_kind<T> ) { return resolve_array_type<T>(); }
|
||||
if constexpr ( class_kind<T> ) { return resolve_class_type<T>(); }
|
||||
if constexpr ( enum_kind<T> ) { return resolve_enum_type<T>(); }
|
||||
if constexpr ( function_pointer_kind<T> ) { return resolve_function_type<T>(); }
|
||||
if constexpr ( function_kind<T> ) { return resolve_function_type<T>(); }
|
||||
if constexpr ( member_pointer_kind<T> ) { return resolve_member_type<T>(); }
|
||||
if constexpr ( method_pointer_kind<T> ) { return resolve_method_type<T>(); }
|
||||
if constexpr ( nullptr_kind<T> ) { return resolve_nullptr_type<T>(); }
|
||||
@@ -4225,7 +4267,7 @@ namespace meta_hpp::detail
|
||||
return type;
|
||||
}
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
[[nodiscard]] function_type resolve_function_type() {
|
||||
using function_t = std::remove_cv_t<Function>;
|
||||
static function_type type{ensure_type<function_type_data>(type_list<function_t>{})};
|
||||
@@ -4716,7 +4758,7 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::function_pointer_kind Function >
|
||||
template < detail::function_kind Function >
|
||||
class function_bind final : public type_bind_base<function_type> {
|
||||
public:
|
||||
explicit function_bind(metadata_map metadata);
|
||||
@@ -4835,7 +4877,7 @@ namespace meta_hpp
|
||||
return enum_bind<Enum>{std::move(metadata)};
|
||||
}
|
||||
|
||||
template < detail::function_pointer_kind Function >
|
||||
template < detail::function_kind Function >
|
||||
function_bind<Function> function_(metadata_map metadata = {}) {
|
||||
return function_bind<Function>{std::move(metadata)};
|
||||
}
|
||||
@@ -5263,7 +5305,7 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::function_pointer_kind Function >
|
||||
template < detail::function_kind Function >
|
||||
function_bind<Function>::function_bind(metadata_map metadata)
|
||||
: type_bind_base{resolve_type<Function>(), std::move(metadata)} {}
|
||||
}
|
||||
@@ -5963,10 +6005,11 @@ namespace meta_hpp::detail
|
||||
return raw_type_;
|
||||
}
|
||||
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept;
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept;
|
||||
|
||||
private:
|
||||
@@ -6005,10 +6048,11 @@ namespace meta_hpp::detail
|
||||
: uarg_base{registry, std::forward<T>(v)}
|
||||
, data_{const_cast<std::remove_cvref_t<T>*>(std::addressof(v))} {} // NOLINT(*-const-cast)
|
||||
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] decltype(auto) cast(type_registry& registry) const;
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] decltype(auto) cast(type_registry& registry) const;
|
||||
|
||||
private:
|
||||
@@ -6018,7 +6062,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept {
|
||||
using to_raw_type = std::remove_cv_t<To>;
|
||||
|
||||
@@ -6064,7 +6108,8 @@ namespace meta_hpp::detail
|
||||
return false;
|
||||
}
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept {
|
||||
using to_raw_type_cv = std::remove_reference_t<To>;
|
||||
using to_raw_type = std::remove_cv_t<to_raw_type_cv>;
|
||||
@@ -6111,7 +6156,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr ( non_pointer_kind<To> && !std::is_reference_v<To> ) {
|
||||
if constexpr ( !std::is_reference_v<To> ) {
|
||||
if ( is_a(to_type, from_type) && is_constructible_from_type(type_list<to_raw_type>{}) ) {
|
||||
return true;
|
||||
}
|
||||
@@ -6123,7 +6168,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const {
|
||||
META_HPP_DEV_ASSERT(can_cast_to<To>(registry) && "bad argument cast");
|
||||
|
||||
@@ -6165,7 +6210,8 @@ namespace meta_hpp::detail
|
||||
throw_exception(error_code::bad_argument_cast);
|
||||
}
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const {
|
||||
META_HPP_DEV_ASSERT(can_cast_to<To>(registry) && "bad argument cast");
|
||||
|
||||
@@ -6228,8 +6274,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
return [args, ®istry]<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
return (... && args[Is].can_cast_to<type_list_at_t<Is, ArgTypeList>>(registry));
|
||||
}
|
||||
(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}
|
||||
|
||||
template < typename ArgTypeList >
|
||||
@@ -6239,8 +6284,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
return [args, ®istry]<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
return (... && args[Is].can_cast_to<type_list_at_t<Is, ArgTypeList>>(registry));
|
||||
}
|
||||
(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}
|
||||
|
||||
template < typename ArgTypeList, typename F >
|
||||
@@ -6248,14 +6292,13 @@ namespace meta_hpp::detail
|
||||
META_HPP_DEV_ASSERT(args.size() == type_list_arity_v<ArgTypeList>);
|
||||
return [args, ®istry, &f]<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
return f(args[Is].cast<type_list_at_t<Is, ArgTypeList>>(registry)...);
|
||||
}
|
||||
(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
function_type_data::function_type_data(type_list<Function>)
|
||||
: type_data_base{type_kind::function_}
|
||||
, flags{function_traits<Function>::make_flags()}
|
||||
@@ -6290,7 +6333,7 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
uvalue raw_function_invoke(type_registry& registry, Function function_ptr, std::span<const uarg> args) {
|
||||
using ft = function_traits<Function>;
|
||||
using ft = function_traits<std::remove_pointer_t<Function>>;
|
||||
using return_type = typename ft::return_type;
|
||||
using argument_types = typename ft::argument_types;
|
||||
|
||||
@@ -6338,7 +6381,7 @@ namespace meta_hpp::detail
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
uerror raw_function_invoke_error(type_registry& registry, std::span<const uarg_base> args) noexcept {
|
||||
using ft = function_traits<Function>;
|
||||
using ft = function_traits<std::remove_pointer_t<Function>>;
|
||||
using argument_types = typename ft::argument_types;
|
||||
|
||||
if ( args.size() != ft::arity ) {
|
||||
@@ -6371,7 +6414,7 @@ namespace meta_hpp::detail
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
argument_list make_function_arguments() {
|
||||
using ft = function_traits<Function>;
|
||||
using ft = function_traits<std::remove_pointer_t<Function>>;
|
||||
using ft_argument_types = typename ft::argument_types;
|
||||
|
||||
return []<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
@@ -6380,8 +6423,7 @@ namespace meta_hpp::detail
|
||||
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||
};
|
||||
return argument_list{make_argument(index_constant<Is>{})...};
|
||||
}
|
||||
(std::make_index_sequence<ft::arity>());
|
||||
}(std::make_index_sequence<ft::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6394,10 +6436,16 @@ namespace meta_hpp::detail
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
function_state_ptr function_state::make(std::string name, Function function_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
function_state state{function_index{registry.resolve_type<Function>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
function_state state{
|
||||
function_index{registry.resolve_type<std::remove_pointer_t<Function>>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.invoke = make_function_invoke<Policy>(registry, function_ptr);
|
||||
state.invoke_error = make_function_invoke_error<Function>(registry);
|
||||
state.arguments = make_function_arguments<Function>();
|
||||
|
||||
return make_intrusive<function_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -6899,11 +6947,17 @@ namespace meta_hpp::detail
|
||||
template < member_policy_family Policy, member_pointer_kind Member >
|
||||
member_state_ptr member_state::make(std::string name, Member member_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
member_state state{member_index{registry.resolve_type<Member>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
member_state state{
|
||||
member_index{registry.resolve_type<Member>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.getter = make_member_getter<Policy>(registry, member_ptr);
|
||||
state.setter = make_member_setter(registry, member_ptr);
|
||||
state.getter_error = make_member_getter_error<Member>(registry);
|
||||
state.setter_error = make_member_setter_error<Member>(registry);
|
||||
|
||||
return make_intrusive<member_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -7158,8 +7212,7 @@ namespace meta_hpp::detail
|
||||
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||
};
|
||||
return argument_list{make_argument(index_constant<Is>{})...};
|
||||
}
|
||||
(std::make_index_sequence<mt::arity>());
|
||||
}(std::make_index_sequence<mt::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7172,10 +7225,16 @@ namespace meta_hpp::detail
|
||||
template < method_policy_family Policy, method_pointer_kind Method >
|
||||
method_state_ptr method_state::make(std::string name, Method method_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
method_state state{method_index{registry.resolve_type<Method>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
method_state state{
|
||||
method_index{registry.resolve_type<Method>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.invoke = make_method_invoke<Policy>(registry, method_ptr);
|
||||
state.invoke_error = make_method_invoke_error<Method>(registry);
|
||||
state.arguments = make_method_arguments<Method>();
|
||||
|
||||
return make_intrusive<method_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -7461,7 +7520,12 @@ namespace meta_hpp::detail
|
||||
template < typename Argument >
|
||||
inline argument_state_ptr argument_state::make(std::size_t position, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
argument_state state{argument_index{registry.resolve_type<Argument>(), position}, std::move(metadata)};
|
||||
|
||||
argument_state state{
|
||||
argument_index{registry.resolve_type<Argument>(), position},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
return make_intrusive<argument_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -7631,8 +7695,7 @@ namespace meta_hpp::detail
|
||||
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||
};
|
||||
return argument_list{make_argument(index_constant<Is>{})...};
|
||||
}
|
||||
(std::make_index_sequence<ct::arity>());
|
||||
}(std::make_index_sequence<ct::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7645,11 +7708,17 @@ namespace meta_hpp::detail
|
||||
template < constructor_policy_family Policy, class_kind Class, typename... Args >
|
||||
constructor_state_ptr constructor_state::make(metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
constructor_state state{constructor_index{registry.resolve_constructor_type<Class, Args...>()}, std::move(metadata)};
|
||||
|
||||
constructor_state state{
|
||||
constructor_index{registry.resolve_constructor_type<Class, Args...>()},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.create = make_constructor_create<Policy, Class, Args...>(registry);
|
||||
state.create_at = make_constructor_create_at<Class, Args...>(registry);
|
||||
state.create_error = make_constructor_create_error<Class, Args...>(registry);
|
||||
state.arguments = make_constructor_arguments<Class, Args...>();
|
||||
|
||||
return make_intrusive<constructor_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -7820,10 +7889,16 @@ namespace meta_hpp::detail
|
||||
template < class_kind Class >
|
||||
destructor_state_ptr destructor_state::make(metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
destructor_state state{destructor_index{registry.resolve_destructor_type<Class>()}, std::move(metadata)};
|
||||
|
||||
destructor_state state{
|
||||
destructor_index{registry.resolve_destructor_type<Class>()},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.destroy = make_destructor_destroy<Class>(registry);
|
||||
state.destroy_at = make_destructor_destroy_at<Class>();
|
||||
state.destroy_error = make_destructor_destroy_error<Class>(registry);
|
||||
|
||||
return make_intrusive<destructor_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -7950,9 +8025,15 @@ namespace meta_hpp::detail
|
||||
template < enum_kind Enum >
|
||||
evalue_state_ptr evalue_state::make(std::string name, Enum evalue, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
evalue_state state{evalue_index{registry.resolve_type<Enum>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
evalue_state state{
|
||||
evalue_index{registry.resolve_type<Enum>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.enum_value = uvalue{evalue};
|
||||
state.underlying_value = uvalue{to_underlying(evalue)};
|
||||
|
||||
return make_intrusive<evalue_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -8101,10 +8182,16 @@ namespace meta_hpp::detail
|
||||
template < variable_policy_family Policy, pointer_kind Pointer >
|
||||
variable_state_ptr variable_state::make(std::string name, Pointer variable_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
variable_state state{variable_index{registry.resolve_type<Pointer>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
variable_state state{
|
||||
variable_index{registry.resolve_type<Pointer>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.getter = make_variable_getter<Policy>(registry, variable_ptr);
|
||||
state.setter = make_variable_setter(registry, variable_ptr);
|
||||
state.setter_error = make_variable_setter_error<Pointer>(registry);
|
||||
|
||||
return make_intrusive<variable_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -8670,7 +8757,10 @@ namespace meta_hpp::detail
|
||||
, metadata{std::move(nmetadata)} {}
|
||||
|
||||
inline scope_state_ptr scope_state::make(std::string name, metadata_map metadata) {
|
||||
scope_state state{scope_index{std::move(name)}, std::move(metadata)};
|
||||
scope_state state{
|
||||
scope_index{std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
return make_intrusive<scope_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
@@ -9227,6 +9317,7 @@ namespace meta_hpp::detail
|
||||
namespace meta_hpp
|
||||
{
|
||||
struct uvalue::vtable_t final {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const any_type type;
|
||||
|
||||
void (*const move)(uvalue&& self, uvalue& to) noexcept;
|
||||
@@ -9236,6 +9327,7 @@ namespace meta_hpp
|
||||
uvalue (*const deref)(const storage_u& self);
|
||||
uvalue (*const index)(const storage_u& self, std::size_t i);
|
||||
uvalue (*const unmap)(const storage_u& self);
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < typename T >
|
||||
inline static constexpr bool in_internal_v = //
|
||||
|
||||
41
develop/untests/meta_issues/random_issue_3.cpp
Normal file
41
develop/untests/meta_issues/random_issue_3.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <meta.hpp/meta_all.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
int int_func() { return 0; }
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_issues/random/3") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
static_assert(std::is_same_v<decltype(meta::resolve_type<int()>()), meta_hpp::function_type>);
|
||||
static_assert(std::is_same_v<decltype(meta::resolve_type<int(*)()>()), meta_hpp::pointer_type>);
|
||||
static_assert(std::is_same_v<decltype(meta::resolve_type<int(&)()>()), meta_hpp::reference_type>);
|
||||
|
||||
static_assert(std::is_same_v<decltype(meta::resolve_type(int_func)), meta_hpp::function_type>);
|
||||
static_assert(std::is_same_v<decltype(meta::resolve_type(&int_func)), meta_hpp::pointer_type>);
|
||||
|
||||
CHECK(meta::resolve_type<int()>().get_kind() == meta::type_kind::function_);
|
||||
CHECK(meta::resolve_type<int(*)()>().get_kind() == meta::type_kind::pointer_);
|
||||
CHECK(meta::resolve_type<int(&)()>().get_kind() == meta::type_kind::reference_);
|
||||
|
||||
CHECK(meta::resolve_type(int_func).get_kind() == meta::type_kind::function_);
|
||||
CHECK(meta::resolve_type(&int_func).get_kind() == meta::type_kind::pointer_);
|
||||
|
||||
CHECK(meta::resolve_type<int(*)()>().get_data_type() == meta::resolve_type<int()>());
|
||||
CHECK(meta::resolve_type<int(&)()>().get_data_type() == meta::resolve_type<int()>());
|
||||
|
||||
{
|
||||
meta::uvalue v{&int_func};
|
||||
CHECK_FALSE(v.has_deref_op());
|
||||
CHECK(v.get_type() == meta::resolve_type<int(*)()>());
|
||||
CHECK((v.as<decltype(&int_func)>() == &int_func));
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ TEST_CASE("meta/meta_states/function") {
|
||||
CHECK(func.get_index().get_type() == func.get_type());
|
||||
CHECK(func.get_index().get_name() == "iadd");
|
||||
|
||||
CHECK(func.get_type() == meta::resolve_type(&ivec2::iadd));
|
||||
CHECK(func.get_type() == meta::resolve_type(ivec2::iadd));
|
||||
CHECK(func.get_name() == "iadd");
|
||||
|
||||
CHECK_FALSE(func.is_invocable_with<>());
|
||||
@@ -99,7 +99,7 @@ TEST_CASE("meta/meta_states/function") {
|
||||
CHECK(func.get_index().get_type() == func.get_type());
|
||||
CHECK(func.get_index().get_name() == "ilength2");
|
||||
|
||||
CHECK(func.get_type() == meta::resolve_type(&ivec2::ilength2));
|
||||
CHECK(func.get_type() == meta::resolve_type(ivec2::ilength2));
|
||||
CHECK(func.get_name() == "ilength2");
|
||||
|
||||
CHECK_FALSE(func.is_invocable_with<>());
|
||||
|
||||
@@ -269,10 +269,10 @@ TEST_CASE("meta/meta_states/metadata/other") {
|
||||
}
|
||||
|
||||
SUBCASE("function") {
|
||||
meta::function_<int(*)(int)>({
|
||||
meta::function_<int(int)>({
|
||||
{"desc", "int->int"s}
|
||||
});
|
||||
CHECK(meta::resolve_type<int(*)(int)>().get_metadata().at("desc").as<std::string>() == "int->int"s);
|
||||
CHECK(meta::resolve_type<int(int)>().get_metadata().at("desc").as<std::string>() == "int->int"s);
|
||||
}
|
||||
|
||||
SUBCASE("member") {
|
||||
|
||||
@@ -118,11 +118,11 @@ TEST_CASE("meta/meta_types/any_type") {
|
||||
}
|
||||
|
||||
SUBCASE("function") {
|
||||
const meta::any_type& type = meta::resolve_type(&function_v);
|
||||
const meta::any_type& type = meta::resolve_type(function_v);
|
||||
|
||||
REQUIRE(type);
|
||||
REQUIRE(type == meta::resolve_type<decltype(&function_v)>());
|
||||
REQUIRE(type.get_id() == meta::resolve_type<decltype(&function_v)>().get_id());
|
||||
REQUIRE(type == meta::resolve_type<decltype(function_v)>());
|
||||
REQUIRE(type.get_id() == meta::resolve_type<decltype(function_v)>().get_id());
|
||||
|
||||
CHECK(type.is_function());
|
||||
CHECK(type.get_kind() == meta::type_kind::function_);
|
||||
|
||||
@@ -34,10 +34,10 @@ TEST_CASE("meta/meta_types/function_type") {
|
||||
}
|
||||
|
||||
SUBCASE("arg_copy") {
|
||||
const meta::function_type type = meta::resolve_type(&arg_copy);
|
||||
const meta::function_type type = meta::resolve_type(arg_copy);
|
||||
REQUIRE(type);
|
||||
|
||||
CHECK(type.get_id() == meta::resolve_type(&arg_copy).get_id());
|
||||
CHECK(type.get_id() == meta::resolve_type(arg_copy).get_id());
|
||||
CHECK(type.get_flags() == meta::function_flags{});
|
||||
|
||||
CHECK(type.get_arity() == 1);
|
||||
@@ -49,10 +49,10 @@ TEST_CASE("meta/meta_types/function_type") {
|
||||
}
|
||||
|
||||
SUBCASE("arg_ref_noexcept") {
|
||||
const meta::function_type type = meta::resolve_type(&arg_ref_noexcept);
|
||||
const meta::function_type type = meta::resolve_type(arg_ref_noexcept);
|
||||
REQUIRE(type);
|
||||
|
||||
CHECK(type.get_id() == meta::resolve_type(&arg_ref_noexcept).get_id());
|
||||
CHECK(type.get_id() == meta::resolve_type(arg_ref_noexcept).get_id());
|
||||
CHECK(type.get_flags() == meta::function_flags::is_noexcept);
|
||||
CHECK(type.get_argument_types() == meta::any_type_list{meta::resolve_type<ivec2&>()});
|
||||
|
||||
@@ -61,10 +61,10 @@ TEST_CASE("meta/meta_types/function_type") {
|
||||
}
|
||||
|
||||
SUBCASE("arg_cref_noexcept") {
|
||||
const meta::function_type type = meta::resolve_type(&arg_cref_noexcept);
|
||||
const meta::function_type type = meta::resolve_type(arg_cref_noexcept);
|
||||
REQUIRE(type);
|
||||
|
||||
CHECK(type.get_id() == meta::resolve_type(&arg_cref_noexcept).get_id());
|
||||
CHECK(type.get_id() == meta::resolve_type(arg_cref_noexcept).get_id());
|
||||
CHECK(type.get_flags() == meta::function_flags::is_noexcept);
|
||||
CHECK(type.get_argument_types() == meta::any_type_list{meta::resolve_type<const ivec2&>()});
|
||||
|
||||
@@ -73,10 +73,10 @@ TEST_CASE("meta/meta_types/function_type") {
|
||||
}
|
||||
|
||||
SUBCASE("arg_bounded_arr") {
|
||||
const meta::function_type type = meta::resolve_type(&arg_bounded_arr);
|
||||
const meta::function_type type = meta::resolve_type(arg_bounded_arr);
|
||||
REQUIRE(type);
|
||||
|
||||
CHECK(type.get_id() == meta::resolve_type(&arg_bounded_arr).get_id());
|
||||
CHECK(type.get_id() == meta::resolve_type(arg_bounded_arr).get_id());
|
||||
CHECK(type.get_flags() == meta::function_flags{});
|
||||
CHECK(type.get_argument_types() == meta::any_type_list{meta::resolve_type<ivec2*>()});
|
||||
|
||||
@@ -85,10 +85,10 @@ TEST_CASE("meta/meta_types/function_type") {
|
||||
}
|
||||
|
||||
SUBCASE("arg_unbounded_arr") {
|
||||
const meta::function_type type = meta::resolve_type(&arg_unbounded_arr);
|
||||
const meta::function_type type = meta::resolve_type(arg_unbounded_arr);
|
||||
REQUIRE(type);
|
||||
|
||||
CHECK(type.get_id() == meta::resolve_type(&arg_unbounded_arr).get_id());
|
||||
CHECK(type.get_id() == meta::resolve_type(arg_unbounded_arr).get_id());
|
||||
CHECK(type.get_flags() == meta::function_flags{});
|
||||
CHECK(type.get_argument_types() == meta::any_type_list{meta::resolve_type<ivec2*>()});
|
||||
|
||||
@@ -97,10 +97,10 @@ TEST_CASE("meta/meta_types/function_type") {
|
||||
}
|
||||
|
||||
SUBCASE("arg_bounded_const_arr") {
|
||||
const meta::function_type type = meta::resolve_type(&arg_bounded_const_arr);
|
||||
const meta::function_type type = meta::resolve_type(arg_bounded_const_arr);
|
||||
REQUIRE(type);
|
||||
|
||||
CHECK(type.get_id() == meta::resolve_type(&arg_bounded_const_arr).get_id());
|
||||
CHECK(type.get_id() == meta::resolve_type(arg_bounded_const_arr).get_id());
|
||||
CHECK(type.get_flags() == meta::function_flags{});
|
||||
CHECK(type.get_argument_types() == meta::any_type_list{meta::resolve_type<const ivec2*>()});
|
||||
|
||||
@@ -109,10 +109,10 @@ TEST_CASE("meta/meta_types/function_type") {
|
||||
}
|
||||
|
||||
SUBCASE("arg_unbounded_const_arr") {
|
||||
const meta::function_type type = meta::resolve_type(&arg_unbounded_const_arr);
|
||||
const meta::function_type type = meta::resolve_type(arg_unbounded_const_arr);
|
||||
REQUIRE(type);
|
||||
|
||||
CHECK(type.get_id() == meta::resolve_type(&arg_unbounded_const_arr).get_id());
|
||||
CHECK(type.get_id() == meta::resolve_type(arg_unbounded_const_arr).get_id());
|
||||
CHECK(type.get_flags() == meta::function_flags{});
|
||||
CHECK(type.get_argument_types() == meta::any_type_list{meta::resolve_type<const ivec2*>()});
|
||||
|
||||
|
||||
@@ -129,16 +129,28 @@ namespace meta_hpp::detail
|
||||
|
||||
#ifdef __COUNTER__
|
||||
# define META_HPP_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __COUNTER__) { ::meta_hpp::detail::make_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __COUNTER__) { \
|
||||
::meta_hpp::detail::make_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_ERROR_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __COUNTER__) { ::meta_hpp::detail::make_error_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __COUNTER__) { \
|
||||
::meta_hpp::detail::make_error_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_RETURN_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __COUNTER__) { ::meta_hpp::detail::make_return_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __COUNTER__) { \
|
||||
::meta_hpp::detail::make_return_defer(__VA_ARGS__) \
|
||||
}
|
||||
#else
|
||||
# define META_HPP_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __LINE__) { ::meta_hpp::detail::make_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_defer_, __LINE__) { \
|
||||
::meta_hpp::detail::make_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_ERROR_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __LINE__) { ::meta_hpp::detail::make_error_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_error_defer_, __LINE__) { \
|
||||
::meta_hpp::detail::make_error_defer(__VA_ARGS__) \
|
||||
}
|
||||
# define META_HPP_RETURN_DEFER(...) \
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __LINE__) { ::meta_hpp::detail::make_return_defer(__VA_ARGS__) }
|
||||
auto META_HPP_PP_CAT(meta_hpp_generated_return_defer_, __LINE__) { \
|
||||
::meta_hpp::detail::make_return_defer(__VA_ARGS__) \
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace meta_hpp::detail
|
||||
concept enum_kind = std::is_enum_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept function_pointer_kind = (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>);
|
||||
concept function_kind = std::is_function_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept member_pointer_kind = std::is_member_object_pointer_v<T>;
|
||||
@@ -35,7 +35,7 @@ namespace meta_hpp::detail
|
||||
concept number_kind = std::is_arithmetic_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept pointer_kind = (std::is_pointer_v<T> && !std::is_function_v<std::remove_pointer_t<T>>);
|
||||
concept pointer_kind = std::is_pointer_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept reference_kind = std::is_reference_v<T>;
|
||||
@@ -47,7 +47,13 @@ namespace meta_hpp::detail
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename T >
|
||||
concept non_pointer_kind = (!pointer_kind<T>);
|
||||
concept non_pointer_kind = !std::is_pointer_v<T>;
|
||||
|
||||
template < typename T >
|
||||
concept function_pointer_kind = std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>;
|
||||
|
||||
template < typename T >
|
||||
concept non_function_pointer_kind = std::is_pointer_v<T> && !std::is_function_v<std::remove_pointer_t<T>>;
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
@@ -74,7 +80,7 @@ namespace meta_hpp::detail
|
||||
if constexpr ( array_kind<T> ) { return type_kind::array_; }
|
||||
if constexpr ( class_kind<T> ) { return type_kind::class_; }
|
||||
if constexpr ( enum_kind<T> ) { return type_kind::enum_; }
|
||||
if constexpr ( function_pointer_kind<T> ) { return type_kind::function_; }
|
||||
if constexpr ( function_kind<T> ) { return type_kind::function_; }
|
||||
if constexpr ( member_pointer_kind<T> ) { return type_kind::member_; }
|
||||
if constexpr ( method_pointer_kind<T> ) { return type_kind::method_; }
|
||||
if constexpr ( nullptr_kind<T> ) { return type_kind::nullptr_; }
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::function_pointer_kind Function >
|
||||
template < detail::function_kind Function >
|
||||
class function_bind final : public type_bind_base<function_type> {
|
||||
public:
|
||||
explicit function_bind(metadata_map metadata);
|
||||
@@ -354,7 +354,7 @@ namespace meta_hpp
|
||||
return enum_bind<Enum>{std::move(metadata)};
|
||||
}
|
||||
|
||||
template < detail::function_pointer_kind Function >
|
||||
template < detail::function_kind Function >
|
||||
function_bind<Function> function_(metadata_map metadata = {}) {
|
||||
return function_bind<Function>{std::move(metadata)};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::function_pointer_kind Function >
|
||||
template < detail::function_kind Function >
|
||||
function_bind<Function>::function_bind(metadata_map metadata)
|
||||
: type_bind_base{resolve_type<Function>(), std::move(metadata)} {}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace meta_hpp::detail
|
||||
if constexpr ( array_kind<T> ) { return resolve_array_type<T>(); }
|
||||
if constexpr ( class_kind<T> ) { return resolve_class_type<T>(); }
|
||||
if constexpr ( enum_kind<T> ) { return resolve_enum_type<T>(); }
|
||||
if constexpr ( function_pointer_kind<T> ) { return resolve_function_type<T>(); }
|
||||
if constexpr ( function_kind<T> ) { return resolve_function_type<T>(); }
|
||||
if constexpr ( member_pointer_kind<T> ) { return resolve_member_type<T>(); }
|
||||
if constexpr ( method_pointer_kind<T> ) { return resolve_method_type<T>(); }
|
||||
if constexpr ( nullptr_kind<T> ) { return resolve_nullptr_type<T>(); }
|
||||
@@ -99,7 +99,7 @@ namespace meta_hpp::detail
|
||||
return type;
|
||||
}
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
[[nodiscard]] function_type resolve_function_type() {
|
||||
using function_t = std::remove_cv_t<Function>;
|
||||
static function_type type{ensure_type<function_type_data>(type_list<function_t>{})};
|
||||
|
||||
@@ -20,11 +20,11 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
struct function_traits;
|
||||
|
||||
template < typename R, typename... Args >
|
||||
struct function_traits<R (*)(Args...)> {
|
||||
struct function_traits<R(Args...)> {
|
||||
static constexpr std::size_t arity{sizeof...(Args)};
|
||||
|
||||
using return_type = R;
|
||||
@@ -36,7 +36,7 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
template < typename R, typename... Args >
|
||||
struct function_traits<R (*)(Args...) noexcept> : function_traits<R (*)(Args...)> {
|
||||
struct function_traits<R(Args...) noexcept> : function_traits<R(Args...)> {
|
||||
[[nodiscard]] static constexpr function_bitflags make_flags() noexcept {
|
||||
return function_flags::is_noexcept;
|
||||
}
|
||||
|
||||
@@ -82,10 +82,11 @@ namespace meta_hpp::detail
|
||||
return raw_type_;
|
||||
}
|
||||
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept;
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept;
|
||||
|
||||
private:
|
||||
@@ -124,10 +125,11 @@ namespace meta_hpp::detail
|
||||
: uarg_base{registry, std::forward<T>(v)}
|
||||
, data_{const_cast<std::remove_cvref_t<T>*>(std::addressof(v))} {} // NOLINT(*-const-cast)
|
||||
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] decltype(auto) cast(type_registry& registry) const;
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] decltype(auto) cast(type_registry& registry) const;
|
||||
|
||||
private:
|
||||
@@ -137,7 +139,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept {
|
||||
using to_raw_type = std::remove_cv_t<To>;
|
||||
|
||||
@@ -183,7 +185,8 @@ namespace meta_hpp::detail
|
||||
return false;
|
||||
}
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept {
|
||||
using to_raw_type_cv = std::remove_reference_t<To>;
|
||||
using to_raw_type = std::remove_cv_t<to_raw_type_cv>;
|
||||
@@ -230,7 +233,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr ( non_pointer_kind<To> && !std::is_reference_v<To> ) {
|
||||
if constexpr ( !std::is_reference_v<To> ) {
|
||||
if ( is_a(to_type, from_type) && is_constructible_from_type(type_list<to_raw_type>{}) ) {
|
||||
return true;
|
||||
}
|
||||
@@ -242,7 +245,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < pointer_kind To >
|
||||
template < non_function_pointer_kind To >
|
||||
[[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const {
|
||||
META_HPP_DEV_ASSERT(can_cast_to<To>(registry) && "bad argument cast");
|
||||
|
||||
@@ -284,7 +287,8 @@ namespace meta_hpp::detail
|
||||
throw_exception(error_code::bad_argument_cast);
|
||||
}
|
||||
|
||||
template < non_pointer_kind To >
|
||||
template < typename To >
|
||||
requires(!non_function_pointer_kind<To>)
|
||||
[[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const {
|
||||
META_HPP_DEV_ASSERT(can_cast_to<To>(registry) && "bad argument cast");
|
||||
|
||||
@@ -347,8 +351,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
return [args, ®istry]<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
return (... && args[Is].can_cast_to<type_list_at_t<Is, ArgTypeList>>(registry));
|
||||
}
|
||||
(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}
|
||||
|
||||
template < typename ArgTypeList >
|
||||
@@ -358,8 +361,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
return [args, ®istry]<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
return (... && args[Is].can_cast_to<type_list_at_t<Is, ArgTypeList>>(registry));
|
||||
}
|
||||
(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}
|
||||
|
||||
template < typename ArgTypeList, typename F >
|
||||
@@ -367,7 +369,6 @@ namespace meta_hpp::detail
|
||||
META_HPP_DEV_ASSERT(args.size() == type_list_arity_v<ArgTypeList>);
|
||||
return [args, ®istry, &f]<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
return f(args[Is].cast<type_list_at_t<Is, ArgTypeList>>(registry)...);
|
||||
}
|
||||
(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}(std::make_index_sequence<type_list_arity_v<ArgTypeList>>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,12 @@ namespace meta_hpp::detail
|
||||
template < typename Argument >
|
||||
inline argument_state_ptr argument_state::make(std::size_t position, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
argument_state state{argument_index{registry.resolve_type<Argument>(), position}, std::move(metadata)};
|
||||
|
||||
argument_state state{
|
||||
argument_index{registry.resolve_type<Argument>(), position},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
return make_intrusive<argument_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +130,7 @@ namespace meta_hpp::detail
|
||||
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||
};
|
||||
return argument_list{make_argument(index_constant<Is>{})...};
|
||||
}
|
||||
(std::make_index_sequence<ct::arity>());
|
||||
}(std::make_index_sequence<ct::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,11 +143,17 @@ namespace meta_hpp::detail
|
||||
template < constructor_policy_family Policy, class_kind Class, typename... Args >
|
||||
constructor_state_ptr constructor_state::make(metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
constructor_state state{constructor_index{registry.resolve_constructor_type<Class, Args...>()}, std::move(metadata)};
|
||||
|
||||
constructor_state state{
|
||||
constructor_index{registry.resolve_constructor_type<Class, Args...>()},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.create = make_constructor_create<Policy, Class, Args...>(registry);
|
||||
state.create_at = make_constructor_create_at<Class, Args...>(registry);
|
||||
state.create_error = make_constructor_create_error<Class, Args...>(registry);
|
||||
state.arguments = make_constructor_arguments<Class, Args...>();
|
||||
|
||||
return make_intrusive<constructor_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,10 +80,16 @@ namespace meta_hpp::detail
|
||||
template < class_kind Class >
|
||||
destructor_state_ptr destructor_state::make(metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
destructor_state state{destructor_index{registry.resolve_destructor_type<Class>()}, std::move(metadata)};
|
||||
|
||||
destructor_state state{
|
||||
destructor_index{registry.resolve_destructor_type<Class>()},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.destroy = make_destructor_destroy<Class>(registry);
|
||||
state.destroy_at = make_destructor_destroy_at<Class>();
|
||||
state.destroy_error = make_destructor_destroy_error<Class>(registry);
|
||||
|
||||
return make_intrusive<destructor_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,15 @@ namespace meta_hpp::detail
|
||||
template < enum_kind Enum >
|
||||
evalue_state_ptr evalue_state::make(std::string name, Enum evalue, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
evalue_state state{evalue_index{registry.resolve_type<Enum>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
evalue_state state{
|
||||
evalue_index{registry.resolve_type<Enum>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.enum_value = uvalue{evalue};
|
||||
state.underlying_value = uvalue{to_underlying(evalue)};
|
||||
|
||||
return make_intrusive<evalue_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
uvalue raw_function_invoke(type_registry& registry, Function function_ptr, std::span<const uarg> args) {
|
||||
using ft = function_traits<Function>;
|
||||
using ft = function_traits<std::remove_pointer_t<Function>>;
|
||||
using return_type = typename ft::return_type;
|
||||
using argument_types = typename ft::argument_types;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace meta_hpp::detail
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
uerror raw_function_invoke_error(type_registry& registry, std::span<const uarg_base> args) noexcept {
|
||||
using ft = function_traits<Function>;
|
||||
using ft = function_traits<std::remove_pointer_t<Function>>;
|
||||
using argument_types = typename ft::argument_types;
|
||||
|
||||
if ( args.size() != ft::arity ) {
|
||||
@@ -98,7 +98,7 @@ namespace meta_hpp::detail
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
argument_list make_function_arguments() {
|
||||
using ft = function_traits<Function>;
|
||||
using ft = function_traits<std::remove_pointer_t<Function>>;
|
||||
using ft_argument_types = typename ft::argument_types;
|
||||
|
||||
return []<std::size_t... Is>(std::index_sequence<Is...>) {
|
||||
@@ -107,8 +107,7 @@ namespace meta_hpp::detail
|
||||
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||
};
|
||||
return argument_list{make_argument(index_constant<Is>{})...};
|
||||
}
|
||||
(std::make_index_sequence<ft::arity>());
|
||||
}(std::make_index_sequence<ft::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,10 +120,16 @@ namespace meta_hpp::detail
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
function_state_ptr function_state::make(std::string name, Function function_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
function_state state{function_index{registry.resolve_type<Function>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
function_state state{
|
||||
function_index{registry.resolve_type<std::remove_pointer_t<Function>>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.invoke = make_function_invoke<Policy>(registry, function_ptr);
|
||||
state.invoke_error = make_function_invoke_error<Function>(registry);
|
||||
state.arguments = make_function_arguments<Function>();
|
||||
|
||||
return make_intrusive<function_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,11 +197,17 @@ namespace meta_hpp::detail
|
||||
template < member_policy_family Policy, member_pointer_kind Member >
|
||||
member_state_ptr member_state::make(std::string name, Member member_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
member_state state{member_index{registry.resolve_type<Member>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
member_state state{
|
||||
member_index{registry.resolve_type<Member>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.getter = make_member_getter<Policy>(registry, member_ptr);
|
||||
state.setter = make_member_setter(registry, member_ptr);
|
||||
state.getter_error = make_member_getter_error<Member>(registry);
|
||||
state.setter_error = make_member_setter_error<Member>(registry);
|
||||
|
||||
return make_intrusive<member_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,7 @@ namespace meta_hpp::detail
|
||||
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||
};
|
||||
return argument_list{make_argument(index_constant<Is>{})...};
|
||||
}
|
||||
(std::make_index_sequence<mt::arity>());
|
||||
}(std::make_index_sequence<mt::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,10 +132,16 @@ namespace meta_hpp::detail
|
||||
template < method_policy_family Policy, method_pointer_kind Method >
|
||||
method_state_ptr method_state::make(std::string name, Method method_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
method_state state{method_index{registry.resolve_type<Method>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
method_state state{
|
||||
method_index{registry.resolve_type<Method>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.invoke = make_method_invoke<Policy>(registry, method_ptr);
|
||||
state.invoke_error = make_method_invoke_error<Method>(registry);
|
||||
state.arguments = make_method_arguments<Method>();
|
||||
|
||||
return make_intrusive<method_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ namespace meta_hpp::detail
|
||||
, metadata{std::move(nmetadata)} {}
|
||||
|
||||
inline scope_state_ptr scope_state::make(std::string name, metadata_map metadata) {
|
||||
scope_state state{scope_index{std::move(name)}, std::move(metadata)};
|
||||
scope_state state{
|
||||
scope_index{std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
return make_intrusive<scope_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +118,16 @@ namespace meta_hpp::detail
|
||||
template < variable_policy_family Policy, pointer_kind Pointer >
|
||||
variable_state_ptr variable_state::make(std::string name, Pointer variable_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
variable_state state{variable_index{registry.resolve_type<Pointer>(), std::move(name)}, std::move(metadata)};
|
||||
|
||||
variable_state state{
|
||||
variable_index{registry.resolve_type<Pointer>(), std::move(name)},
|
||||
std::move(metadata),
|
||||
};
|
||||
|
||||
state.getter = make_variable_getter<Policy>(registry, variable_ptr);
|
||||
state.setter = make_variable_setter(registry, variable_ptr);
|
||||
state.setter_error = make_variable_setter_error<Pointer>(registry);
|
||||
|
||||
return make_intrusive<variable_state>(std::move(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,7 +462,9 @@ namespace meta_hpp
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
struct type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const type_kind kind;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
metadata_map metadata{};
|
||||
|
||||
@@ -479,19 +481,23 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct array_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const array_bitflags flags;
|
||||
const std::size_t extent;
|
||||
const any_type data_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < array_kind Array >
|
||||
explicit array_type_data(type_list<Array>);
|
||||
};
|
||||
|
||||
struct class_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const class_bitflags flags;
|
||||
const std::size_t size;
|
||||
const std::size_t align;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
class_list base_classes;
|
||||
class_list derived_classes;
|
||||
@@ -546,25 +552,31 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct constructor_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const constructor_bitflags flags;
|
||||
const class_type owner_type;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < class_kind Class, typename... Args >
|
||||
explicit constructor_type_data(type_list<Class>, type_list<Args...>);
|
||||
};
|
||||
|
||||
struct destructor_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const destructor_bitflags flags;
|
||||
const class_type owner_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < class_kind Class >
|
||||
explicit destructor_type_data(type_list<Class>);
|
||||
};
|
||||
|
||||
struct enum_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const enum_bitflags flags;
|
||||
const number_type underlying_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
evalue_list evalues;
|
||||
|
||||
@@ -573,28 +585,34 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct function_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const function_bitflags flags;
|
||||
const any_type return_type;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
explicit function_type_data(type_list<Function>);
|
||||
};
|
||||
|
||||
struct member_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const member_bitflags flags;
|
||||
const class_type owner_type;
|
||||
const any_type value_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < member_pointer_kind Member >
|
||||
explicit member_type_data(type_list<Member>);
|
||||
};
|
||||
|
||||
struct method_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const method_bitflags flags;
|
||||
const class_type owner_type;
|
||||
const any_type return_type;
|
||||
const any_type_list argument_types;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < method_pointer_kind Method >
|
||||
explicit method_type_data(type_list<Method>);
|
||||
@@ -606,25 +624,31 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
struct number_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const number_bitflags flags;
|
||||
const std::size_t size;
|
||||
const std::size_t align;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < number_kind Number >
|
||||
explicit number_type_data(type_list<Number>);
|
||||
};
|
||||
|
||||
struct pointer_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const pointer_bitflags flags;
|
||||
const any_type data_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < pointer_kind Pointer >
|
||||
explicit pointer_type_data(type_list<Pointer>);
|
||||
};
|
||||
|
||||
struct reference_type_data final : type_data_base {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const reference_bitflags flags;
|
||||
const any_type data_type;
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < reference_kind Reference >
|
||||
explicit reference_type_data(type_list<Reference>);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < function_pointer_kind Function >
|
||||
template < function_kind Function >
|
||||
function_type_data::function_type_data(type_list<Function>)
|
||||
: type_data_base{type_kind::function_}
|
||||
, flags{function_traits<Function>::make_flags()}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
namespace meta_hpp
|
||||
{
|
||||
struct uvalue::vtable_t final {
|
||||
// NOLINTBEGIN(*-avoid-const-or-ref-data-members)
|
||||
const any_type type;
|
||||
|
||||
void (*const move)(uvalue&& self, uvalue& to) noexcept;
|
||||
@@ -29,6 +30,7 @@ namespace meta_hpp
|
||||
uvalue (*const deref)(const storage_u& self);
|
||||
uvalue (*const index)(const storage_u& self, std::size_t i);
|
||||
uvalue (*const unmap)(const storage_u& self);
|
||||
// NOLINTEND(*-avoid-const-or-ref-data-members)
|
||||
|
||||
template < typename T >
|
||||
inline static constexpr bool in_internal_v = //
|
||||
|
||||
Reference in New Issue
Block a user