c++ 变长模板
来源:互联网 发布:金蝶kis软件视频教程 编辑:程序博客网 时间:2024/06/13 01:58
void f(const T& t)
{
cout << t << endl;
}
template<typename T, typename... Arg>
void f(const T& t, const Arg&... arg)
{
cout << t << endl;
f(arg...);
}
int main()
{
f(10, 20, 30);
system("pause");
return 0;
}
//////////////////
void print_split(std::ostream&)
{
}
template<class T,class... Types>
void print_split(std::ostream& stream, T&& head, Types&&... rest)
{
stream << head << ' ';
print(stream, std::forward<Types>(rest)...);
}
template<class... Types>
void print(std::ostream& stream, Types&&...args)
{
print_split(stream, std::forward<Types>(args)...);
}
int main()
{
print(std::cout, 42, 'x', "hello", 3.14159, 0, '\n');
system("pause");
return 0;
}
////////////////////////////////////////////////////
template<long ...nums> struct Multiply;
template<long first, long ... last>
struct Multiply<first, last...>
{
static const long val = first * Multiply<last...>::val;
};
template<>
struct Multiply<>
{
static const long val = 1;
};
int main()
{
cout<< Multiply<1, 2, 3, 4, 5>::val << std::endl;
std::tuple<int, double, std::string> m = std::make_tuple(1, 22.2, "good");
system("pause");
return 0;
}
- C++变长参数模板
- c++ 变长模板
- 变长参数模板
- C变长参数
- C语言变长数组
- C变长参数
- C语言变长数组
- C/C++变长参数
- C变长参数
- c语言变长数组
- C 中的变长数组
- C语言变长数组
- C语言变长参数
- 变长数组 C
- c 变长数组
- C的变长参数
- C语言变长数组
- C语言变长参数
- UESTC 839——东风不与周郎便(线段树区间修改模板)
- Android手机拍照功能的实现
- Rhythmbox 支持 mp3
- 第七题 胡晓燕
- Zookeeper Client简介
- c++ 变长模板
- 控制器与导航笔记
- BZOJ 1136 POI2009 Arc 单调队列
- JavaScript的5种调用函数的方法
- Java高手真经_编程基础卷——读书笔记(9)——Java类修饰符
- 说说自己找互联网工作的经验
- ORACLE-基础四(数字字典,动态性能视图,控制文件)
- 计蒜客--第30题:合法分数的组合
- 宅急送项目的第七天笔记!(JBPM工作流)