1 Star 0 Fork 115

mryu12 / CPlusPlusThings

forked from Yj / CPlusPlusThings 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tuple.cpp 730 Bytes
一键复制 编辑 原始数据 按行查看 历史
light-city 提交于 2020-03-03 09:34 . update
//
// Created by light on 19-11-4.
//
#include <iostream>
#include <tuple>
using namespace std;
// tuple使用
int main() {
tuple<int, int, string> t, t1, t2;
t = make_tuple(1, 2, "qwe");
t1 = make_tuple(3, 2, "qwe");
t2 = make_tuple(3, 2, "qwe");
int a = get<0>(t);
get<0>(t) = get<1>(t); // 可以修改
cout << a << endl;
cout << (get<0>(t) > get<1>(t) ? "true" : "false") << endl; // 比较大小
cout << (t1 == t2 ? "true" : "false") << endl;
typedef tuple<int, int, int, string> T;
cout << tuple_size<T>::value << endl; // meta programming 处理类型
cout << tuple_size<T>::value << endl;
tuple_element<1, T>::type a1 = 10;
cout << a1 << endl;
return 0;
}
C++
1
https://gitee.com/mryu12/CPlusPlusThings.git
git@gitee.com:mryu12/CPlusPlusThings.git
mryu12
CPlusPlusThings
CPlusPlusThings
master

搜索帮助