fork(2) download
  1. #include <functional>
  2. #include <cmath>
  3.  
  4. template<typename... T>
  5. struct pick
  6. {
  7. template<typename R, typename... U>
  8. static auto from(R(*ptr)(T..., U...))
  9. {
  10. return ptr;
  11. }
  12. };
  13.  
  14. int main()
  15. {
  16. std::function<double(double)>{pick<double>::from(&std::exp)};
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:60: error: no matching function for call to 'pick<double>::from(<unresolved overloaded function type>)'
  std::function<double(double)>{pick<double>::from(&std::exp)};
                                                            ^
prog.cpp:8:14: note: candidate: template<class R, class ... U> static auto pick<T>::from(R (*)(T ..., U ...)) [with R = R; U = {U ...}; T = {double}]
  static auto from(R(*ptr)(T..., U...))
              ^
prog.cpp:8:14: note:   template argument deduction/substitution failed:
prog.cpp:16:60: note:   mismatched types 'double' and 'long double'
  std::function<double(double)>{pick<double>::from(&std::exp)};
                                                            ^
prog.cpp:16:60: note:   mismatched types 'double' and 'float'
prog.cpp:16:60: note:   couldn't deduce template parameter 'R'
prog.cpp:16:61: error: no matching function for call to 'std::function<double(double)>::function(<brace-enclosed initializer list>)'
  std::function<double(double)>{pick<double>::from(&std::exp)};
                                                             ^
In file included from prog.cpp:1:0:
/usr/include/c++/5/functional:2058:2: note: candidate: template<class _Functor, class> std::function<_Res(_ArgTypes ...)>::function(_Functor)
  function(_Functor);
  ^
/usr/include/c++/5/functional:2058:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:2033:7: note: candidate: std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = double; _ArgTypes = {double}]
       function(function&& __x) : _Function_base()
       ^
/usr/include/c++/5/functional:2033:7: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/5/functional:2236:5: note: candidate: std::function<_Res(_ArgTypes ...)>::function(const std::function<_Res(_ArgTypes ...)>&) [with _Res = double; _ArgTypes = {double}]
     function<_Res(_ArgTypes...)>::
     ^
/usr/include/c++/5/functional:2236:5: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/5/functional:2013:7: note: candidate: std::function<_Res(_ArgTypes ...)>::function(std::nullptr_t) [with _Res = double; _ArgTypes = {double}; std::nullptr_t = std::nullptr_t]
       function(nullptr_t) noexcept
       ^
/usr/include/c++/5/functional:2013:7: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/5/functional:2006:7: note: candidate: std::function<_Res(_ArgTypes ...)>::function() [with _Res = double; _ArgTypes = {double}]
       function() noexcept
       ^
/usr/include/c++/5/functional:2006:7: note:   candidate expects 0 arguments, 1 provided
stdout
Standard output is empty