#includeusing namespace std; void printX(){ } template void printX(const T& f1 , const args&... f2){ cout << f1 << endl; printX(f2...); } int main(){ printX(22 , "hello" , 23 , 24 , 25); return 0; } // 如果想知道传进来的这一包东西有几个, 可以使用sizeof...(args);
例二: 重写printf
void PrintX(const char* p){
while(*p){
if(*p == '%' && *(++p) != '%'){
}
cout << *p++;
}
}
template
void PrintX(const char* p , T type , Args... arg){
while(*p){
if(*p == '%' && *(++p) != '%'){
cout << type << ' ' ;
PrintX(++p , arg...);
return;
}
}
}
int main(){
PrintX("%d%d%d" , 23 , 24 , 25);
return 0;
}
第六种: 可以利用这种形式,到底要把哪几种类型组合成一包。这种做法非常的精简巧妙。 但是这么用会报错,直接写出它的类型即可。
Rvalues references可以用decltype类型推导
右值是不可以出现在左边的,而什么是右值呢,最常见的就是临时对象。
这是一个不完美的转接。
hashtable如何设计一个具备移动语义意识的classs:
hash function
Tuple



