mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 22:17:02 +07:00
fix some misstypings
This commit is contained in:
@@ -200,7 +200,7 @@ namespace meta_hpp
|
||||
|
||||
template < typename... Args >
|
||||
function get_function_with(std::string_view name) const noexcept;
|
||||
function get_function_with(std::string_view name, std::vector<any_type> args) const noexcept;
|
||||
function get_function_with(std::string_view name, const std::vector<any_type>& args) const noexcept;
|
||||
function get_function_with(std::string_view name, std::initializer_list<any_type> args) const noexcept;
|
||||
private:
|
||||
detail::scope_state_ptr state_;
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace meta_hpp
|
||||
bool ctor::is_invocable_with(Args&&... args) const noexcept {
|
||||
using namespace detail;
|
||||
if constexpr ( sizeof...(Args) > 0 ) {
|
||||
std::array<arg, sizeof...(Args)> vargs{arg{std::forward<Args>(args)}...};
|
||||
std::array<arg_base, sizeof...(Args)> vargs{arg{std::forward<Args>(args)}...};
|
||||
return state_->is_invocable_with(vargs.data(), vargs.size());
|
||||
} else {
|
||||
return state_->is_invocable_with(nullptr, 0);
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace meta_hpp
|
||||
bool function::is_invocable_with(Args&&... args) const noexcept {
|
||||
using namespace detail;
|
||||
if constexpr ( sizeof...(Args) > 0 ) {
|
||||
std::array<arg, sizeof...(Args)> vargs{arg{std::forward<Args>(args)}...};
|
||||
std::array<arg_base, sizeof...(Args)> vargs{arg{std::forward<Args>(args)}...};
|
||||
return state_->is_invocable_with(vargs.data(), vargs.size());
|
||||
} else {
|
||||
return state_->is_invocable_with(nullptr, 0);
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace meta_hpp
|
||||
bool method::is_invocable_with(Instance&& instance, Args&&... args) const noexcept {
|
||||
using namespace detail;
|
||||
if constexpr ( sizeof...(Args) > 0 ) {
|
||||
std::array<arg, sizeof...(Args)> vargs{arg{std::forward<Args>(args)}...};
|
||||
std::array<arg_base, sizeof...(Args)> vargs{arg{std::forward<Args>(args)}...};
|
||||
return state_->is_invocable_with(inst{std::forward<Instance>(instance)}, vargs.data(), vargs.size());
|
||||
} else {
|
||||
return state_->is_invocable_with(inst{std::forward<Instance>(instance)}, nullptr, 0);
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace meta_hpp
|
||||
return get_function_with(name, {resolve_type<Args>()...});
|
||||
}
|
||||
|
||||
inline function scope::get_function_with(std::string_view name, std::vector<any_type> args) const noexcept {
|
||||
inline function scope::get_function_with(std::string_view name, const std::vector<any_type>& args) const noexcept {
|
||||
for ( auto&& [index, function] : state_->functions ) {
|
||||
if ( index.name != name ) {
|
||||
continue;
|
||||
|
||||
@@ -228,17 +228,17 @@ namespace meta_hpp
|
||||
|
||||
template < typename... Args >
|
||||
ctor get_ctor_with() const noexcept;
|
||||
ctor get_ctor_with(std::vector<any_type> args) const noexcept;
|
||||
ctor get_ctor_with(const std::vector<any_type>& args) const noexcept;
|
||||
ctor get_ctor_with(std::initializer_list<any_type> args) const noexcept;
|
||||
|
||||
template < typename... Args >
|
||||
function get_function_with(std::string_view name) const noexcept;
|
||||
function get_function_with(std::string_view name, std::vector<any_type> args) const noexcept;
|
||||
function get_function_with(std::string_view name, const std::vector<any_type>& args) const noexcept;
|
||||
function get_function_with(std::string_view name, std::initializer_list<any_type> args) const noexcept;
|
||||
|
||||
template < typename... Args >
|
||||
method get_method_with(std::string_view name) const noexcept;
|
||||
method get_method_with(std::string_view name, std::vector<any_type> args) const noexcept;
|
||||
method get_method_with(std::string_view name, const std::vector<any_type>& args) const noexcept;
|
||||
method get_method_with(std::string_view name, std::initializer_list<any_type> args) const noexcept;
|
||||
private:
|
||||
detail::class_type_data_ptr data_;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace meta_hpp
|
||||
template < typename... Args >
|
||||
std::optional<value> class_type::create(Args&&... args) const {
|
||||
for ( auto&& ctor : data_->ctors ) {
|
||||
if ( ctor.second.is_invocable_with<Args...>() ) {
|
||||
if ( ctor.second.is_invocable_with(std::forward<Args>(args)...) ) {
|
||||
return ctor.second.invoke(std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ namespace meta_hpp
|
||||
return get_ctor_with({resolve_type<Args>()...});
|
||||
}
|
||||
|
||||
inline ctor class_type::get_ctor_with(std::vector<any_type> args) const noexcept {
|
||||
inline ctor class_type::get_ctor_with(const std::vector<any_type>& args) const noexcept {
|
||||
for ( auto&& [index, ctor] : data_->ctors ) {
|
||||
if ( ctor.get_type().get_arity() != args.size() ) {
|
||||
continue;
|
||||
@@ -264,7 +264,7 @@ namespace meta_hpp
|
||||
return get_function_with(name, {resolve_type<Args>()...});
|
||||
}
|
||||
|
||||
inline function class_type::get_function_with(std::string_view name, std::vector<any_type> args) const noexcept {
|
||||
inline function class_type::get_function_with(std::string_view name, const std::vector<any_type>& args) const noexcept {
|
||||
for ( auto&& [index, function] : data_->functions ) {
|
||||
if ( index.name != name ) {
|
||||
continue;
|
||||
@@ -323,7 +323,7 @@ namespace meta_hpp
|
||||
return get_method_with(name, {resolve_type<Args>()...});
|
||||
}
|
||||
|
||||
inline method class_type::get_method_with(std::string_view name, std::vector<any_type> args) const noexcept {
|
||||
inline method class_type::get_method_with(std::string_view name, const std::vector<any_type>& args) const noexcept {
|
||||
for ( auto&& [index, method] : data_->methods ) {
|
||||
if ( index.name != name ) {
|
||||
continue;
|
||||
|
||||
@@ -86,14 +86,14 @@ namespace
|
||||
}\
|
||||
}
|
||||
|
||||
TEST_CASE("features/meta_utilities/arg2") {
|
||||
TEST_CASE("features/meta_utilities/arg") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
meta::class_<dclazz>()
|
||||
.base_<clazz>();
|
||||
}
|
||||
|
||||
TEST_CASE("features/meta_utilities/arg2/refs") {
|
||||
TEST_CASE("features/meta_utilities/arg/refs") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
{
|
||||
@@ -241,7 +241,7 @@ TEST_CASE("features/meta_utilities/arg2/refs") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("features/meta_utilities/arg2/ptrs") {
|
||||
TEST_CASE("features/meta_utilities/arg/ptrs") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
{
|
||||
@@ -625,7 +625,7 @@ TEST_CASE("features/meta_utilities/arg2/ptrs") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("features/meta_utilities/arg2/values") {
|
||||
TEST_CASE("features/meta_utilities/arg/values") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
{
|
||||
@@ -767,7 +767,7 @@ TEST_CASE("features/meta_utilities/arg2/values") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("features/meta_utilities/arg2/ptr_values") {
|
||||
TEST_CASE("features/meta_utilities/arg/ptr_values") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace
|
||||
|
||||
TEST_CASE("meta/meta_utilities/value") {
|
||||
namespace meta = meta_hpp;
|
||||
using namespace std::string_literals;
|
||||
|
||||
ivec2::move_ctor_counter = 0;
|
||||
ivec2::copy_ctor_counter = 0;
|
||||
@@ -197,16 +198,26 @@ TEST_CASE("meta/meta_utilities/value") {
|
||||
CHECK(val_src.data() != val_dst.data());
|
||||
}
|
||||
|
||||
SUBCASE("value& operator=(T&&)") {
|
||||
meta::value val{10};
|
||||
|
||||
val = 20;
|
||||
CHECK(val == 20);
|
||||
|
||||
val = "hello"s;
|
||||
CHECK(val == "hello"s);
|
||||
}
|
||||
|
||||
SUBCASE("value& operator=(value&&)") {
|
||||
meta::value val_src1{std::string("world")};
|
||||
meta::value val_src1{"world"s};
|
||||
meta::value val_src2{ivec2{1,2}};
|
||||
CHECK(ivec2::move_ctor_counter == 1);
|
||||
CHECK(ivec2::copy_ctor_counter == 0);
|
||||
|
||||
meta::value val_dst{std::string("hello")};
|
||||
meta::value val_dst{"hello"s};
|
||||
|
||||
val_dst = std::move(val_src1);
|
||||
CHECK(val_dst == std::string("world"));
|
||||
CHECK(val_dst == "world"s);
|
||||
CHECK(ivec2::move_ctor_counter == 1);
|
||||
CHECK(ivec2::copy_ctor_counter == 0);
|
||||
|
||||
@@ -220,15 +231,15 @@ TEST_CASE("meta/meta_utilities/value") {
|
||||
}
|
||||
|
||||
SUBCASE("value& operator=(const meta::value&)") {
|
||||
meta::value val_src1{std::string("world")};
|
||||
meta::value val_src1{"world"s};
|
||||
meta::value val_src2{ivec2{1,2}};
|
||||
CHECK(ivec2::move_ctor_counter == 1);
|
||||
CHECK(ivec2::copy_ctor_counter == 0);
|
||||
|
||||
meta::value val_dst{std::string("hello")};
|
||||
meta::value val_dst{"hello"s};
|
||||
|
||||
val_dst = val_src1;
|
||||
CHECK(val_dst == std::string("world"));
|
||||
CHECK(val_dst == "world"s);
|
||||
CHECK(ivec2::move_ctor_counter == 1);
|
||||
CHECK(ivec2::copy_ctor_counter == 0);
|
||||
|
||||
@@ -242,19 +253,19 @@ TEST_CASE("meta/meta_utilities/value") {
|
||||
}
|
||||
|
||||
SUBCASE("swap") {
|
||||
meta::value val1{std::string("world")};
|
||||
meta::value val1{"world"s};
|
||||
meta::value val2{ivec2{1,2}};
|
||||
CHECK(ivec2::move_ctor_counter == 1);
|
||||
CHECK(ivec2::copy_ctor_counter == 0);
|
||||
|
||||
val1.swap(val2);
|
||||
CHECK(val1 == ivec2{1,2});
|
||||
CHECK(val2 == std::string("world"));
|
||||
CHECK(val2 == "world"s);
|
||||
CHECK((ivec2::move_ctor_counter == 2 || ivec2::move_ctor_counter == 3));
|
||||
CHECK(ivec2::copy_ctor_counter == 0);
|
||||
|
||||
swap(val1, val2);
|
||||
CHECK(val1 == std::string("world"));
|
||||
CHECK(val1 == "world"s);
|
||||
CHECK(val2 == ivec2{1,2});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user