mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 11:40:35 +07:00
remove all std::bind usage
This commit is contained in:
@@ -78,7 +78,7 @@ namespace meta_hpp::detail
|
||||
struct vtable_t;
|
||||
vtable_t* vtable_{};
|
||||
private:
|
||||
using storage_t = std::aligned_storage_t<MaxFunctorSize, alignof(void*)>;
|
||||
using storage_t = std::aligned_storage_t<MaxFunctorSize>;
|
||||
storage_t storage_{};
|
||||
};
|
||||
|
||||
@@ -142,11 +142,10 @@ namespace meta_hpp::detail
|
||||
static void construct(fixed_function& dst, Functor&& functor) {
|
||||
using Fp = std::decay_t<Functor>;
|
||||
|
||||
static_assert(
|
||||
sizeof(Fp) <= MaxFunctorSize &&
|
||||
alignof(Fp) <= alignof(storage_t) &&
|
||||
std::is_invocable_r_v<R, Fp, Args...> &&
|
||||
std::is_nothrow_move_constructible_v<Fp>);
|
||||
static_assert(sizeof(Fp) <= MaxFunctorSize);
|
||||
static_assert(alignof(Fp) <= alignof(storage_t));
|
||||
static_assert(std::is_invocable_r_v<R, Fp, Args...>);
|
||||
static_assert(std::is_nothrow_move_constructible_v<Fp>);
|
||||
|
||||
::new (&dst.storage_) Fp(std::forward<Functor>(functor));
|
||||
dst.vtable_ = vtable_t::get<Fp>();
|
||||
|
||||
@@ -81,14 +81,12 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < ctor_policy_kind Policy, class_kind Class, typename... Args >
|
||||
ctor_state::invoke_impl make_ctor_invoke() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_ctor_invoke<Policy, Class, Args...>, _1);
|
||||
return &raw_ctor_invoke<Policy, Class, Args...>;
|
||||
}
|
||||
|
||||
template < class_kind Class, typename... Args >
|
||||
ctor_state::is_invocable_with_impl make_ctor_is_invocable_with() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_ctor_is_invocable_with<Class, Args...>, _1);
|
||||
return &raw_ctor_is_invocable_with<Class, Args...>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,12 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < class_kind Class >
|
||||
dtor_state::invoke_impl make_dtor_invoke() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_dtor_invoke<Class>, _1);
|
||||
return &raw_dtor_invoke<Class>;
|
||||
}
|
||||
|
||||
template < class_kind Class >
|
||||
dtor_state::is_invocable_with_impl make_dtor_is_invocable_with() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_dtor_is_invocable_with<Class>, _1);
|
||||
return &raw_dtor_is_invocable_with<Class>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,14 +85,14 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < function_policy_kind Policy, function_kind Function >
|
||||
function_state::invoke_impl make_function_invoke(Function function) {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_function_invoke<Policy, Function>, std::move(function), _1);
|
||||
return [function = std::move(function)](std::span<const arg> args){
|
||||
return raw_function_invoke<Policy>(function, args);
|
||||
};
|
||||
}
|
||||
|
||||
template < function_kind Function >
|
||||
function_state::is_invocable_with_impl make_function_is_invocable_with() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_function_is_invocable_with<Function>, _1);
|
||||
return &raw_function_is_invocable_with<Function>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,26 +121,26 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < member_policy_kind Policy, member_kind Member >
|
||||
member_state::getter_impl make_member_getter(Member member) {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_member_getter<Policy, Member>, std::move(member), _1);
|
||||
return [member = std::move(member)](const inst& inst){
|
||||
return raw_member_getter<Policy>(member, inst);
|
||||
};
|
||||
}
|
||||
|
||||
template < member_kind Member >
|
||||
member_state::is_gettable_with_impl make_member_is_gettable_with() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_member_is_gettable_with<Member>, _1);
|
||||
return &raw_member_is_gettable_with<Member>;
|
||||
}
|
||||
|
||||
template < member_kind Member >
|
||||
member_state::setter_impl make_member_setter(Member member) {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_member_setter<Member>, std::move(member), _1, _2);
|
||||
return [member = std::move(member)](const inst& inst, const arg& arg){
|
||||
return raw_member_setter(member, inst, arg);
|
||||
};
|
||||
}
|
||||
|
||||
template < member_kind Member >
|
||||
member_state::is_settable_with_impl make_member_is_settable_with() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_member_is_settable_with<Member>, _1, _2);
|
||||
return &raw_member_is_settable_with<Member>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,14 +98,14 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < method_policy_kind Policy, method_kind Method >
|
||||
method_state::invoke_impl make_method_invoke(Method method) {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_method_invoke<Policy, Method>, std::move(method), _1, _2);
|
||||
return [method = std::move(method)](const inst& inst, std::span<const arg> args){
|
||||
return raw_method_invoke<Policy>(method, inst, args);
|
||||
};
|
||||
}
|
||||
|
||||
template < method_kind Method >
|
||||
method_state::is_invocable_with_impl make_method_is_invocable_with() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_method_is_invocable_with<Method>, _1, _2);
|
||||
return &raw_method_is_invocable_with<Method>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,20 +75,21 @@ namespace meta_hpp::detail
|
||||
{
|
||||
template < variable_policy_kind Policy, pointer_kind Pointer >
|
||||
variable_state::getter_impl make_variable_getter(Pointer pointer) {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_variable_getter<Policy, Pointer>, std::move(pointer));
|
||||
return [pointer = std::move(pointer)](){
|
||||
return raw_variable_getter<Policy>(pointer);
|
||||
};
|
||||
}
|
||||
|
||||
template < pointer_kind Pointer >
|
||||
variable_state::setter_impl make_variable_setter(Pointer pointer) {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_variable_setter<Pointer>, std::move(pointer), _1);
|
||||
return [pointer = std::move(pointer)](const arg& arg){
|
||||
return raw_variable_setter(pointer, arg);
|
||||
};
|
||||
}
|
||||
|
||||
template < pointer_kind Pointer >
|
||||
variable_state::is_settable_with_impl make_variable_is_settable_with() {
|
||||
using namespace std::placeholders;
|
||||
return std::bind(&raw_variable_is_settable_with<Pointer>, _1);
|
||||
return &raw_variable_is_settable_with<Pointer>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace meta_hpp
|
||||
struct vtable_t;
|
||||
vtable_t* vtable_{};
|
||||
private:
|
||||
using buffer_t = std::aligned_storage_t<sizeof(void*) * 2, alignof(void*)>;
|
||||
using buffer_t = std::aligned_storage_t<sizeof(void*) * 2>;
|
||||
using storage_u = std::variant<std::monostate, void*, buffer_t>;
|
||||
storage_u storage_{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user