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
}
相关推荐
Starmoon_dhw32 分钟前
题解:P17078 夏日甜点
c++·学习·算法·图论
某不知名網友35 分钟前
C/C++动态内存管理,智能指针及RAlI思想。
java·c语言·c++
hold?fish:palm1 小时前
从源码到可执行文件:C++程序的编译过程
开发语言·c++
lingran__2 小时前
C++_STL简介
开发语言·c++
南国韭菜2 小时前
【无标题】
c++·qt
没用的阿_吉3 小时前
vs2022offline 生成
c++
qq_416409133 小时前
专业的openclaw推荐
c++
一个小猴子`5 小时前
CUDA全局内存
c++·cuda编程
ysa0510305 小时前
【板子】树上启发式合并
数据结构·c++·笔记·算法
Simple_core5 小时前
cmake模板和问题总结
c++