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
}
相关推荐
wangjialelele2 分钟前
Linux SystemV 消息队列 + 责任链模式:实现客户端消息处理流水线
linux·服务器·c语言·网络·c++·责任链模式
智者知已应修善业28 分钟前
51单片机4按键控制共阳LED霓虹灯切换1整体闪烁2流水下3流水上4间隔闪烁】2023-10-27
c++·经验分享·笔记·算法·51单片机
洛水水33 分钟前
结构性设计模式详解
c++·设计模式
曦夜日长1 小时前
C++ STL容器string(二):删除与插入、数据查找、自定义输入
java·开发语言·c++
fpcc2 小时前
跟我学C++中级篇—虚函数的优化
c++
智者知已应修善业2 小时前
【51单片机独立按键控制数码管自增自减】2023-10-5
c++·经验分享·笔记·算法·51单片机
ComputerInBook2 小时前
C++中“概念”(concept)之含义
开发语言·c++·概念·concept
程序员老舅2 小时前
Linux:谁把根目录卸载了?
linux·c++·容器·linux内核·文件系统·根目录
石山代码2 小时前
c++类型判断
开发语言·c++
雪度娃娃2 小时前
结构型设计模式——代理模式
java·c++·设计模式·系统安全·代理模式