mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 19:41:29 +07:00
add class_type::get_destructor method
This commit is contained in:
@@ -195,6 +195,8 @@ namespace meta_hpp
|
||||
[[nodiscard]] constructor get_constructor_with(std::span<const any_type> args) const noexcept;
|
||||
[[nodiscard]] constructor get_constructor_with(std::initializer_list<any_type> args) const noexcept;
|
||||
|
||||
[[nodiscard]] destructor get_destructor() const noexcept;
|
||||
|
||||
template < typename... Args >
|
||||
[[nodiscard]] function get_function_with(std::string_view name) const noexcept;
|
||||
template < typename Iter >
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace meta_hpp
|
||||
|
||||
template < typename Iter >
|
||||
constructor class_type::get_constructor_with(Iter first, Iter last) const noexcept {
|
||||
for ( auto&& [index, ctor] : data_->constructors ) {
|
||||
for ( auto&& [_, 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;
|
||||
@@ -291,6 +291,19 @@ namespace meta_hpp
|
||||
return get_constructor_with(args.begin(), args.end());
|
||||
}
|
||||
|
||||
//
|
||||
// get_destructor
|
||||
//
|
||||
|
||||
inline destructor class_type::get_destructor() const noexcept {
|
||||
if ( data_->destructors.empty() ) {
|
||||
return destructor{};
|
||||
}
|
||||
|
||||
auto&& [_, dtor] = *data_->destructors.begin();
|
||||
return dtor;
|
||||
}
|
||||
|
||||
//
|
||||
// get_function_with
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user