mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 12:44:40 +03:00
see #2: move non-type template param auto to ch02
This commit is contained in:
18
code/2/2.14.default.template.param.cpp
Normal file
18
code/2/2.14.default.template.param.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 2.4.default.template.param.cpp
|
||||
// chapter 2 language usability
|
||||
// modern cpp tutorial
|
||||
//
|
||||
// created by changkun at changkun.de
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
template<typename T = int, typename U = int>
|
||||
auto add(T x, U y) -> decltype(x+y) {
|
||||
return x+y;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << add(1, 2) << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user