Merge pull request #7 from BlackMATov/dev

Dev
This commit is contained in:
2022-02-14 08:20:54 +07:00
committed by GitHub
18 changed files with 182 additions and 200 deletions

View File

@@ -170,21 +170,6 @@ namespace meta_hpp
struct pointer_type_data;
struct reference_type_data;
struct void_type_data;
using type_data_base_ptr = std::shared_ptr<type_data_base>;
using array_type_data_ptr = std::shared_ptr<array_type_data>;
using class_type_data_ptr = std::shared_ptr<class_type_data>;
using constructor_type_data_ptr = std::shared_ptr<constructor_type_data>;
using destructor_type_data_ptr = std::shared_ptr<destructor_type_data>;
using enum_type_data_ptr = std::shared_ptr<enum_type_data>;
using function_type_data_ptr = std::shared_ptr<function_type_data>;
using member_type_data_ptr = std::shared_ptr<member_type_data>;
using method_type_data_ptr = std::shared_ptr<method_type_data>;
using nullptr_type_data_ptr = std::shared_ptr<nullptr_type_data>;
using number_type_data_ptr = std::shared_ptr<number_type_data>;
using pointer_type_data_ptr = std::shared_ptr<pointer_type_data>;
using reference_type_data_ptr = std::shared_ptr<reference_type_data>;
using void_type_data_ptr = std::shared_ptr<void_type_data>;
}
}

View File

@@ -87,8 +87,8 @@ namespace meta_hpp
explicit array_bind(metadata_map metadata);
operator array_type() const noexcept;
private:
detail::array_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::array_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -220,8 +220,8 @@ namespace meta_hpp
variable_opts opts,
Policy = Policy{});
private:
detail::class_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::class_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -236,8 +236,8 @@ namespace meta_hpp
enum_bind& evalue_(std::string name, Enum value);
enum_bind& evalue_(std::string name, Enum value, evalue_opts opts);
private:
detail::enum_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::enum_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -249,8 +249,8 @@ namespace meta_hpp
explicit function_bind(metadata_map metadata);
operator function_type() const noexcept;
private:
detail::function_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::function_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -262,8 +262,8 @@ namespace meta_hpp
explicit member_bind(metadata_map metadata);
operator member_type() const noexcept;
private:
detail::member_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::member_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -275,8 +275,8 @@ namespace meta_hpp
explicit method_bind(metadata_map metadata);
operator method_type() const noexcept;
private:
detail::method_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::method_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -288,8 +288,8 @@ namespace meta_hpp
explicit nullptr_bind(metadata_map metadata);
operator nullptr_type() const noexcept;
private:
detail::nullptr_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::nullptr_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -301,8 +301,8 @@ namespace meta_hpp
explicit number_bind(metadata_map metadata);
operator number_type() const noexcept;
private:
detail::number_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::number_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -314,8 +314,8 @@ namespace meta_hpp
explicit pointer_bind(metadata_map metadata);
operator pointer_type() const noexcept;
private:
detail::pointer_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::pointer_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -327,8 +327,8 @@ namespace meta_hpp
explicit reference_bind(metadata_map metadata);
operator reference_type() const noexcept;
private:
detail::reference_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::reference_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -340,8 +340,8 @@ namespace meta_hpp
explicit void_bind(metadata_map metadata);
operator void_type() const noexcept;
private:
detail::void_type_data_ptr data_;
detail::type_registry::locker locker_;
detail::void_type_data* data_{};
detail::type_registry::locker locker_{};
};
}
@@ -404,7 +404,7 @@ namespace meta_hpp
Policy = Policy{});
private:
detail::scope_state_ptr state_;
detail::state_registry::locker locker_;
detail::state_registry::locker locker_{};
};
}

View File

