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
}
相关推荐
郝学胜-神的一滴2 分钟前
Linux 读写锁深度解析:原理、应用与性能优化
linux·服务器·c++·程序人生·性能优化
闻缺陷则喜何志丹10 分钟前
【图论 DFS 换根法】3772. 子图的最大得分|2235
c++·算法·深度优先·力扣·图论·换根法
开开心心就好11 分钟前
音频格式互转工具,支持Mp3ApeWavFlac互转
java·网络·c++·windows·qt·电脑·excel
byxdaz9 小时前
C++内存序
c++
优雅的潮叭9 小时前
c++ 学习笔记之 malloc
c++·笔记·学习
苦藤新鸡12 小时前
8.最长的无重复字符的子串
c++·力扣
꧁Q༒ོγ꧂12 小时前
C++ 入门完全指南(四)--函数与模块化编程
开发语言·c++
汉克老师13 小时前
GESP2025年12月认证C++八级真题与解析(判断题8-10)
c++·快速排序··lcs·gesp八级·gesp8级
qq_4335545413 小时前
C++ manacher(求解回文串问题)
开发语言·c++·算法
HL_风神14 小时前
设计原则之迪米特
c++·学习·设计模式