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
}
相关推荐
鹅毛在路上了1 小时前
C++, ffmpeg, libavcodec-RTSP拉流,opencv实时预览
c++·opencv·ffmpeg
John_ToDebug1 小时前
定制 ResourceBundle 的实现与 DuiLib 思想在 Chromium 架构下的应用解析
c++·chrome·ui
小欣加油2 小时前
leetcode 面试题01.02判定是否互为字符重排
数据结构·c++·算法·leetcode·职场和发展
王璐WL3 小时前
【c++】c++第一课:命名空间
数据结构·c++·算法
aramae3 小时前
C++ -- 模板
开发语言·c++·笔记·其他
MChine慕青5 小时前
顺序表与单链表:核心原理与实战应用
linux·c语言·开发语言·数据结构·c++·算法·链表
骄傲的心别枯萎6 小时前
RV1126 NO.16:通过多线程同时获取H264和H265码流
linux·c++·音视频·rv1126
落羽的落羽6 小时前
【C++】特别的程序错误处理方式——异常机制
开发语言·c++
空山新雨(大队长)7 小时前
C 语言第一课:hello word c
c++·c·exe
春蕾夏荷_7282977257 小时前
c++ 第三方库与个人封装库
c++·三方库