9-2. 가변 길이 템플릿(Variadic template)
가변 길이 템플릿(Variadic template)
#include <iostream>
template <typename T>
void print(T arg) {
std::cout << arg << std::endl;
}
template <typename T, typename... Types>
void print(T arg, Types... args) {
std::cout << arg << ", ";
print(args...);
}
int main() {
print(1, 3.1, "abc");
print(1, 2, 3, 4, 5, 6, 7);
}
파라미터 팩(parameter pack)
함수 정의 순서를 바꾼다면?

임의의 개수의 문자열을 합치는 함수
첫번째 시도

두번째 시도

sizeof...

Fold Expression
단항 Fold 형식

이항 Fold 형식

Fold 의 추가적인 기능

Last updated