@@ -123,81 +123,92 @@ namespace meta_hpp::detail
//
template < array_kind Array >
[[nodiscard]] array_type_data_ptr resolve_array_type_data() {
static array_type_data_ptr data{std::make_shared<array_type_data>(type_list<Array>{})};
return ensure_type<Array>(data);
[[nodiscard]] array_type_data* resolve_array_type_data() {
static array_type_data data{type_list<Array>{}};
ensure_type<Array>(data);
return &data;
}
template < class_kind Class >
[[nodiscard]] class_type_data_ptr resolve_class_type_data() {
static class_type_data_ptr data{std::make_shared<class_type_data>(type_list<Class>{})};
return ensure_type<Class>(data);
[[nodiscard]] class_type_data* resolve_class_type_data() {
static class_type_data data{type_list<Class>{}};
ensure_type<Class>(data);
return &data;
}
template < class_kind Class, typename... Args >
[[nodiscard]] constructor_type_data_ptr resolve_constructor_type_data() {
static constructor_type_data_ptr data{std::make_shared<constructor_type_data>(type_list<Class>{}, type_list<Args...>{})};
return data;
[[nodiscard]] constructor_type_data* resolve_constructor_type_data() {
static constructor_type_data data{type_list<Class>{}, type_list<Args...>{}};
return &data;
}
template < class_kind Class >
[[nodiscard]] destructor_type_data_ptr resolve_destructor_type_data() {
static destructor_type_data_ptr data{std::make_shared<destructor_type_data>(type_list<Class>{})};
return data;
[[nodiscard]] destructor_type_data* resolve_destructor_type_data() {
static destructor_type_data data{type_list<Class>{}};
return &data;
}
template < enum_kind Enum >
[[nodiscard]] enum_type_data_ptr resolve_enum_type_data() {
static enum_type_data_ptr data{std::make_shared<enum_type_data>(type_list<Enum>{})};
return ensure_type<Enum>(data);
[[nodiscard]] enum_type_data* resolve_enum_type_data() {
static enum_type_data data{type_list<Enum>{}};
ensure_type<Enum>(data);
return &data;
}
template < function_kind Function >
[[nodiscard]] function_type_data_ptr resolve_function_type_data() {
static function_type_data_ptr data{std::make_shared<function_type_data>(type_list<Function>{})};
return ensure_type<Function>(data);
[[nodiscard]] function_type_data* resolve_function_type_data() {
static function_type_data data{type_list<Function>{}};
ensure_type<Function>(data);
return &data;
}
template < member_kind Member >
[[nodiscard]] member_type_data_ptr resolve_member_type_data() {
static member_type_data_ptr data{std::make_shared<member_type_data>(type_list<Member>{})};
return ensure_type<Member>(data);
[[nodiscard]] member_type_data* resolve_member_type_data() {
static member_type_data data{type_list<Member>{}};
ensure_type<Member>(data);
return &data;
}
template < method_kind Method >
[[nodiscard]] method_type_data_ptr resolve_method_type_data() {
static method_type_data_ptr data{std::make_shared<method_type_data>(type_list<Method>{})};
return ensure_type<Method>(data);
[[nodiscard]] method_type_data* resolve_method_type_data() {
static method_type_data data{type_list<Method>{}};
ensure_type<Method>(data);
return &data;
}
template < nullptr_kind Nullptr >
[[nodiscard]] nullptr_type_data_ptr resolve_nullptr_type_data() {
static nullptr_type_data_ptr data{std::make_shared<nullptr_type_data>(type_list<Nullptr>{})};
return ensure_type<Nullptr>(data);
[[nodiscard]] nullptr_type_data* resolve_nullptr_type_data() {
static nullptr_type_data data{type_list<Nullptr>{}};
ensure_type<Nullptr>(data);
return &data;
}
template < number_kind Number >
[[nodiscard]] number_type_data_ptr resolve_number_type_data() {
static number_type_data_ptr data{std::make_shared<number_type_data>(type_list<Number>{})};
return ensure_type<Number>(data);
[[nodiscard]] number_type_data* resolve_number_type_data() {
static number_type_data data{type_list<Number>{}};
ensure_type<Number>(data);
return &data;
}
template < pointer_kind Pointer >
[[nodiscard]] pointer_type_data_ptr resolve_pointer_type_data() {
static pointer_type_data_ptr data{std::make_shared<pointer_type_data>(type_list<Pointer>{})};
return ensure_type<Pointer>(data);
[[nodiscard]] pointer_type_data* resolve_pointer_type_data() {
static pointer_type_data data{type_list<Pointer>{}};
ensure_type<Pointer>(data);
return &data;
}
template < reference_kind Reference >
[[nodiscard]] reference_type_data_ptr resolve_reference_type_data() {
static reference_type_data_ptr data{std::make_shared<reference_type_data>(type_list<Reference>{})};
return ensure_type<Reference>(data);
[[nodiscard]] reference_type_data* resolve_reference_type_data() {
static reference_type_data data{type_list<Reference>{}};
ensure_type<Reference>(data);
return &data;
}
template < void_kind Void >
[[nodiscard]] void_type_data_ptr resolve_void_type_data() {
static void_type_data_ptr data{std::make_shared<void_type_data>(type_list<Void>{})};
return ensure_type<Void>(data);
[[nodiscard]] void_type_data* resolve_void_type_data() {
static void_type_data data{type_list<Void>{}};
ensure_type<Void>(data);
return &data;
}
public:
class locker : noncopyable {
@@ -211,16 +222,15 @@ namespace meta_hpp::detail
type_registry() = default;
template < typename Type, typename TypeData >
TypeData ensure_type(const TypeData& type_data) {
void ensure_type(TypeData& type_data) {
static std::once_flag init_flag{};
std::call_once(init_flag, [this, &type_data](){
const locker lock;
type_by_id_[type_data->id] = any_type{type_data};
type_by_id_.emplace(type_data.id, any_type{&type_data});
#ifndef META_HPP_NO_RTTI
type_by_rtti_[typeid(Type)] = any_type{type_data};
type_by_rtti_.emplace(typeid(Type), any_type{&type_data});
#endif
});
return type_data;
}
private:
std::recursive_mutex mutex_;

View File

@@ -114,14 +114,14 @@ namespace meta_hpp
[[nodiscard]] reference_type as_reference() const noexcept;
[[nodiscard]] void_type as_void() const noexcept;
private:
detail::type_data_base_ptr data_;
detail::type_data_base* data_{};
friend auto detail::type_access<any_type>(const any_type&);
};
class array_type final {
public:
array_type() = default;
array_type(detail::array_type_data_ptr data);
array_type(detail::array_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -133,14 +133,14 @@ namespace meta_hpp
[[nodiscard]] std::size_t get_extent() const noexcept;
[[nodiscard]] any_type get_data_type() const noexcept;
private:
detail::array_type_data_ptr data_;
detail::array_type_data* data_{};
friend auto detail::type_access<array_type>(const array_type&);
};
class class_type final {
public:
class_type() = default;
class_type(detail::class_type_data_ptr data);
class_type(detail::class_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -208,14 +208,14 @@ namespace meta_hpp
[[nodiscard]] method get_method_with(std::string_view name, const std::vector<any_type>& args) const noexcept;
[[nodiscard]] method get_method_with(std::string_view name, std::initializer_list<any_type> args) const noexcept;
private:
detail::class_type_data_ptr data_;
detail::class_type_data* data_{};
friend auto detail::type_access<class_type>(const class_type&);
};
class constructor_type final {
public:
constructor_type() = default;
constructor_type(detail::constructor_type_data_ptr data);
constructor_type(detail::constructor_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -229,14 +229,14 @@ namespace meta_hpp
[[nodiscard]] any_type get_argument_type(std::size_t position) const noexcept;
[[nodiscard]] const std::vector<any_type>& get_argument_types() const noexcept;
private:
detail::constructor_type_data_ptr data_;
detail::constructor_type_data* data_{};
friend auto detail::type_access<constructor_type>(const constructor_type&);
};
class destructor_type final {
public:
destructor_type() = default;
destructor_type(detail::destructor_type_data_ptr data);
destructor_type(detail::destructor_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -247,14 +247,14 @@ namespace meta_hpp
[[nodiscard]] any_type get_class_type() const noexcept;
private:
detail::destructor_type_data_ptr data_;
detail::destructor_type_data* data_{};
friend auto detail::type_access<destructor_type>(const destructor_type&);
};
class enum_type final {
public:
enum_type() = default;
enum_type(detail::enum_type_data_ptr data);
enum_type(detail::enum_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -273,14 +273,14 @@ namespace meta_hpp
[[nodiscard]] std::string_view value_to_name(Value&& value) const noexcept;
[[nodiscard]] uvalue name_to_value(std::string_view name) const noexcept;
private:
detail::enum_type_data_ptr data_;
detail::enum_type_data* data_{};
friend auto detail::type_access<enum_type>(const enum_type&);
};
class function_type final {
public:
function_type() = default;
function_type(detail::function_type_data_ptr data);
function_type(detail::function_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -294,14 +294,14 @@ namespace meta_hpp
[[nodiscard]] any_type get_argument_type(std::size_t position) const noexcept;
[[nodiscard]] const std::vector<any_type>& get_argument_types() const noexcept;
private:
detail::function_type_data_ptr data_;
detail::function_type_data* data_{};
friend auto detail::type_access<function_type>(const function_type&);
};
class member_type final {
public:
member_type() = default;
member_type(detail::member_type_data_ptr data);
member_type(detail::member_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -313,14 +313,14 @@ namespace meta_hpp
[[nodiscard]] class_type get_owner_type() const noexcept;
[[nodiscard]] any_type get_value_type() const noexcept;
private:
detail::member_type_data_ptr data_;
detail::member_type_data* data_{};
friend auto detail::type_access<member_type>(const member_type&);
};
class method_type final {
public:
method_type() = default;
method_type(detail::method_type_data_ptr data);
method_type(detail::method_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -335,14 +335,14 @@ namespace meta_hpp
[[nodiscard]] any_type get_argument_type(std::size_t position) const noexcept;
[[nodiscard]] const std::vector<any_type>& get_argument_types() const noexcept;
private:
detail::method_type_data_ptr data_;
detail::method_type_data* data_{};
friend auto detail::type_access<method_type>(const method_type&);
};
class nullptr_type final {
public:
nullptr_type() = default;
nullptr_type(detail::nullptr_type_data_ptr data);
nullptr_type(detail::nullptr_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -350,14 +350,14 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
private:
detail::nullptr_type_data_ptr data_;
detail::nullptr_type_data* data_{};
friend auto detail::type_access<nullptr_type>(const nullptr_type&);
};
class number_type final {
public:
number_type() = default;
number_type(detail::number_type_data_ptr data);
number_type(detail::number_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -368,14 +368,14 @@ namespace meta_hpp
[[nodiscard]] std::size_t get_size() const noexcept;
private:
detail::number_type_data_ptr data_;
detail::number_type_data* data_{};
friend auto detail::type_access<number_type>(const number_type&);
};
class pointer_type final {
public:
pointer_type() = default;
pointer_type(detail::pointer_type_data_ptr data);
pointer_type(detail::pointer_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -386,14 +386,14 @@ namespace meta_hpp
[[nodiscard]] any_type get_data_type() const noexcept;
private:
detail::pointer_type_data_ptr data_;
detail::pointer_type_data* data_{};
friend auto detail::type_access<pointer_type>(const pointer_type&);
};
class reference_type final {
public:
reference_type() = default;
reference_type(detail::reference_type_data_ptr data);
reference_type(detail::reference_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -404,14 +404,14 @@ namespace meta_hpp
[[nodiscard]] any_type get_data_type() const noexcept;
private:
detail::reference_type_data_ptr data_;
detail::reference_type_data* data_{};
friend auto detail::type_access<reference_type>(const reference_type&);
};
class void_type final {
public:
void_type() = default;
void_type(detail::void_type_data_ptr data);
void_type(detail::void_type_data* data);
[[nodiscard]] bool is_valid() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
@@ -419,7 +419,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
private:
detail::void_type_data_ptr data_;
detail::void_type_data* data_{};
friend auto detail::type_access<void_type>(const void_type&);
};
}

View File

@@ -12,7 +12,7 @@
namespace meta_hpp
{
inline bool any_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline any_type::operator bool() const noexcept {
@@ -71,132 +71,119 @@ namespace meta_hpp
: data_{detail::type_access(other)} {}
inline bool any_type::is_array() const noexcept {
return data_ && data_->kind == type_kind::array_;
return is_valid() && data_->kind == type_kind::array_;
}
inline bool any_type::is_class() const noexcept {
return data_ && data_->kind == type_kind::class_;
return is_valid() && data_->kind == type_kind::class_;
}
inline bool any_type::is_constructor() const noexcept {
return data_ && data_->kind == type_kind::constructor_;
return is_valid() && data_->kind == type_kind::constructor_;
}
inline bool any_type::is_destructor() const noexcept {
return data_ && data_->kind == type_kind::destructor_;
return is_valid() && data_->kind == type_kind::destructor_;
}
inline bool any_type::is_enum() const noexcept {
return data_ && data_->kind == type_kind::enum_;
return is_valid() && data_->kind == type_kind::enum_;
}
inline bool any_type::is_function() const noexcept {
return data_ && data_->kind == type_kind::function_;
return is_valid() && data_->kind == type_kind::function_;
}
inline bool any_type::is_member() const noexcept {
return data_ && data_->kind == type_kind::member_;
return is_valid() && data_->kind == type_kind::member_;
}
inline bool any_type::is_method() const noexcept {
return data_ && data_->kind == type_kind::method_;
return is_valid() && data_->kind == type_kind::method_;
}
inline bool any_type::is_nullptr() const noexcept {
return data_ && data_->kind == type_kind::nullptr_;
return is_valid() && data_->kind == type_kind::nullptr_;
}
inline bool any_type::is_number() const noexcept {
return data_ && data_->kind == type_kind::number_;
return is_valid() && data_->kind == type_kind::number_;
}
inline bool any_type::is_pointer() const noexcept {
return data_ && data_->kind == type_kind::pointer_;
return is_valid() && data_->kind == type_kind::pointer_;
}
inline bool any_type::is_reference() const noexcept {
return data_ && data_->kind == type_kind::reference_;
return is_valid() && data_->kind == type_kind::reference_;
}
inline bool any_type::is_void() const noexcept {
return data_ && data_->kind == type_kind::void_;
return is_valid() && data_->kind == type_kind::void_;
}
inline array_type any_type::as_array() const noexcept {
return is_array()
? array_type{std::static_pointer_cast<detail::array_type_data>(data_)}
: array_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_array() ? array_type{static_cast<detail::array_type_data*>(data_)} : array_type{};
}
inline class_type any_type::as_class() const noexcept {
return is_class()
? class_type{std::static_pointer_cast<detail::class_type_data>(data_)}
: class_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_class() ? class_type{static_cast<detail::class_type_data*>(data_)} : class_type{};
}
inline constructor_type any_type::as_constructor() const noexcept {
return is_constructor()
? constructor_type{std::static_pointer_cast<detail::constructor_type_data>(data_)}
: constructor_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_constructor() ? constructor_type{static_cast<detail::constructor_type_data*>(data_)} : constructor_type{};
}
inline destructor_type any_type::as_destructor() const noexcept {
return is_destructor()
? destructor_type{std::static_pointer_cast<detail::destructor_type_data>(data_)}
: destructor_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_destructor() ? destructor_type{static_cast<detail::destructor_type_data*>(data_)} : destructor_type{};
}
inline enum_type any_type::as_enum() const noexcept {
return is_enum()
? enum_type{std::static_pointer_cast<detail::enum_type_data>(data_)}
: enum_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_enum() ? enum_type{static_cast<detail::enum_type_data*>(data_)} : enum_type{};
}
inline function_type any_type::as_function() const noexcept {
return is_function()
? function_type{std::static_pointer_cast<detail::function_type_data>(data_)}
: function_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_function() ? function_type{static_cast<detail::function_type_data*>(data_)} : function_type{};
}
inline member_type any_type::as_member() const noexcept {
return is_member()
? member_type{std::static_pointer_cast<detail::member_type_data>(data_)}
: member_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_member() ? member_type{static_cast<detail::member_type_data*>(data_)} : member_type{};
}
inline method_type any_type::as_method() const noexcept {
return is_method()
? method_type{std::static_pointer_cast<detail::method_type_data>(data_)}
: method_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_method() ? method_type{static_cast<detail::method_type_data*>(data_)} : method_type{};
}
inline nullptr_type any_type::as_nullptr() const noexcept {
return is_nullptr()
? nullptr_type{std::static_pointer_cast<detail::nullptr_type_data>(data_)}
: nullptr_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_nullptr() ? nullptr_type{static_cast<detail::nullptr_type_data*>(data_)} : nullptr_type{};
}
inline number_type any_type::as_number() const noexcept {
return is_number()
? number_type{std::static_pointer_cast<detail::number_type_data>(data_)}
: number_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_number() ? number_type{static_cast<detail::number_type_data*>(data_)} : number_type{};
}
inline pointer_type any_type::as_pointer() const noexcept {
return is_pointer()
? pointer_type{std::static_pointer_cast<detail::pointer_type_data>(data_)}
: pointer_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_pointer() ? pointer_type{static_cast<detail::pointer_type_data*>(data_)} : pointer_type{};
}
inline reference_type any_type::as_reference() const noexcept {
return is_reference()
? reference_type{std::static_pointer_cast<detail::reference_type_data>(data_)}
: reference_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_reference() ? reference_type{static_cast<detail::reference_type_data*>(data_)} : reference_type{};
}
inline void_type any_type::as_void() const noexcept {
return is_void()
? void_type{std::static_pointer_cast<detail::void_type_data>(data_)}
: void_type{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
return is_void() ? void_type{static_cast<detail::void_type_data*>(data_)} : void_type{};
}
}

View File

@@ -28,11 +28,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline array_type::array_type(detail::array_type_data_ptr data)
: data_{std::move(data)} {}
inline array_type::array_type(detail::array_type_data* data)
: data_{data} {}
inline bool array_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline array_type::operator bool() const noexcept {

View File

@@ -34,11 +34,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline class_type::class_type(detail::class_type_data_ptr data)
: data_{std::move(data)} {}
inline class_type::class_type(detail::class_type_data* data)
: data_{data} {}
inline bool class_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline class_type::operator bool() const noexcept {

View File

@@ -28,11 +28,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline constructor_type::constructor_type(detail::constructor_type_data_ptr data)
: data_{std::move(data)} {}
inline constructor_type::constructor_type(detail::constructor_type_data* data)
: data_{data} {}
inline bool constructor_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline constructor_type::operator bool() const noexcept {

View File

@@ -27,11 +27,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline destructor_type::destructor_type(detail::destructor_type_data_ptr data)
: data_{std::move(data)} {}
inline destructor_type::destructor_type(detail::destructor_type_data* data)
: data_{data} {}
inline bool destructor_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline destructor_type::operator bool() const noexcept {

View File

@@ -30,11 +30,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline enum_type::enum_type(detail::enum_type_data_ptr data)
: data_{std::move(data)} {}
inline enum_type::enum_type(detail::enum_type_data* data)
: data_{data} {}
inline bool enum_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline enum_type::operator bool() const noexcept {

View File

@@ -28,11 +28,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline function_type::function_type(detail::function_type_data_ptr data)
: data_{std::move(data)} {}
inline function_type::function_type(detail::function_type_data* data)
: data_{data} {}
inline bool function_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline function_type::operator bool() const noexcept {

View File

@@ -28,11 +28,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline member_type::member_type(detail::member_type_data_ptr data)
: data_{std::move(data)} {}
inline member_type::member_type(detail::member_type_data* data)
: data_{data} {}
inline bool member_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline member_type::operator bool() const noexcept {

View File

@@ -29,11 +29,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline method_type::method_type(detail::method_type_data_ptr data)
: data_{std::move(data)} {}
inline method_type::method_type(detail::method_type_data* data)
: data_{data} {}
inline bool method_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline method_type::operator bool() const noexcept {

View File

@@ -22,11 +22,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline nullptr_type::nullptr_type(detail::nullptr_type_data_ptr data)
: data_{std::move(data)} {}
inline nullptr_type::nullptr_type(detail::nullptr_type_data* data)
: data_{data} {}
inline bool nullptr_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline nullptr_type::operator bool() const noexcept {

View File

@@ -26,11 +26,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline number_type::number_type(detail::number_type_data_ptr data)
: data_{std::move(data)} {}
inline number_type::number_type(detail::number_type_data* data)
: data_{data} {}
inline bool number_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline number_type::operator bool() const noexcept {

View File

@@ -27,11 +27,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline pointer_type::pointer_type(detail::pointer_type_data_ptr data)
: data_{std::move(data)} {}
inline pointer_type::pointer_type(detail::pointer_type_data* data)
: data_{data} {}
inline bool pointer_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline pointer_type::operator bool() const noexcept {

View File

@@ -27,11 +27,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline reference_type::reference_type(detail::reference_type_data_ptr data)
: data_{std::move(data)} {}
inline reference_type::reference_type(detail::reference_type_data* data)
: data_{data} {}
inline bool reference_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline reference_type::operator bool() const noexcept {

View File

@@ -22,11 +22,11 @@ namespace meta_hpp::detail
namespace meta_hpp
{
inline void_type::void_type(detail::void_type_data_ptr data)
: data_{std::move(data)} {}
inline void_type::void_type(detail::void_type_data* data)
: data_{data} {}
inline bool void_type::is_valid() const noexcept {
return !!data_;
return data_ != nullptr;
}
inline void_type::operator bool() const noexcept {