diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..e0619a2 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,18 @@ +Checks: '-*, + + clang-analyzer-*, + + concurrency-*, + + cppcoreguidelines-*, + + modernize-*, + -modernize-use-trailing-return-type, + + performance-*, + + portability-*, + + readability-*, + -readability-use-anyofallof, + ' diff --git a/CMakeLists.txt b/CMakeLists.txt index d4d87f3..9cf65da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,8 +29,10 @@ target_compile_options(${PROJECT_NAME} -Wno-c++98-compat-pedantic -Wno-ctad-maybe-unsupported -Wno-exit-time-destructors + -Wno-extra-semi-stmt -Wno-float-equal -Wno-padded + -Wno-reserved-identifier -Wno-shadow-field -Wno-shadow-field-in-constructor -Wno-unknown-warning-option diff --git a/headers/meta.hpp/meta_registry.hpp b/headers/meta.hpp/meta_registry.hpp index d09fcf2..fbc89c9 100644 --- a/headers/meta.hpp/meta_registry.hpp +++ b/headers/meta.hpp/meta_registry.hpp @@ -18,19 +18,23 @@ namespace meta_hpp operator class_type() const noexcept; template < typename... Args > - class_bind& ctor_(); + class_bind& ctor_() + requires std::is_constructible_v; template < detail::class_kind Base > - class_bind& base_(); + class_bind& base_() + requires std::is_base_of_v; template < detail::function_kind Function > class_bind& function_(std::string name, Function function); 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_type>; 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_type>; template < detail::pointer_kind Pointer > class_bind& variable_(std::string name, Pointer pointer); @@ -60,7 +64,7 @@ namespace meta_hpp struct local_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); operator scope() const noexcept; @@ -96,7 +100,7 @@ namespace meta_hpp return scope_bind{std::move(name), scope_bind::local_tag()}; } - inline scope_bind static_scope_(std::string name) { - return scope_bind{std::move(name), scope_bind::static_tag()}; + inline scope_bind static_scope_(std::string_view name) { + return scope_bind{name, scope_bind::static_tag()}; } } diff --git a/headers/meta.hpp/meta_registry/class_bind.hpp b/headers/meta.hpp/meta_registry/class_bind.hpp index 952562f..6682cc5 100644 --- a/headers/meta.hpp/meta_registry/class_bind.hpp +++ b/headers/meta.hpp/meta_registry/class_bind.hpp @@ -22,8 +22,9 @@ namespace meta_hpp template < detail::class_kind Class > template < typename... Args > - class_bind& class_bind::ctor_() { - static_assert(std::is_constructible_v); + class_bind& class_bind::ctor_() + requires std::is_constructible_v + { auto ctor_state = detail::ctor_state::make(); data_->ctors.emplace(ctor_state->index, std::move(ctor_state)); return *this; @@ -31,8 +32,9 @@ namespace meta_hpp template < detail::class_kind Class > template < detail::class_kind Base > - class_bind& class_bind::base_() { - static_assert(std::is_base_of_v); + class_bind& class_bind::base_() + requires std::is_base_of_v + { data_->bases.emplace(resolve_type()); return *this; } @@ -47,8 +49,9 @@ namespace meta_hpp template < detail::class_kind Class > template < detail::member_kind Member > - class_bind& class_bind::member_(std::string name, Member member) { - static_assert(std::same_as::class_type>); + class_bind& class_bind::member_(std::string name, Member member) + requires std::same_as::class_type> + { auto member_state = detail::member_state::make(std::move(name), std::move(member)); data_->members.emplace(member_state->index, std::move(member_state)); return *this; @@ -56,8 +59,9 @@ namespace meta_hpp template < detail::class_kind Class > template < detail::method_kind Method > - class_bind& class_bind::method_(std::string name, Method method) { - static_assert(std::same_as::class_type>); + class_bind& class_bind::method_(std::string name, Method method) + requires std::same_as::class_type> + { auto method_state = detail::method_state::make(std::move(name), std::move(method)); data_->methods.emplace(method_state->index, std::move(method_state)); return *this; diff --git a/headers/meta.hpp/meta_registry/scope_bind.hpp b/headers/meta.hpp/meta_registry/scope_bind.hpp index 32cfe84..453a19a 100644 --- a/headers/meta.hpp/meta_registry/scope_bind.hpp +++ b/headers/meta.hpp/meta_registry/scope_bind.hpp @@ -11,9 +11,11 @@ namespace meta_hpp { - inline scope_bind::scope_bind(std::string_view name, local_tag) - : state_{detail::scope_state::make(std::string{name})} {} + // NOLINTNEXTLINE(readability-named-parameter) + 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) : state_{detail::scope_state::get_static(name)} {}