fix new gcc warnings

This commit is contained in:
BlackMATov
2024-01-31 20:25:12 +07:00
parent 1621b8c1b3
commit d9db0b3bc0
10 changed files with 97 additions and 42 deletions

View File

@@ -204,6 +204,7 @@ namespace meta_hpp
[[nodiscard]] constructor_type get_type() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] argument get_argument(std::size_t position) const noexcept;
[[nodiscard]] const argument_list& get_arguments() const noexcept;
@@ -301,6 +302,7 @@ namespace meta_hpp
[[nodiscard]] function_type get_type() const noexcept;
[[nodiscard]] const std::string& get_name() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] argument get_argument(std::size_t position) const noexcept;
[[nodiscard]] const argument_list& get_arguments() const noexcept;
@@ -399,6 +401,7 @@ namespace meta_hpp
[[nodiscard]] method_type get_type() const noexcept;
[[nodiscard]] const std::string& get_name() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] argument get_argument(std::size_t position) const noexcept;
[[nodiscard]] const argument_list& get_arguments() const noexcept;

View File

@@ -170,6 +170,10 @@ namespace meta_hpp
return state_->index.get_type();
}
inline std::size_t constructor::get_arity() const noexcept {
return state_->arguments.size();
}
inline argument constructor::get_argument(std::size_t position) const noexcept {
return position < state_->arguments.size() ? state_->arguments[position] : argument{};
}

View File

@@ -144,6 +144,10 @@ namespace meta_hpp
return state_->index.get_name();
}
inline std::size_t function::get_arity() const noexcept {
return state_->arguments.size();
}
inline argument function::get_argument(std::size_t position) const noexcept {
return position < state_->arguments.size() ? state_->arguments[position] : argument{};
}

View File

@@ -156,6 +156,10 @@ namespace meta_hpp
return state_->index.get_name();
}
inline std::size_t method::get_arity() const noexcept {
return state_->arguments.size();
}
inline argument method::get_argument(std::size_t position) const noexcept {
return position < state_->arguments.size() ? state_->arguments[position] : argument{};
}

View File

@@ -93,8 +93,10 @@ namespace meta_hpp
continue;
}
const any_type_list& args = function.get_type().get_argument_types();
if ( std::equal(first, last, args.begin(), args.end()) ) {
const function_type& function_type = function.get_type();
const any_type_list& function_args = function_type.get_argument_types();
if ( std::equal(first, last, function_args.begin(), function_args.end()) ) {
return function;
}
}

View File

@@ -202,11 +202,11 @@ namespace meta_hpp
template < typename... Args >
uvalue class_type::create(Args&&... args) const {
for ( const constructor& ctor : data_->constructors ) {
if ( ctor.is_invocable_with(META_HPP_FWD(args)...) ) {
for ( const constructor& constructor : data_->constructors ) {
if ( constructor.is_invocable_with(META_HPP_FWD(args)...) ) {
// there is no 'use after move' here because
// 'is_invocable_with' doesn't actually move 'args'
return ctor.create(META_HPP_FWD(args)...);
return constructor.create(META_HPP_FWD(args)...);
}
}
return uvalue{};
@@ -214,11 +214,11 @@ namespace meta_hpp
template < typename... Args >
uvalue class_type::create_at(void* mem, Args&&... args) const {
for ( const constructor& ctor : data_->constructors ) {
if ( ctor.is_invocable_with(META_HPP_FWD(args)...) ) {
for ( const constructor& constructor : data_->constructors ) {
if ( constructor.is_invocable_with(META_HPP_FWD(args)...) ) {
// there is no 'use after move' here because
// 'is_invocable_with' doesn't actually move 'args'
return ctor.create_at(mem, META_HPP_FWD(args)...);
return constructor.create_at(mem, META_HPP_FWD(args)...);
}
}
return uvalue{};
@@ -226,11 +226,11 @@ namespace meta_hpp
template < typename Arg >
bool class_type::destroy(Arg&& arg) const {
if ( const destructor& dtor = get_destructor() ) {
if ( dtor.is_invocable_with(META_HPP_FWD(arg)) ) {
if ( const destructor& destructor = get_destructor() ) {
if ( destructor.is_invocable_with(META_HPP_FWD(arg)) ) {
// there is no 'use after move' here because
// 'is_invocable_with' doesn't actually move an 'arg'
dtor.destroy(META_HPP_FWD(arg));
destructor.destroy(META_HPP_FWD(arg));
return true;
}
}
@@ -238,8 +238,8 @@ namespace meta_hpp
}
inline bool class_type::destroy_at(void* mem) const {
if ( const destructor& dtor = get_destructor() ) {
dtor.destroy_at(mem);
if ( const destructor& destructor = get_destructor() ) {
destructor.destroy_at(mem);
return true;
}
return false;
@@ -401,10 +401,12 @@ namespace meta_hpp
template < typename Iter >
constructor class_type::get_constructor_with(Iter first, Iter last) const noexcept {
for ( const constructor& ctor : data_->constructors ) {
const any_type_list& args = ctor.get_type().get_argument_types();
if ( std::equal(first, last, args.begin(), args.end()) ) {
return ctor;
for ( const constructor& constructor : data_->constructors ) {
const constructor_type& constructor_type = constructor.get_type();
const any_type_list& constructor_args = constructor_type.get_argument_types();
if ( std::equal(first, last, constructor_args.begin(), constructor_args.end()) ) {
return constructor;
}
}
return constructor{};
@@ -454,8 +456,10 @@ namespace meta_hpp
continue;
}
const any_type_list& args = function.get_type().get_argument_types();
if ( std::equal(first, last, args.begin(), args.end()) ) {
const function_type& function_type = function.get_type();
const any_type_list& function_args = function_type.get_argument_types();
if ( std::equal(first, last, function_args.begin(), function_args.end()) ) {
return function;
}
}
@@ -512,8 +516,10 @@ namespace meta_hpp
continue;
}
const any_type_list& args = method.get_type().get_argument_types();
if ( std::equal(first, last, args.begin(), args.end()) ) {
const method_type& method_type = method.get_type();
const any_type_list& method_args = method_type.get_argument_types();
if ( std::equal(first, last, method_args.begin(), method_args.end()) ) {
return method;
}
}