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
}
相关推荐
重启的码农36 分钟前
llama.cpp 分布式推理介绍(2) 后端注册机制 (Backend Registration)
c++·人工智能·神经网络
重启的码农39 分钟前
llama.cpp 分布式推理介绍(1) 远程计算设备 (RPC Device)
c++·人工智能·神经网络
蜗牛沐雨1 小时前
C++ 类型转换
开发语言·c++
_poplar_2 小时前
08.5【C++ 初阶】实现一个相对完整的日期类--附带源码
c语言·开发语言·数据结构·c++·vscode·算法·vim
源远流长jerry2 小时前
STM32之MCU和GPIO
linux·c++·stm32·单片机·嵌入式硬件
汤永红3 小时前
week2-[一维数组]最大元素
数据结构·c++·算法·信睡奥赛
Minecraft红客6 小时前
C++小游戏荒芜的城堡
c++·游戏·娱乐
scx2013100412 小时前
20250814 最小生成树和重构树总结
c++·算法·最小生成树·重构树
weixin_3077791314 小时前
VS Code配置MinGW64编译SQLite3库
开发语言·数据库·c++·vscode·算法
励志不掉头发的内向程序员15 小时前
STL库——string(类函数学习)
开发语言·c++