1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #include <iostream>
#include <string>
#include <ctime>
void foo(int i){
std::cout<<"using an int as "<<i<<std::endl;
}
void foo(std::string const & i){
std::cout<<"using a string as "<<i<<std::endl;
}
void foo(tm const & i){
const char * temp=asctime(&i);
std::cout<<"using a time as"<< temp<<std::endl;
}
template <typename T, typename... Others>
void foo(T data, Others... rest){
foo(data);
foo(rest...);
}
int main(){
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
std::string hello("hello");
std::string world("world");
int i=0,j=2,k=3,l=4;
foo(hello,i,*timeinfo,j,world,k,l);
return 0;
} |
Partager