fork download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. template<typename out_t, typename in_t>
  5. struct my_type{
  6. using F = std::function<out_t(in_t)>;
  7. F m_f;
  8. my_type(F f) : m_f(f) {}
  9. };
  10.  
  11. class C{
  12. public:
  13. my_type<double,double> m_func_taker;
  14.  
  15. double func(double in) {
  16. return 2*in;
  17. }
  18.  
  19. C() : m_func_taker(std::function<double(double)>(func) ) {}
  20.  
  21.  
  22. };
  23.  
  24.  
  25. int main() {
  26. // your code goes here
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 4504KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘C::C()’:
prog.cpp:19:55: error: invalid use of non-static member function ‘double C::func(double)’
  C() : m_func_taker(std::function<double(double)>(func) ) {}
                                                       ^
prog.cpp:15:9: note: declared here
  double func(double in) {
         ^~~~
stdout
Standard output is empty