I have an input class that has a method that is supposed to take function as an argument.
#include "pixelGameEngine.h"
#include <functional>
class Input
{
public:
Input() = default;
Input(const Input&) = delete;
Input& operator=(const Input&) = delete;
public:
static void OnDPress(olc::PixelGameEngine* pge, std::function<void()> DoIteration) noexcept
{
if (pge->GetKey(olc::D).bPressed)
{
DoIteration();
}
}
};
And I have a triangle processor class that is supposed to call that function.
#include "pixelGameEngine.h"
#include "input.h"
#include <functional>
class TriangleProcessor
{
//...
void DoIteration() noexcept{};
Input input;
void Run(olc::PixelGameEngine* pge)
{
Input::OnDPress(pge, DoIteration);
}
}
But I am getting an error "no suitable constructor exists to convert from "void () to "std::function<void ()>"
on line Input::OnDPress(pge, DoIteration);
with a red squiggly under DoIteration
.