title: error: could not convert ‘print’ from ‘void (*)(int)’ to ‘std::function<void()>’
body: <p>Following on from a <a href="https://stackoverflow.com/questions/46265136">previous question</a>, I was pointed to <a href="https://stackoverflow.com/questions/13545660">an answer</a>. The answer however involved a lambda function and I am trying to pass a normal function through.</p>
  
  <p>Using the below code as an example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  
  void forloop(std::function&lt;void()&gt; func, int arg) {
      func(arg);
  }
  
  
  void print(int number) {
      std::cout &lt;&lt; number &lt;&lt; std::endl;
  }
  
  
  int main() {
      int n = 5;
      forloop(print, n);
  }
  </code></pre>
  
  <p>The following error is returned in CLion.</p>
  
  <pre><code>/home/dave/JetBrains/CLion/bin/cmake/bin/cmake --build /home/dave/CLionProjects/csv/cmake-build-debug --target csv -- -j 2
  Scanning dependencies of target csv
  [ 50%] Building CXX object CMakeFiles/csv.dir/main.cpp.o
  /home/dave/CLionProjects/csv/main.cpp: In function ‘void forloop(std::function&lt;void()&gt;, int)’:
  /home/dave/CLionProjects/csv/main.cpp:5:13: error: no match for call to ‘(std::function&lt;void()&gt;) (int&amp;)’
       func(arg);
               ^
  In file included from /home/dave/CLionProjects/csv/main.cpp:2:0:
  /usr/include/c++/6/functional:2122:5: note: candidate: _Res std::function&lt;_Res(_ArgTypes ...)&gt;::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {}]
       function&lt;_Res(_ArgTypes...)&gt;::
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/include/c++/6/functional:2122:5: note:   candidate expects 0 arguments, 1 provided
  /home/dave/CLionProjects/csv/main.cpp: In function ‘int main()’:
  /home/dave/CLionProjects/csv/main.cpp:16:21: error: could not convert ‘print’ from ‘void (*)(int)’ to ‘std::function&lt;void()&gt;’
       forloop(print, n);
                       ^
  CMakeFiles/csv.dir/build.make:62: recipe for target 'CMakeFiles/csv.dir/main.cpp.o' failed
  make[3]: *** [CMakeFiles/csv.dir/main.cpp.o] Error 1
  CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/csv.dir/all' failed
  make[2]: *** [CMakeFiles/csv.dir/all] Error 2
  CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/csv.dir/rule' failed
  make[1]: *** [CMakeFiles/csv.dir/rule] Error 2
  Makefile:118: recipe for target 'csv' failed
  make: *** [csv] Error 2
  </code></pre>
  
  <p>Apologies if this questions seems silly - I am a C++ noob.</p>