mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 14:09:02 +07:00
class_type create function
This commit is contained in:
@@ -201,6 +201,12 @@ namespace meta_hpp
|
|||||||
const method_map& get_methods() const noexcept;
|
const method_map& get_methods() const noexcept;
|
||||||
const variable_map& get_variables() const noexcept;
|
const variable_map& get_variables() const noexcept;
|
||||||
|
|
||||||
|
template < typename... Args >
|
||||||
|
std::optional<value> create(Args&&... args) const;
|
||||||
|
|
||||||
|
template < typename... Args >
|
||||||
|
std::optional<value> operator()(Args&&... args) const;
|
||||||
|
|
||||||
template < detail::class_kind Derived >
|
template < detail::class_kind Derived >
|
||||||
bool is_base_of() const noexcept;
|
bool is_base_of() const noexcept;
|
||||||
bool is_base_of(const class_type& derived) const noexcept;
|
bool is_base_of(const class_type& derived) const noexcept;
|
||||||
|
|||||||
@@ -91,6 +91,21 @@ namespace meta_hpp
|
|||||||
return data_->variables;
|
return data_->variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename... Args >
|
||||||
|
std::optional<value> class_type::create(Args&&... args) const {
|
||||||
|
for ( auto&& ctor : data_->ctors ) {
|
||||||
|
if ( ctor.second.is_invocable_with<Args...>() ) {
|
||||||
|
return ctor.second.invoke(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename... Args >
|
||||||
|
std::optional<value> class_type::operator()(Args&&... args) const {
|
||||||
|
return create(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
template < detail::class_kind Derived >
|
template < detail::class_kind Derived >
|
||||||
bool class_type::is_base_of() const noexcept {
|
bool class_type::is_base_of() const noexcept {
|
||||||
return is_base_of(resolve_type<Derived>());
|
return is_base_of(resolve_type<Derived>());
|
||||||
|
|||||||
Reference in New Issue
Block a user