fork download
  1. #include <functional>
  2. #include <vector>
  3.  
  4. using namespace std;
  5. struct MultiMemoizator {
  6. template <typename ReturnType, typename... Args>
  7. ReturnType callFunction(std::function<ReturnType(Args...)> memFunc, Args&&... args) {
  8.  
  9. }
  10. };
  11.  
  12. typedef vector<double> vecD;
  13.  
  14. vecD sort_vec (vecD const& vec) {
  15. return vec;
  16. }
  17.  
  18. int main()
  19. {
  20. vecD vec;
  21. std::function<vecD(vecD)> sortFunc(sort_vec);
  22. MultiMemoizator mem;
  23. mem.callFunction<vecD, vecD>(sortFunc, vec);
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:23:47: error: no matching function for call to 'MultiMemoizator::callFunction(std::function<std::vector<double>(std::vector<double>)>&, vecD&)'
     mem.callFunction<vecD, vecD>(sortFunc, vec);
                                               ^
prog.cpp:7:16: note: candidate: template<class ReturnType, class ... Args> ReturnType MultiMemoizator::callFunction(std::function<_Res(_ArgTypes ...)>, Args&& ...)
     ReturnType callFunction(std::function<ReturnType(Args...)> memFunc, Args&&... args) {
                ^
prog.cpp:7:16: note:   template argument deduction/substitution failed:
prog.cpp:23:47: note:   cannot convert 'vec' (type 'vecD {aka std::vector<double>}') to type 'std::vector<double>&&'
     mem.callFunction<vecD, vecD>(sortFunc, vec);
                                               ^
stdout
Standard output is empty