Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
non-deduced context
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> #include <functional> template<class T, class U> int adapter1(T t, U u, int (*f)(T, U)) { return f(t, u); } template<class T, class U> int adapter2(T t, U u, std::function<int(T,U)> f) { return f(t, u); } template<class T> using func = typename std::common_type<T>::type; template<class T, class U> int adapter3(T t, U u, func<int(T,U)> f) { return f(t, u); } int main() { auto l = [](int t, double u)->int{ return t + u; }; int t = 9; double u = 8.9; std::cout << adapter1(t, u, +l); // ok except visual studio //std::cout << adapter2(t, u, l); // fails everywhere std::cout << adapter3(t, u, l); // ok everywhere }
run
|
edit
|
history
|
help
0
Sum of Natural Numbers using loop
Math1
nontype template parameter produced with decltype for function
auto Keyword Example
even number
overloading
Tree Traversal and Node
illegal instruction (SIGILL)
Rounding float to nearest 1000
34534