mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 12:44:40 +03:00
revision #1: 更新第二章中已维护的代码
This commit is contained in:
21
code/2/todo/2.xxx.cpp
Normal file
21
code/2/todo/2.xxx.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
template<typename T0>
|
||||
void printf(T0 value) {
|
||||
std::cout << value << std::endl;
|
||||
}
|
||||
template<typename T, typename... Args>
|
||||
void printf(T value, Args... args) {
|
||||
std::cout << value << std::endl;
|
||||
printf(args...);
|
||||
}
|
||||
|
||||
template<typename T0, typename... T>
|
||||
void printf_short(T0 t0, T... t) {
|
||||
std::cout << t0 << std::endl;
|
||||
if constexpr (sizeof...(t) > 0) printf(t...);
|
||||
}
|
||||
int main() {
|
||||
printf_short(1, 2, "123", 1.1);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user