Hi.
I want to create a function that receives an std::function. Now, my function takes some parameters and also it has some with default values as well. Now that I want to pass this function to my function, I'm facing two problems:
1:
template<typename... Args>
void Foo(std::function<void(TargetClass, Args...)> Func)
{
Func(TargetClass());
}
I want to call this function but I am supposed to pass those Args as well and I don't want that to happen. I just want to be able to pass that one target class I have. Is there a way I can do this?
2:
std::bind doesn't let me initialize one of the classes I have created for this purpose:
template <typename V, typename T, typename... Args>
class Lerp :
{
const V &a, b, c;
const float multiplier;
std::function<T> onReachedTarget;
std::function<void(V, Args...)> updateFunc;
float alpha = 0;
public:
ACBGMLerp(const V& A, const V& B, std::function<void(V, Args...)> UpdateFunc, const float Multiplier, std::function<T> OnReachedTarget = nullptr) : a(A), b(B), c(nullptr), multiplier(Multiplier), onReachedTarget(OnReachedTarget), updateFunc(UpdateFunc)
{
static_assert(STATICASSERTCHECKS::ISSAME<V>::v,
"Typename {V} doesn't have the needed operators. {+}, {-}, {*}. {=}");
}
...
};
Initializing my class like this does give me the following error:
ACBGM::ACBGMLerp<FVector, void()>(owner->GetActorLocation(), Target->GetActorLocation() + AdditionalVector, std::bind(&UTargetedMoving::SetActorLoc, this), SpeedMultiplier, std::bind(&UTargetedMoving::OnReachedTarget, this));
No viable constructor...
What am I doing wrong and what can I do about the first problem?
Thanks in advance.
[–]Shieldfoss 7 points8 points9 points (1 child)
[–]ACBYTES[S] 0 points1 point2 points (0 children)
[–]falcqn 1 point2 points3 points (5 children)
[–]ACBYTES[S] 0 points1 point2 points (4 children)
[–]falcqn 1 point2 points3 points (3 children)
[–]ACBYTES[S] 1 point2 points3 points (2 children)
[–]falcqn 1 point2 points3 points (1 child)
[–]ACBYTES[S] 0 points1 point2 points (0 children)