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
Composite pattern
template specialization inheritance solution
Program to Time Difference
PrintAddress
Check if a year is leap year or not
Reference example
Store Information in Structure and Display it
non-template template parameters for container stream insertion: SFINAE
Test size_t
Throttle Example (Send two requests every two seconds)