Skip to content

Instantly share code, notes, and snippets.

@jia-kai
Last active August 29, 2015 14:05
Show Gist options
  • Save jia-kai/4705d3ab090cc79f1bb7 to your computer and use it in GitHub Desktop.
Save jia-kai/4705d3ab090cc79f1bb7 to your computer and use it in GitHub Desktop.
c++14 auto type deduction
#include <iostream>
auto second_f(auto a, auto b) {
return b;
}
int main() {
auto second_l = [](auto a, auto b) {return b;};
std::cout << second_f(0u, -1) << std::endl;
std::cout << second_l(0u, -1) << std::endl;
//std::cout << second_f("str", -1) << std::endl; // would not compile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment