requires instead static_assert for registry binds

This commit is contained in:
BlackMATov
2022-01-03 15:20:08 +07:00
parent ab1f78124e
commit ee518b4da2
5 changed files with 47 additions and 17 deletions

18
.clang-tidy Normal file
View File

@@ -0,0 +1,18 @@
Checks: '-*,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
modernize-*,
-modernize-use-trailing-return-type,
performance-*,
portability-*,
readability-*,
-readability-use-anyofallof,
'

View File

@@ -29,8 +29,10 @@ target_compile_options(${PROJECT_NAME}
-Wno-c++98-compat-pedantic -Wno-c++98-compat-pedantic
-Wno-ctad-maybe-unsupported -Wno-ctad-maybe-unsupported
-Wno-exit-time-destructors -Wno-exit-time-destructors
-Wno-extra-semi-stmt
-Wno-float-equal -Wno-float-equal
-Wno-padded -Wno-padded
-Wno-reserved-identifier
-Wno-shadow-field -Wno-shadow-field
-Wno-shadow-field-in-constructor -Wno-shadow-field-in-constructor
-Wno-unknown-warning-option -Wno-unknown-warning-option

View File

@@ -18,19 +18,23 @@ namespace meta_hpp
operator class_type() const noexcept; operator class_type() const noexcept;
template < typename... Args > template < typename... Args >
class_bind& ctor_(); class_bind& ctor_()
requires std::is_constructible_v<Class, Args...>;
template < detail::class_kind Base > template < detail::class_kind Base >
class_bind& base_(); class_bind& base_()
requires std::is_base_of_v<Base, Class>;
template < detail::function_kind Function > template < detail::function_kind Function >
class_bind& function_(std::string name, Function function); class_bind& function_(std::string name, Function function);
template < detail::member_kind Member > template < detail::member_kind Member >
class_bind& member_(std::string name, Member member); class_bind& member_(std::string name, Member member)
requires std::same_as<Class, typename detail::member_traits<Member>::class_type>;
template < detail::method_kind Method > template < detail::method_kind Method >
class_bind& method_(std::string name, Method method); class_bind& method_(std::string name, Method method)
requires std::same_as<Class, typename detail::method_traits<Method>::class_type>;
template < detail::pointer_kind Pointer > template < detail::pointer_kind Pointer >
class_bind& variable_(std::string name, Pointer pointer); class_bind& variable_(std::string name, Pointer pointer);
@@ -60,7 +64,7 @@ namespace meta_hpp
struct local_tag {}; struct local_tag {};
struct static_tag {}; struct static_tag {};
explicit scope_bind(std::string_view name, local_tag); explicit scope_bind(std::string name, local_tag);
explicit scope_bind(std::string_view name, static_tag); explicit scope_bind(std::string_view name, static_tag);
operator scope() const noexcept; operator scope() const noexcept;
@@ -96,7 +100,7 @@ namespace meta_hpp
return scope_bind{std::move(name), scope_bind::local_tag()}; return scope_bind{std::move(name), scope_bind::local_tag()};
} }
inline scope_bind static_scope_(std::string name) { inline scope_bind static_scope_(std::string_view name) {
return scope_bind{std::move(name), scope_bind::static_tag()}; return scope_bind{name, scope_bind::static_tag()};
} }
} }

View File

@@ -22,8 +22,9 @@ namespace meta_hpp
template < detail::class_kind Class > template < detail::class_kind Class >
template < typename... Args > template < typename... Args >
class_bind<Class>& class_bind<Class>::ctor_() { class_bind<Class>& class_bind<Class>::ctor_()
static_assert(std::is_constructible_v<Class, Args...>); requires std::is_constructible_v<Class, Args...>
{
auto ctor_state = detail::ctor_state::make<Class, Args...>(); auto ctor_state = detail::ctor_state::make<Class, Args...>();
data_->ctors.emplace(ctor_state->index, std::move(ctor_state)); data_->ctors.emplace(ctor_state->index, std::move(ctor_state));
return *this; return *this;
@@ -31,8 +32,9 @@ namespace meta_hpp
template < detail::class_kind Class > template < detail::class_kind Class >
template < detail::class_kind Base > template < detail::class_kind Base >
class_bind<Class>& class_bind<Class>::base_() { class_bind<Class>& class_bind<Class>::base_()
static_assert(std::is_base_of_v<Base, Class>); requires std::is_base_of_v<Base, Class>
{
data_->bases.emplace(resolve_type<Base>()); data_->bases.emplace(resolve_type<Base>());
return *this; return *this;
} }
@@ -47,8 +49,9 @@ namespace meta_hpp
template < detail::class_kind Class > template < detail::class_kind Class >
template < detail::member_kind Member > template < detail::member_kind Member >
class_bind<Class>& class_bind<Class>::member_(std::string name, Member member) { class_bind<Class>& class_bind<Class>::member_(std::string name, Member member)
static_assert(std::same_as<Class, typename detail::member_traits<Member>::class_type>); requires std::same_as<Class, typename detail::member_traits<Member>::class_type>
{
auto member_state = detail::member_state::make<Member>(std::move(name), std::move(member)); auto member_state = detail::member_state::make<Member>(std::move(name), std::move(member));
data_->members.emplace(member_state->index, std::move(member_state)); data_->members.emplace(member_state->index, std::move(member_state));
return *this; return *this;
@@ -56,8 +59,9 @@ namespace meta_hpp
template < detail::class_kind Class > template < detail::class_kind Class >
template < detail::method_kind Method > template < detail::method_kind Method >
class_bind<Class>& class_bind<Class>::method_(std::string name, Method method) { class_bind<Class>& class_bind<Class>::method_(std::string name, Method method)
static_assert(std::same_as<Class, typename detail::method_traits<Method>::class_type>); requires std::same_as<Class, typename detail::method_traits<Method>::class_type>
{
auto method_state = detail::method_state::make<Method>(std::move(name), std::move(method)); auto method_state = detail::method_state::make<Method>(std::move(name), std::move(method));
data_->methods.emplace(method_state->index, std::move(method_state)); data_->methods.emplace(method_state->index, std::move(method_state));
return *this; return *this;

View File

@@ -11,9 +11,11 @@
namespace meta_hpp namespace meta_hpp
{ {
inline scope_bind::scope_bind(std::string_view name, local_tag) // NOLINTNEXTLINE(readability-named-parameter)
: state_{detail::scope_state::make(std::string{name})} {} inline scope_bind::scope_bind(std::string name, local_tag)
: state_{detail::scope_state::make(std::move(name))} {}
// NOLINTNEXTLINE(readability-named-parameter)
inline scope_bind::scope_bind(std::string_view name, static_tag) inline scope_bind::scope_bind(std::string_view name, static_tag)
: state_{detail::scope_state::get_static(name)} {} : state_{detail::scope_state::get_static(name)} {}