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
}
相关推荐
码客-ygluu8 小时前
X3 LUA 异步分布式微服务集群框架
c++·架构·lua
九英里路10 小时前
protobuf快速上手
网络·c++·中间件·json·谷歌·序列化·protobuf
纪念 22911 小时前
C++ 算法基础 (差分)
开发语言·c++·算法
ShineWinsu16 小时前
对于Qt:QTreeWidget常见属性以及QTreeWidgetItem类的解析
开发语言·c++·qt·gui·客户端·多叉树·qtreewidget
落羽的落羽16 小时前
【C++】C++17的主要特性
linux·服务器·开发语言·c++·算法·机器学习
汉克老师1 天前
《从C++小白到算法高手:GESP 1—8级成长地图》第一讲:认识GESP——从编程新手到算法探索者
c++·gesp·信息学竞赛·小学生学c++
晴天的雨.9921 天前
【C++】继承篇
java·开发语言·c++
青少儿编程课堂1 天前
蓝桥杯青少组图形化 + 全国青少年信息素养大赛 + 电子学会图形化考级:校园大富翁经营闯关解析
c++·python·算法·bfs·信息学竞赛
another heaven1 天前
【C/C++ 第一次跨越(上):用 C++11/14 停止制造新的旧代码】
c语言·c++·制造
qq_406981031 天前
c++ lamda(三)Lambda表达式
java·前端·c++