#include <functional>
#include <cmath>
template<typename... T>
struct pick
{
template<typename R, typename... U>
static auto from(R(*ptr)(T..., U...))
{
return ptr;
}
};
int main()
{
std::function<double(double)>{pick<double>::from(&std::exp)};
}
I2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxjbWF0aD4KCnRlbXBsYXRlPHR5cGVuYW1lLi4uIFQ+CnN0cnVjdCBwaWNrCnsKCXRlbXBsYXRlPHR5cGVuYW1lIFIsIHR5cGVuYW1lLi4uIFU+CglzdGF0aWMgYXV0byBmcm9tKFIoKnB0cikoVC4uLiwgVS4uLikpCgl7CgkJcmV0dXJuIHB0cjsKCX0KfTsKCmludCBtYWluKCkKewoJc3RkOjpmdW5jdGlvbjxkb3VibGUoZG91YmxlKT57cGljazxkb3VibGU+Ojpmcm9tKCZzdGQ6OmV4cCl9Owp9
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