diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index fb15d5a..a9765e0 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -1375,6 +1375,12 @@ namespace meta_hpp::detail concept void_kind = std::is_void_v; } +namespace meta_hpp::detail +{ + template < typename T > + concept non_pointer_kind = (!pointer_kind); +} + namespace meta_hpp::detail { enum class type_kind : std::uint32_t { @@ -1456,6 +1462,9 @@ namespace meta_hpp || std::is_same_v // || std::is_same_v // || std::is_same_v; // + + template < typename T > + concept non_uvalue_family = (!uvalue_family); } } @@ -2905,8 +2914,8 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // !detail::is_in_place_type_v && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uvalue(T&& val); @@ -2914,7 +2923,7 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uvalue& operator=(T&& val); @@ -2962,44 +2971,28 @@ namespace meta_hpp template < typename T > [[nodiscard]] bool is() const noexcept; - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T as(); - - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T as() const; - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] T as() &&; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] T& as() &; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] const T& as() const&; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] const T&& as() const&&; - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T try_as() noexcept; - - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T try_as() const noexcept; - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] T* try_as() noexcept; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] const T* try_as() const noexcept; private: @@ -3126,8 +3119,8 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // !detail::is_in_place_type_v && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uresult(T&& val); @@ -3135,7 +3128,7 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uresult& operator=(T&& val); @@ -3337,31 +3330,31 @@ namespace meta_hpp } template < typename Policy > - concept constructor_policy_kind // + concept constructor_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept function_policy_kind // + concept function_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept member_policy_kind // + concept member_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept method_policy_kind // + concept method_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept variable_policy_kind // + concept variable_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; @@ -3691,7 +3684,7 @@ namespace meta_hpp::detail create_error_impl create_error{}; argument_list arguments{}; - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + template < constructor_policy_family Policy, class_kind Class, typename... Args > [[nodiscard]] static constructor_state_ptr make(metadata_map metadata); explicit constructor_state(constructor_index index, metadata_map metadata); }; @@ -3736,7 +3729,7 @@ namespace meta_hpp::detail invoke_error_impl invoke_error{}; argument_list arguments{}; - template < function_policy_kind Policy, function_pointer_kind Function > + template < function_policy_family Policy, function_pointer_kind Function > [[nodiscard]] static function_state_ptr make(std::string name, Function function_ptr, metadata_map metadata); explicit function_state(function_index index, metadata_map metadata); }; @@ -3756,7 +3749,7 @@ namespace meta_hpp::detail getter_error_impl getter_error{}; setter_error_impl setter_error{}; - template < member_policy_kind Policy, member_pointer_kind Member > + template < member_policy_family Policy, member_pointer_kind Member > [[nodiscard]] static member_state_ptr make(std::string name, Member member_ptr, metadata_map metadata); explicit member_state(member_index index, metadata_map metadata); }; @@ -3772,7 +3765,7 @@ namespace meta_hpp::detail invoke_error_impl invoke_error{}; argument_list arguments{}; - template < method_policy_kind Policy, method_pointer_kind Method > + template < method_policy_family Policy, method_pointer_kind Method > [[nodiscard]] static method_state_ptr make(std::string name, Method method_ptr, metadata_map metadata); explicit method_state(method_index index, metadata_map metadata); }; @@ -3801,7 +3794,7 @@ namespace meta_hpp::detail setter_impl setter{}; setter_error_impl setter_error{}; - template < variable_policy_kind Policy, pointer_kind Pointer > + template < variable_policy_family Policy, pointer_kind Pointer > [[nodiscard]] static variable_state_ptr make(std::string name, Pointer variable_ptr, metadata_map metadata); explicit variable_state(variable_index index, metadata_map metadata); }; @@ -4396,11 +4389,11 @@ namespace meta_hpp // constructor_ - template < typename... Args, constructor_policy_kind Policy = constructor_policy::as_object_t > + template < typename... Args, constructor_policy_family Policy = constructor_policy::as_object_t > class_bind& constructor_(Policy = {}) requires detail::class_bind_constructor_kind; - template < typename... Args, constructor_policy_kind Policy = constructor_policy::as_object_t > + template < typename... Args, constructor_policy_family Policy = constructor_policy::as_object_t > class_bind& constructor_(constructor_opts opts, Policy = {}) requires detail::class_bind_constructor_kind; @@ -4414,36 +4407,36 @@ namespace meta_hpp // function_ - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > class_bind& function_(std::string name, Function function_ptr, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > class_bind& function_(std::string name, Function function_ptr, function_opts opts, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > class_bind& function_(std::string name, Function function_ptr, string_ilist arguments, Policy = {}); // member_ - template < detail::member_pointer_kind Member, member_policy_kind Policy = member_policy::as_copy_t > + template < detail::member_pointer_kind Member, member_policy_family Policy = member_policy::as_copy_t > requires detail::class_bind_member_kind class_bind& member_(std::string name, Member member_ptr, Policy = {}); - template < detail::member_pointer_kind Member, member_policy_kind Policy = member_policy::as_copy_t > + template < detail::member_pointer_kind Member, member_policy_family Policy = member_policy::as_copy_t > requires detail::class_bind_member_kind class_bind& member_(std::string name, Member member_ptr, member_opts opts, Policy = {}); // method_ - template < detail::method_pointer_kind Method, method_policy_kind Policy = method_policy::as_copy_t > + template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t > requires detail::class_bind_method_kind class_bind& method_(std::string name, Method method_ptr, Policy = {}); - template < detail::method_pointer_kind Method, method_policy_kind Policy = method_policy::as_copy_t > + template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t > requires detail::class_bind_method_kind class_bind& method_(std::string name, Method method_ptr, method_opts opts, Policy = {}); - template < detail::method_pointer_kind Method, method_policy_kind Policy = method_policy::as_copy_t > + template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t > requires detail::class_bind_method_kind class_bind& method_(std::string name, Method method_ptr, string_ilist arguments, Policy = {}); @@ -4454,10 +4447,10 @@ namespace meta_hpp // variable_ - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > class_bind& variable_(std::string name, Pointer variable_ptr, Policy = {}); - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > class_bind& variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy = {}); }; } @@ -4554,13 +4547,13 @@ namespace meta_hpp // function_ - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > scope_bind& function_(std::string name, Function function_ptr, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > scope_bind& function_(std::string name, Function function_ptr, function_opts opts, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > scope_bind& function_(std::string name, Function function_ptr, string_ilist arguments, Policy = {}); // typedef_ @@ -4570,10 +4563,10 @@ namespace meta_hpp // variable_ - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > scope_bind& variable_(std::string name, Pointer variable_ptr, Policy = {}); - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > scope_bind& variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy = {}); }; } @@ -4708,7 +4701,7 @@ namespace meta_hpp // template < detail::class_kind Class > - template < typename... Args, constructor_policy_kind Policy > + template < typename... Args, constructor_policy_family Policy > class_bind& class_bind::constructor_(Policy policy) requires detail::class_bind_constructor_kind { @@ -4716,7 +4709,7 @@ namespace meta_hpp } template < detail::class_kind Class > - template < typename... Args, constructor_policy_kind Policy > + template < typename... Args, constructor_policy_family Policy > class_bind& class_bind::constructor_(constructor_opts opts, Policy) requires detail::class_bind_constructor_kind { @@ -4762,13 +4755,13 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > class_bind& class_bind::function_(std::string name, Function function_ptr, Policy policy) { return function_(std::move(name), function_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > class_bind& class_bind::function_(std::string name, Function function_ptr, function_opts opts, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, std::move(opts.metadata)); @@ -4788,7 +4781,7 @@ namespace meta_hpp } template < detail::class_kind Class > - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > class_bind& class_bind::function_(std::string name, Function function_ptr, string_ilist arguments, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, {}); @@ -4812,14 +4805,14 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::member_pointer_kind Member, member_policy_kind Policy > + template < detail::member_pointer_kind Member, member_policy_family Policy > requires detail::class_bind_member_kind class_bind& class_bind::member_(std::string name, Member member_ptr, Policy policy) { return member_(std::move(name), member_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::member_pointer_kind Member, member_policy_kind Policy > + template < detail::member_pointer_kind Member, member_policy_family Policy > requires detail::class_bind_member_kind class_bind& class_bind::member_(std::string name, Member member_ptr, member_opts opts, Policy) { auto state = detail::member_state::make(std::move(name), member_ptr, std::move(opts.metadata)); @@ -4832,14 +4825,14 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::method_pointer_kind Method, method_policy_kind Policy > + template < detail::method_pointer_kind Method, method_policy_family Policy > requires detail::class_bind_method_kind class_bind& class_bind::method_(std::string name, Method method_ptr, Policy policy) { return method_(std::move(name), method_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::method_pointer_kind Method, method_policy_kind Policy > + template < detail::method_pointer_kind Method, method_policy_family Policy > requires detail::class_bind_method_kind class_bind& class_bind::method_(std::string name, Method method_ptr, method_opts opts, Policy) { auto state = detail::method_state::make(std::move(name), method_ptr, std::move(opts.metadata)); @@ -4860,7 +4853,7 @@ namespace meta_hpp } template < detail::class_kind Class > - template < detail::method_pointer_kind Method, method_policy_kind Policy > + template < detail::method_pointer_kind Method, method_policy_family Policy > requires detail::class_bind_method_kind class_bind& class_bind::method_(std::string name, Method method_ptr, string_ilist arguments, Policy) { auto state = detail::method_state::make(std::move(name), method_ptr, {}); @@ -4896,13 +4889,13 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > class_bind& class_bind::variable_(std::string name, Pointer variable_ptr, Policy policy) { return variable_(std::move(name), variable_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > class_bind& class_bind::variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy) { auto state = detail::variable_state::make(std::move(name), variable_ptr, std::move(opts.metadata)); detail::insert_or_assign(get_data().variables, variable{std::move(state)}); @@ -4987,12 +4980,12 @@ namespace meta_hpp // function_ // - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > scope_bind& scope_bind::function_(std::string name, Function function_ptr, Policy policy) { return function_(std::move(name), function_ptr, {}, policy); } - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > scope_bind& scope_bind::function_(std::string name, Function function_ptr, function_opts opts, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, std::move(opts.metadata)); @@ -5011,7 +5004,7 @@ namespace meta_hpp return *this; } - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > scope_bind& scope_bind::function_(std::string name, Function function_ptr, string_ilist arguments, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, {}); @@ -5044,12 +5037,12 @@ namespace meta_hpp // variable_ // - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > scope_bind& scope_bind::variable_(std::string name, Pointer variable_ptr, Policy policy) { return variable_(std::move(name), variable_ptr, {}, policy); } - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > scope_bind& scope_bind::variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy) { auto state = detail::variable_state::make(std::move(name), variable_ptr, std::move(opts.metadata)); detail::insert_or_assign(get_state().variables, variable{std::move(state)}); @@ -5361,13 +5354,13 @@ namespace meta_hpp namespace meta_hpp::detail { template < typename T, typename Tp = std::decay_t > - concept arg_lvalue_ref_kind // - = (!uvalue_family) // + concept arg_lvalue_ref_kind // + = (non_uvalue_family) // && (std::is_lvalue_reference_v); template < typename T, typename Tp = std::decay_t > - concept arg_rvalue_ref_kind // - = (!uvalue_family) // + concept arg_rvalue_ref_kind // + = (non_uvalue_family) // && (!std::is_reference_v || std::is_rvalue_reference_v); } @@ -5380,13 +5373,13 @@ namespace meta_hpp::detail template < typename T, typename Tp = std::decay_t > concept inst_class_lvalue_ref_kind // - = (!uvalue_family) // + = (non_uvalue_family) // && (std::is_lvalue_reference_v) // && (std::is_class_v>>); template < typename T, typename Tp = std::decay_t > concept inst_class_rvalue_ref_kind // - = (!uvalue_family) // + = (non_uvalue_family) // && (!std::is_reference_v || std::is_rvalue_reference_v) // && (std::is_class_v>>); } @@ -5554,8 +5547,7 @@ namespace meta_hpp::detail uarg_base& operator=(uarg_base&&) = delete; uarg_base& operator=(const uarg_base&) = delete; - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uarg_base(type_registry& registry, T&&) : uarg_base{registry, type_list{}} {} @@ -5603,12 +5595,10 @@ namespace meta_hpp::detail return raw_type_; } - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept; - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept; private: @@ -5642,18 +5632,15 @@ namespace meta_hpp::detail : uarg_base{registry, std::forward(v)} , data_{const_cast(v->get_data())} {} // NOLINT(*-const-cast) - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uarg(type_registry& registry, T&& v) : uarg_base{registry, std::forward(v)} , data_{const_cast*>(std::addressof(v))} {} // NOLINT(*-const-cast) - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] decltype(auto) cast(type_registry& registry) const; - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] decltype(auto) cast(type_registry& registry) const; private: @@ -5663,8 +5650,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept { using to_raw_type = std::remove_cv_t; @@ -5710,8 +5696,7 @@ namespace meta_hpp::detail return false; } - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept { using to_raw_type_cv = std::remove_reference_t; using to_raw_type = std::remove_cv_t; @@ -5758,7 +5743,7 @@ namespace meta_hpp::detail } } - if constexpr ( !pointer_kind && !std::is_reference_v ) { + if constexpr ( non_pointer_kind && !std::is_reference_v ) { if ( is_a(to_type, from_type) && is_constructible_from_type(type_list{}) ) { return true; } @@ -5770,8 +5755,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const { META_HPP_ASSERT(can_cast_to(registry) && "bad argument cast"); @@ -5807,8 +5791,7 @@ namespace meta_hpp::detail throw_exception(error_code::bad_argument_cast); } - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const { META_HPP_ASSERT(can_cast_to(registry) && "bad argument cast"); @@ -5929,7 +5912,7 @@ namespace meta_hpp namespace meta_hpp::detail { - template < function_policy_kind Policy, function_pointer_kind Function > + template < function_policy_family Policy, function_pointer_kind Function > uvalue raw_function_invoke(type_registry& registry, Function function_ptr, std::span args) { using ft = function_traits; using return_type = typename ft::return_type; @@ -5996,7 +5979,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < function_policy_kind Policy, function_pointer_kind Function > + template < function_policy_family Policy, function_pointer_kind Function > function_state::invoke_impl make_function_invoke(type_registry& registry, Function function_ptr) { return [®istry, function_ptr](std::span args) { // return raw_function_invoke(registry, function_ptr, args); @@ -6032,7 +6015,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < function_policy_kind Policy, function_pointer_kind Function > + 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(), std::move(name)}, std::move(metadata)}; @@ -6128,8 +6111,7 @@ namespace meta_hpp::detail uinst_base& operator=(uinst_base&&) = delete; uinst_base& operator=(const uinst_base&) = delete; - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uinst_base(type_registry& registry, T&&) : uinst_base{registry, type_list{}} {} @@ -6216,8 +6198,7 @@ namespace meta_hpp::detail : uinst_base{registry, std::forward(v)} , data_{const_cast(v->get_data())} {} // NOLINT(*-const-cast) - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uinst(type_registry& registry, T&& v) : uinst_base{registry, std::forward(v)} , data_{const_cast*>(std::addressof(v))} {} // NOLINT(*-const-cast) @@ -6361,7 +6342,7 @@ namespace meta_hpp namespace meta_hpp::detail { - template < member_policy_kind Policy, member_pointer_kind Member > + template < member_policy_family Policy, member_pointer_kind Member > uvalue raw_member_getter(type_registry& registry, Member member_ptr, const uinst& inst) { using mt = member_traits; using class_type = typename mt::class_type; @@ -6504,7 +6485,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < member_policy_kind Policy, member_pointer_kind Member > + template < member_policy_family Policy, member_pointer_kind Member > member_state::getter_impl make_member_getter(type_registry& registry, Member member_ptr) { return [®istry, member_ptr](const uinst& inst) { // return raw_member_getter(registry, member_ptr, inst); @@ -6539,7 +6520,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < member_policy_kind Policy, member_pointer_kind Member > + 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(), std::move(name)}, std::move(metadata)}; @@ -6701,7 +6682,7 @@ namespace meta_hpp namespace meta_hpp::detail { - template < method_policy_kind Policy, method_pointer_kind Method > + template < method_policy_family Policy, method_pointer_kind Method > uvalue raw_method_invoke(type_registry& registry, Method method_ptr, const uinst& inst, std::span args) { using mt = method_traits; using return_type = typename mt::return_type; @@ -6779,7 +6760,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < method_policy_kind Policy, method_pointer_kind Method > + template < method_policy_family Policy, method_pointer_kind Method > method_state::invoke_impl make_method_invoke(type_registry& registry, Method method_ptr) { return [®istry, method_ptr](const uinst& inst, std::span args) { return raw_method_invoke(registry, method_ptr, inst, args); @@ -6815,7 +6796,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < method_policy_kind Policy, method_pointer_kind Method > + 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(), std::move(name)}, std::move(metadata)}; @@ -7100,7 +7081,7 @@ namespace meta_hpp namespace meta_hpp::detail { - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + template < constructor_policy_family Policy, class_kind Class, typename... Args > uvalue raw_constructor_create(type_registry& registry, std::span args) { using ct = constructor_traits; using class_type = typename ct::class_type; @@ -7183,7 +7164,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + template < constructor_policy_family Policy, class_kind Class, typename... Args > constructor_state::create_impl make_constructor_create(type_registry& registry) { return [®istry](std::span args) { // return raw_constructor_create(registry, args); @@ -7226,7 +7207,7 @@ namespace meta_hpp::detail : index{nindex} , metadata{std::move(nmetadata)} {} - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + 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()}, std::move(metadata)}; @@ -7591,7 +7572,7 @@ namespace meta_hpp namespace meta_hpp::detail { - template < variable_policy_kind Policy, pointer_kind Pointer > + template < variable_policy_family Policy, pointer_kind Pointer > uvalue raw_variable_getter(type_registry&, Pointer variable_ptr) { using pt = pointer_traits; using data_type = typename pt::data_type; @@ -7663,7 +7644,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < variable_policy_kind Policy, pointer_kind Pointer > + template < variable_policy_family Policy, pointer_kind Pointer > variable_state::getter_impl make_variable_getter(type_registry& registry, Pointer variable_ptr) { return [®istry, variable_ptr]() { // return raw_variable_getter(registry, variable_ptr); @@ -7691,7 +7672,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < variable_policy_kind Policy, pointer_kind Pointer > + 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(), std::move(name)}, std::move(metadata)}; @@ -9020,8 +9001,7 @@ namespace meta_hpp return detail::is_a(resolve_type(), get_type()); } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::as() { static_assert(std::is_same_v>); @@ -9032,8 +9012,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::as() const { static_assert(std::is_same_v>); @@ -9044,8 +9023,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > T uvalue::as() && { static_assert(std::is_same_v>); @@ -9056,8 +9034,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > T& uvalue::as() & { static_assert(std::is_same_v>); @@ -9068,8 +9045,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > const T& uvalue::as() const& { static_assert(std::is_same_v>); @@ -9080,8 +9056,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > const T&& uvalue::as() const&& { static_assert(std::is_same_v>); @@ -9092,8 +9067,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::try_as() noexcept { static_assert(std::is_same_v>); @@ -9107,8 +9081,7 @@ namespace meta_hpp return nullptr; } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::try_as() const noexcept { static_assert(std::is_same_v>); @@ -9122,8 +9095,7 @@ namespace meta_hpp return nullptr; } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > T* uvalue::try_as() noexcept { static_assert(std::is_same_v>); @@ -9137,8 +9109,7 @@ namespace meta_hpp return nullptr; } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > const T* uvalue::try_as() const noexcept { static_assert(std::is_same_v>); diff --git a/headers/meta.hpp/meta_base.hpp b/headers/meta.hpp/meta_base.hpp index dc3fa47..db7104e 100644 --- a/headers/meta.hpp/meta_base.hpp +++ b/headers/meta.hpp/meta_base.hpp @@ -73,6 +73,9 @@ namespace meta_hpp || std::is_same_v // || std::is_same_v // || std::is_same_v; // + + template < typename T > + concept non_uvalue_family = (!uvalue_family); } } diff --git a/headers/meta.hpp/meta_base/type_kinds.hpp b/headers/meta.hpp/meta_base/type_kinds.hpp index d4f3905..0ade348 100644 --- a/headers/meta.hpp/meta_base/type_kinds.hpp +++ b/headers/meta.hpp/meta_base/type_kinds.hpp @@ -44,6 +44,12 @@ namespace meta_hpp::detail concept void_kind = std::is_void_v; } +namespace meta_hpp::detail +{ + template < typename T > + concept non_pointer_kind = (!pointer_kind); +} + namespace meta_hpp::detail { enum class type_kind : std::uint32_t { diff --git a/headers/meta.hpp/meta_binds.hpp b/headers/meta.hpp/meta_binds.hpp index ac3a22b..5f2e50e 100644 --- a/headers/meta.hpp/meta_binds.hpp +++ b/headers/meta.hpp/meta_binds.hpp @@ -155,11 +155,11 @@ namespace meta_hpp // constructor_ - template < typename... Args, constructor_policy_kind Policy = constructor_policy::as_object_t > + template < typename... Args, constructor_policy_family Policy = constructor_policy::as_object_t > class_bind& constructor_(Policy = {}) requires detail::class_bind_constructor_kind; - template < typename... Args, constructor_policy_kind Policy = constructor_policy::as_object_t > + template < typename... Args, constructor_policy_family Policy = constructor_policy::as_object_t > class_bind& constructor_(constructor_opts opts, Policy = {}) requires detail::class_bind_constructor_kind; @@ -173,36 +173,36 @@ namespace meta_hpp // function_ - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > class_bind& function_(std::string name, Function function_ptr, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > class_bind& function_(std::string name, Function function_ptr, function_opts opts, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > class_bind& function_(std::string name, Function function_ptr, string_ilist arguments, Policy = {}); // member_ - template < detail::member_pointer_kind Member, member_policy_kind Policy = member_policy::as_copy_t > + template < detail::member_pointer_kind Member, member_policy_family Policy = member_policy::as_copy_t > requires detail::class_bind_member_kind class_bind& member_(std::string name, Member member_ptr, Policy = {}); - template < detail::member_pointer_kind Member, member_policy_kind Policy = member_policy::as_copy_t > + template < detail::member_pointer_kind Member, member_policy_family Policy = member_policy::as_copy_t > requires detail::class_bind_member_kind class_bind& member_(std::string name, Member member_ptr, member_opts opts, Policy = {}); // method_ - template < detail::method_pointer_kind Method, method_policy_kind Policy = method_policy::as_copy_t > + template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t > requires detail::class_bind_method_kind class_bind& method_(std::string name, Method method_ptr, Policy = {}); - template < detail::method_pointer_kind Method, method_policy_kind Policy = method_policy::as_copy_t > + template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t > requires detail::class_bind_method_kind class_bind& method_(std::string name, Method method_ptr, method_opts opts, Policy = {}); - template < detail::method_pointer_kind Method, method_policy_kind Policy = method_policy::as_copy_t > + template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t > requires detail::class_bind_method_kind class_bind& method_(std::string name, Method method_ptr, string_ilist arguments, Policy = {}); @@ -213,10 +213,10 @@ namespace meta_hpp // variable_ - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > class_bind& variable_(std::string name, Pointer variable_ptr, Policy = {}); - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > class_bind& variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy = {}); }; } @@ -313,13 +313,13 @@ namespace meta_hpp // function_ - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > scope_bind& function_(std::string name, Function function_ptr, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > scope_bind& function_(std::string name, Function function_ptr, function_opts opts, Policy = {}); - template < detail::function_pointer_kind Function, function_policy_kind Policy = function_policy::as_copy_t > + template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t > scope_bind& function_(std::string name, Function function_ptr, string_ilist arguments, Policy = {}); // typedef_ @@ -329,10 +329,10 @@ namespace meta_hpp // variable_ - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > scope_bind& variable_(std::string name, Pointer variable_ptr, Policy = {}); - template < detail::pointer_kind Pointer, variable_policy_kind Policy = variable_policy::as_copy_t > + template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t > scope_bind& variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy = {}); }; } diff --git a/headers/meta.hpp/meta_binds/class_bind.hpp b/headers/meta.hpp/meta_binds/class_bind.hpp index 70e9113..8515490 100644 --- a/headers/meta.hpp/meta_binds/class_bind.hpp +++ b/headers/meta.hpp/meta_binds/class_bind.hpp @@ -58,7 +58,7 @@ namespace meta_hpp // template < detail::class_kind Class > - template < typename... Args, constructor_policy_kind Policy > + template < typename... Args, constructor_policy_family Policy > class_bind& class_bind::constructor_(Policy policy) requires detail::class_bind_constructor_kind { @@ -66,7 +66,7 @@ namespace meta_hpp } template < detail::class_kind Class > - template < typename... Args, constructor_policy_kind Policy > + template < typename... Args, constructor_policy_family Policy > class_bind& class_bind::constructor_(constructor_opts opts, Policy) requires detail::class_bind_constructor_kind { @@ -112,13 +112,13 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > class_bind& class_bind::function_(std::string name, Function function_ptr, Policy policy) { return function_(std::move(name), function_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > class_bind& class_bind::function_(std::string name, Function function_ptr, function_opts opts, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, std::move(opts.metadata)); @@ -138,7 +138,7 @@ namespace meta_hpp } template < detail::class_kind Class > - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > class_bind& class_bind::function_(std::string name, Function function_ptr, string_ilist arguments, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, {}); @@ -162,14 +162,14 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::member_pointer_kind Member, member_policy_kind Policy > + template < detail::member_pointer_kind Member, member_policy_family Policy > requires detail::class_bind_member_kind class_bind& class_bind::member_(std::string name, Member member_ptr, Policy policy) { return member_(std::move(name), member_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::member_pointer_kind Member, member_policy_kind Policy > + template < detail::member_pointer_kind Member, member_policy_family Policy > requires detail::class_bind_member_kind class_bind& class_bind::member_(std::string name, Member member_ptr, member_opts opts, Policy) { auto state = detail::member_state::make(std::move(name), member_ptr, std::move(opts.metadata)); @@ -182,14 +182,14 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::method_pointer_kind Method, method_policy_kind Policy > + template < detail::method_pointer_kind Method, method_policy_family Policy > requires detail::class_bind_method_kind class_bind& class_bind::method_(std::string name, Method method_ptr, Policy policy) { return method_(std::move(name), method_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::method_pointer_kind Method, method_policy_kind Policy > + template < detail::method_pointer_kind Method, method_policy_family Policy > requires detail::class_bind_method_kind class_bind& class_bind::method_(std::string name, Method method_ptr, method_opts opts, Policy) { auto state = detail::method_state::make(std::move(name), method_ptr, std::move(opts.metadata)); @@ -210,7 +210,7 @@ namespace meta_hpp } template < detail::class_kind Class > - template < detail::method_pointer_kind Method, method_policy_kind Policy > + template < detail::method_pointer_kind Method, method_policy_family Policy > requires detail::class_bind_method_kind class_bind& class_bind::method_(std::string name, Method method_ptr, string_ilist arguments, Policy) { auto state = detail::method_state::make(std::move(name), method_ptr, {}); @@ -246,13 +246,13 @@ namespace meta_hpp // template < detail::class_kind Class > - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > class_bind& class_bind::variable_(std::string name, Pointer variable_ptr, Policy policy) { return variable_(std::move(name), variable_ptr, {}, policy); } template < detail::class_kind Class > - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > class_bind& class_bind::variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy) { auto state = detail::variable_state::make(std::move(name), variable_ptr, std::move(opts.metadata)); detail::insert_or_assign(get_data().variables, variable{std::move(state)}); diff --git a/headers/meta.hpp/meta_binds/scope_bind.hpp b/headers/meta.hpp/meta_binds/scope_bind.hpp index d62cb9f..2f44e5d 100644 --- a/headers/meta.hpp/meta_binds/scope_bind.hpp +++ b/headers/meta.hpp/meta_binds/scope_bind.hpp @@ -19,12 +19,12 @@ namespace meta_hpp // function_ // - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > scope_bind& scope_bind::function_(std::string name, Function function_ptr, Policy policy) { return function_(std::move(name), function_ptr, {}, policy); } - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > scope_bind& scope_bind::function_(std::string name, Function function_ptr, function_opts opts, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, std::move(opts.metadata)); @@ -43,7 +43,7 @@ namespace meta_hpp return *this; } - template < detail::function_pointer_kind Function, function_policy_kind Policy > + template < detail::function_pointer_kind Function, function_policy_family Policy > scope_bind& scope_bind::function_(std::string name, Function function_ptr, string_ilist arguments, Policy) { auto state = detail::function_state::make(std::move(name), function_ptr, {}); @@ -76,12 +76,12 @@ namespace meta_hpp // variable_ // - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > scope_bind& scope_bind::variable_(std::string name, Pointer variable_ptr, Policy policy) { return variable_(std::move(name), variable_ptr, {}, policy); } - template < detail::pointer_kind Pointer, variable_policy_kind Policy > + template < detail::pointer_kind Pointer, variable_policy_family Policy > scope_bind& scope_bind::variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy) { auto state = detail::variable_state::make(std::move(name), variable_ptr, std::move(opts.metadata)); detail::insert_or_assign(get_state().variables, variable{std::move(state)}); diff --git a/headers/meta.hpp/meta_detail/value_utilities/uarg.hpp b/headers/meta.hpp/meta_detail/value_utilities/uarg.hpp index d98ce22..d772f28 100644 --- a/headers/meta.hpp/meta_detail/value_utilities/uarg.hpp +++ b/headers/meta.hpp/meta_detail/value_utilities/uarg.hpp @@ -34,8 +34,7 @@ namespace meta_hpp::detail uarg_base& operator=(uarg_base&&) = delete; uarg_base& operator=(const uarg_base&) = delete; - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uarg_base(type_registry& registry, T&&) : uarg_base{registry, type_list{}} {} @@ -83,12 +82,10 @@ namespace meta_hpp::detail return raw_type_; } - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept; - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] bool can_cast_to(type_registry& registry) const noexcept; private: @@ -122,18 +119,15 @@ namespace meta_hpp::detail : uarg_base{registry, std::forward(v)} , data_{const_cast(v->get_data())} {} // NOLINT(*-const-cast) - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uarg(type_registry& registry, T&& v) : uarg_base{registry, std::forward(v)} , data_{const_cast*>(std::addressof(v))} {} // NOLINT(*-const-cast) - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] decltype(auto) cast(type_registry& registry) const; - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] decltype(auto) cast(type_registry& registry) const; private: @@ -143,8 +137,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept { using to_raw_type = std::remove_cv_t; @@ -190,8 +183,7 @@ namespace meta_hpp::detail return false; } - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] bool uarg_base::can_cast_to(type_registry& registry) const noexcept { using to_raw_type_cv = std::remove_reference_t; using to_raw_type = std::remove_cv_t; @@ -238,7 +230,7 @@ namespace meta_hpp::detail } } - if constexpr ( !pointer_kind && !std::is_reference_v ) { + if constexpr ( non_pointer_kind && !std::is_reference_v ) { if ( is_a(to_type, from_type) && is_constructible_from_type(type_list{}) ) { return true; } @@ -250,8 +242,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < typename To > - requires pointer_kind + template < pointer_kind To > [[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const { META_HPP_ASSERT(can_cast_to(registry) && "bad argument cast"); @@ -287,8 +278,7 @@ namespace meta_hpp::detail throw_exception(error_code::bad_argument_cast); } - template < typename To > - requires(!pointer_kind) + template < non_pointer_kind To > [[nodiscard]] decltype(auto) uarg::cast(type_registry& registry) const { META_HPP_ASSERT(can_cast_to(registry) && "bad argument cast"); diff --git a/headers/meta.hpp/meta_detail/value_utilities/uinst.hpp b/headers/meta.hpp/meta_detail/value_utilities/uinst.hpp index efff60e..89475f4 100644 --- a/headers/meta.hpp/meta_detail/value_utilities/uinst.hpp +++ b/headers/meta.hpp/meta_detail/value_utilities/uinst.hpp @@ -34,8 +34,7 @@ namespace meta_hpp::detail uinst_base& operator=(uinst_base&&) = delete; uinst_base& operator=(const uinst_base&) = delete; - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uinst_base(type_registry& registry, T&&) : uinst_base{registry, type_list{}} {} @@ -122,8 +121,7 @@ namespace meta_hpp::detail : uinst_base{registry, std::forward(v)} , data_{const_cast(v->get_data())} {} // NOLINT(*-const-cast) - template < typename T, typename Tp = std::decay_t > - requires(!uvalue_family) + template < typename T, non_uvalue_family Tp = std::decay_t > explicit uinst(type_registry& registry, T&& v) : uinst_base{registry, std::forward(v)} , data_{const_cast*>(std::addressof(v))} {} // NOLINT(*-const-cast) diff --git a/headers/meta.hpp/meta_detail/value_utilities/utraits.hpp b/headers/meta.hpp/meta_detail/value_utilities/utraits.hpp index c76b4a7..57e0f6f 100644 --- a/headers/meta.hpp/meta_detail/value_utilities/utraits.hpp +++ b/headers/meta.hpp/meta_detail/value_utilities/utraits.hpp @@ -12,13 +12,13 @@ namespace meta_hpp::detail { template < typename T, typename Tp = std::decay_t > - concept arg_lvalue_ref_kind // - = (!uvalue_family) // + concept arg_lvalue_ref_kind // + = (non_uvalue_family) // && (std::is_lvalue_reference_v); template < typename T, typename Tp = std::decay_t > - concept arg_rvalue_ref_kind // - = (!uvalue_family) // + concept arg_rvalue_ref_kind // + = (non_uvalue_family) // && (!std::is_reference_v || std::is_rvalue_reference_v); } @@ -31,13 +31,13 @@ namespace meta_hpp::detail template < typename T, typename Tp = std::decay_t > concept inst_class_lvalue_ref_kind // - = (!uvalue_family) // + = (non_uvalue_family) // && (std::is_lvalue_reference_v) // && (std::is_class_v>>); template < typename T, typename Tp = std::decay_t > concept inst_class_rvalue_ref_kind // - = (!uvalue_family) // + = (non_uvalue_family) // && (!std::is_reference_v || std::is_rvalue_reference_v) // && (std::is_class_v>>); } diff --git a/headers/meta.hpp/meta_states.hpp b/headers/meta.hpp/meta_states.hpp index 71d9c9b..a834ffb 100644 --- a/headers/meta.hpp/meta_states.hpp +++ b/headers/meta.hpp/meta_states.hpp @@ -82,31 +82,31 @@ namespace meta_hpp } template < typename Policy > - concept constructor_policy_kind // + concept constructor_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept function_policy_kind // + concept function_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept member_policy_kind // + concept member_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept method_policy_kind // + concept method_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; template < typename Policy > - concept variable_policy_kind // + concept variable_policy_family // = std::is_same_v // || std::is_same_v // || std::is_same_v; @@ -436,7 +436,7 @@ namespace meta_hpp::detail create_error_impl create_error{}; argument_list arguments{}; - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + template < constructor_policy_family Policy, class_kind Class, typename... Args > [[nodiscard]] static constructor_state_ptr make(metadata_map metadata); explicit constructor_state(constructor_index index, metadata_map metadata); }; @@ -481,7 +481,7 @@ namespace meta_hpp::detail invoke_error_impl invoke_error{}; argument_list arguments{}; - template < function_policy_kind Policy, function_pointer_kind Function > + template < function_policy_family Policy, function_pointer_kind Function > [[nodiscard]] static function_state_ptr make(std::string name, Function function_ptr, metadata_map metadata); explicit function_state(function_index index, metadata_map metadata); }; @@ -501,7 +501,7 @@ namespace meta_hpp::detail getter_error_impl getter_error{}; setter_error_impl setter_error{}; - template < member_policy_kind Policy, member_pointer_kind Member > + template < member_policy_family Policy, member_pointer_kind Member > [[nodiscard]] static member_state_ptr make(std::string name, Member member_ptr, metadata_map metadata); explicit member_state(member_index index, metadata_map metadata); }; @@ -517,7 +517,7 @@ namespace meta_hpp::detail invoke_error_impl invoke_error{}; argument_list arguments{}; - template < method_policy_kind Policy, method_pointer_kind Method > + template < method_policy_family Policy, method_pointer_kind Method > [[nodiscard]] static method_state_ptr make(std::string name, Method method_ptr, metadata_map metadata); explicit method_state(method_index index, metadata_map metadata); }; @@ -546,7 +546,7 @@ namespace meta_hpp::detail setter_impl setter{}; setter_error_impl setter_error{}; - template < variable_policy_kind Policy, pointer_kind Pointer > + template < variable_policy_family Policy, pointer_kind Pointer > [[nodiscard]] static variable_state_ptr make(std::string name, Pointer variable_ptr, metadata_map metadata); explicit variable_state(variable_index index, metadata_map metadata); }; diff --git a/headers/meta.hpp/meta_states/constructor.hpp b/headers/meta.hpp/meta_states/constructor.hpp index 6bcc18c..42d9890 100644 --- a/headers/meta.hpp/meta_states/constructor.hpp +++ b/headers/meta.hpp/meta_states/constructor.hpp @@ -15,7 +15,7 @@ namespace meta_hpp::detail { - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + template < constructor_policy_family Policy, class_kind Class, typename... Args > uvalue raw_constructor_create(type_registry& registry, std::span args) { using ct = constructor_traits; using class_type = typename ct::class_type; @@ -98,7 +98,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + template < constructor_policy_family Policy, class_kind Class, typename... Args > constructor_state::create_impl make_constructor_create(type_registry& registry) { return [®istry](std::span args) { // return raw_constructor_create(registry, args); @@ -141,7 +141,7 @@ namespace meta_hpp::detail : index{nindex} , metadata{std::move(nmetadata)} {} - template < constructor_policy_kind Policy, class_kind Class, typename... Args > + 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()}, std::move(metadata)}; diff --git a/headers/meta.hpp/meta_states/function.hpp b/headers/meta.hpp/meta_states/function.hpp index 1dcbc2c..7408383 100644 --- a/headers/meta.hpp/meta_states/function.hpp +++ b/headers/meta.hpp/meta_states/function.hpp @@ -15,7 +15,7 @@ namespace meta_hpp::detail { - template < function_policy_kind Policy, function_pointer_kind Function > + template < function_policy_family Policy, function_pointer_kind Function > uvalue raw_function_invoke(type_registry& registry, Function function_ptr, std::span args) { using ft = function_traits; using return_type = typename ft::return_type; @@ -82,7 +82,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < function_policy_kind Policy, function_pointer_kind Function > + template < function_policy_family Policy, function_pointer_kind Function > function_state::invoke_impl make_function_invoke(type_registry& registry, Function function_ptr) { return [®istry, function_ptr](std::span args) { // return raw_function_invoke(registry, function_ptr, args); @@ -118,7 +118,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < function_policy_kind Policy, function_pointer_kind Function > + 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(), std::move(name)}, std::move(metadata)}; diff --git a/headers/meta.hpp/meta_states/member.hpp b/headers/meta.hpp/meta_states/member.hpp index 5622bad..151f71e 100644 --- a/headers/meta.hpp/meta_states/member.hpp +++ b/headers/meta.hpp/meta_states/member.hpp @@ -16,7 +16,7 @@ namespace meta_hpp::detail { - template < member_policy_kind Policy, member_pointer_kind Member > + template < member_policy_family Policy, member_pointer_kind Member > uvalue raw_member_getter(type_registry& registry, Member member_ptr, const uinst& inst) { using mt = member_traits; using class_type = typename mt::class_type; @@ -159,7 +159,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < member_policy_kind Policy, member_pointer_kind Member > + template < member_policy_family Policy, member_pointer_kind Member > member_state::getter_impl make_member_getter(type_registry& registry, Member member_ptr) { return [®istry, member_ptr](const uinst& inst) { // return raw_member_getter(registry, member_ptr, inst); @@ -194,7 +194,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < member_policy_kind Policy, member_pointer_kind Member > + 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(), std::move(name)}, std::move(metadata)}; diff --git a/headers/meta.hpp/meta_states/method.hpp b/headers/meta.hpp/meta_states/method.hpp index a24c14b..e9e385d 100644 --- a/headers/meta.hpp/meta_states/method.hpp +++ b/headers/meta.hpp/meta_states/method.hpp @@ -16,7 +16,7 @@ namespace meta_hpp::detail { - template < method_policy_kind Policy, method_pointer_kind Method > + template < method_policy_family Policy, method_pointer_kind Method > uvalue raw_method_invoke(type_registry& registry, Method method_ptr, const uinst& inst, std::span args) { using mt = method_traits; using return_type = typename mt::return_type; @@ -94,7 +94,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < method_policy_kind Policy, method_pointer_kind Method > + template < method_policy_family Policy, method_pointer_kind Method > method_state::invoke_impl make_method_invoke(type_registry& registry, Method method_ptr) { return [®istry, method_ptr](const uinst& inst, std::span args) { return raw_method_invoke(registry, method_ptr, inst, args); @@ -130,7 +130,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < method_policy_kind Policy, method_pointer_kind Method > + 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(), std::move(name)}, std::move(metadata)}; diff --git a/headers/meta.hpp/meta_states/variable.hpp b/headers/meta.hpp/meta_states/variable.hpp index 655f2fb..535bc0a 100644 --- a/headers/meta.hpp/meta_states/variable.hpp +++ b/headers/meta.hpp/meta_states/variable.hpp @@ -15,7 +15,7 @@ namespace meta_hpp::detail { - template < variable_policy_kind Policy, pointer_kind Pointer > + template < variable_policy_family Policy, pointer_kind Pointer > uvalue raw_variable_getter(type_registry&, Pointer variable_ptr) { using pt = pointer_traits; using data_type = typename pt::data_type; @@ -87,7 +87,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < variable_policy_kind Policy, pointer_kind Pointer > + template < variable_policy_family Policy, pointer_kind Pointer > variable_state::getter_impl make_variable_getter(type_registry& registry, Pointer variable_ptr) { return [®istry, variable_ptr]() { // return raw_variable_getter(registry, variable_ptr); @@ -115,7 +115,7 @@ namespace meta_hpp::detail : index{std::move(nindex)} , metadata{std::move(nmetadata)} {} - template < variable_policy_kind Policy, pointer_kind Pointer > + 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(), std::move(name)}, std::move(metadata)}; diff --git a/headers/meta.hpp/meta_uresult.hpp b/headers/meta.hpp/meta_uresult.hpp index 393f2f7..1ff6f98 100644 --- a/headers/meta.hpp/meta_uresult.hpp +++ b/headers/meta.hpp/meta_uresult.hpp @@ -83,8 +83,8 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // !detail::is_in_place_type_v && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uresult(T&& val); @@ -92,7 +92,7 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uresult& operator=(T&& val); diff --git a/headers/meta.hpp/meta_uvalue.hpp b/headers/meta.hpp/meta_uvalue.hpp index f0fe0a0..9123ad1 100644 --- a/headers/meta.hpp/meta_uvalue.hpp +++ b/headers/meta.hpp/meta_uvalue.hpp @@ -26,8 +26,8 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // !detail::is_in_place_type_v && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uvalue(T&& val); @@ -35,7 +35,7 @@ namespace meta_hpp typename T, // typename Tp = std::decay_t, // typename = std::enable_if_t< // - !detail::uvalue_family && // + detail::non_uvalue_family && // std::is_copy_constructible_v>> // uvalue& operator=(T&& val); @@ -83,44 +83,28 @@ namespace meta_hpp template < typename T > [[nodiscard]] bool is() const noexcept; - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T as(); - - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T as() const; - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] T as() &&; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] T& as() &; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] const T& as() const&; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] const T&& as() const&&; - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T try_as() noexcept; - - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > [[nodiscard]] T try_as() const noexcept; - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] T* try_as() noexcept; - - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > [[nodiscard]] const T* try_as() const noexcept; private: diff --git a/headers/meta.hpp/meta_uvalue/uvalue.hpp b/headers/meta.hpp/meta_uvalue/uvalue.hpp index 957c69e..4ee0bf6 100644 --- a/headers/meta.hpp/meta_uvalue/uvalue.hpp +++ b/headers/meta.hpp/meta_uvalue/uvalue.hpp @@ -439,8 +439,7 @@ namespace meta_hpp return detail::is_a(resolve_type(), get_type()); } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::as() { static_assert(std::is_same_v>); @@ -451,8 +450,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::as() const { static_assert(std::is_same_v>); @@ -463,8 +461,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > T uvalue::as() && { static_assert(std::is_same_v>); @@ -475,8 +472,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > T& uvalue::as() & { static_assert(std::is_same_v>); @@ -487,8 +483,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > const T& uvalue::as() const& { static_assert(std::is_same_v>); @@ -499,8 +494,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > const T&& uvalue::as() const&& { static_assert(std::is_same_v>); @@ -511,8 +505,7 @@ namespace meta_hpp throw_exception(error_code::bad_uvalue_access); } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::try_as() noexcept { static_assert(std::is_same_v>); @@ -526,8 +519,7 @@ namespace meta_hpp return nullptr; } - template < typename T > - requires detail::pointer_kind + template < detail::pointer_kind T > T uvalue::try_as() const noexcept { static_assert(std::is_same_v>); @@ -541,8 +533,7 @@ namespace meta_hpp return nullptr; } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > T* uvalue::try_as() noexcept { static_assert(std::is_same_v>); @@ -556,8 +547,7 @@ namespace meta_hpp return nullptr; } - template < typename T > - requires(!detail::pointer_kind) + template < detail::non_pointer_kind T > const T* uvalue::try_as() const noexcept { static_assert(std::is_same_v>);