基于C++可变模板参数的Log,任意个参数
2017-12-27 20:59
931 查看
class Log
{
public:
Log();
~Log();
template <typename T>
static void i(const T& t) {
cout << t << endl;
}
template <typename T, typename ... Args>
static void i(const T& t, Args ... args) {
cout << t << " ";
i(args...);
}
};
int main() {
Log::i("hello", "world", 123, "yemao");
return 0;
}
{
public:
Log();
~Log();
template <typename T>
static void i(const T& t) {
cout << t << endl;
}
template <typename T, typename ... Args>
static void i(const T& t, Args ... args) {
cout << t << " ";
i(args...);
}
};
int main() {
Log::i("hello", "world", 123, "yemao");
return 0;
}
相关文章推荐
- [置顶] C++ 通用可变参数高级函数模板
- C++ 获取可变模板参数类型
- C++学习之可变参数的函数与模板
- C++ 11可变参数接口设计在模板编程中应用的一点点总结
- C++可变模板参数中&&和&的使用
- C++ Has Become More Pythonic ( tuple & 可变模板参数 )
- C++ 11 可变模板参数详解
- 利用可变模板参数实现log功能
- C++ 11 可变模板参数的两种展开方式
- c++模板实现多参数任意传 - 方法实现
- C++学习之可变参数的函数与模板
- C++学习之可变参数的函数与模板
- c++模板实现多参数任意传 - 类实现
- C++可变参数的函数与模板实例分析
- c++模板特性---------可变参数的使用
- C/C++宏定义的可变参数
- [zz]c++可变参数函数使用
- 【转】C/C++中可变参数的详细介绍(va_list,va_start,va_arg,va_end)
- 基于c++的函数模板
- 【C++基础之二十】可变参数的函数