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
}
相关推荐
澈20717 小时前
深入浅出C++滑动窗口算法:原理、实现与实战应用详解
数据结构·c++·算法
A.A呐17 小时前
【C++第二十九章】IO流
开发语言·c++
ambition2024218 小时前
从暴力搜索到理论最优:一道任务调度问题的完整算法演进历程
c语言·数据结构·c++·算法·贪心算法·深度优先
kebeiovo18 小时前
atomic原子操作实现无锁队列
服务器·c++
Yungoal18 小时前
常见 时间复杂度计算
c++·算法
6Hzlia18 小时前
【Hot 100 刷题计划】 LeetCode 48. 旋转图像 | C++ 矩阵变换题解
c++·leetcode·矩阵
Ricky_Theseus19 小时前
C++右值引用
java·开发语言·c++
吴梓穆20 小时前
UE5 c++ 常用方法
java·c++·ue5
云栖梦泽20 小时前
Linux内核与驱动:9.Linux 驱动 API 封装
linux·c++
Morwit20 小时前
【力扣hot100】 1. 两数之和
数据结构·c++·算法·leetcode·职场和发展