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