C++ std__get(std__tuple)

https://en.cppreference.com/w/cpp/utility/tuple/get
the type T in std::get must occur exactly once in the tuple.

cpp 复制代码
#include <iostream>
#include <string>
#include <tuple>

int main()
{
    auto t = std::make_tuple(1, "Foo", 3.14);
    // index-based access
    std::cout << "(" << std::get<0>(t) << ", " << std::get<1>(t)
        << ", " << std::get<2>(t) << ")\n";
    // type-based access (C++14 or later), the type T in std::get<T> must occur exactly once in the tuple
    std::cout << "(" << std::get<int>(t) << ", " << std::get<const char*>(t)
        << ", " << std::get<double>(t) << ")\n";
    // Note: std::tie and structured binding may also be used to decompose a tuple
}
相关推荐
不负岁月无痕11 分钟前
简单理解操作系统结构
java·linux·c语言·开发语言·c++·面试
余额瞒着我当琳31 分钟前
C++模板初阶与STL初探
android·java·c++
萧瑟其中~44 分钟前
多线程锁详解:互斥锁·自旋锁·读写锁(CAS + futex 原理)
开发语言·c++
yyy(十一月限定版)3 小时前
016【入门】双端队列
数据结构·c++
c238564 小时前
# Mini OJ — 项目详解文档
开发语言·数据库·c++
c238564 小时前
C/C++每日一练20
c语言·开发语言·c++
可爱系程序猿5 小时前
msvcp140_codecvt_ids.dll 缺失的排查记录:C++ 程序启动异常时如何核对运行库版本
开发语言·c++·程序人生·电脑
encoconut5 小时前
01_C++ 入门基础
c++
郝学胜-神的一滴6 小时前
中级OpenGL教程 030:gl_FragCoord解锁区域渲染与深度可视化新姿势
c++·unity·游戏引擎·图形渲染·unreal engine·opengl
不会代码的小猴7 小时前
11. 类和动态内存分配
开发语言·c++