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
}
相关推荐
ruanjiananquan9913 分钟前
c,c++语言的栈内存、堆内存及任意读写内存
java·c语言·c++
持梦远方1 小时前
C 语言基础入门:基本数据类型与运算符详解
c语言·开发语言·c++
江理不变情1 小时前
图像质量对比感悟
c++·人工智能
apocelipes2 小时前
记一次ADL导致的C++代码编译错误
c++·开发工具和环境
Code Warrior3 小时前
【每日算法】专题五_位运算
开发语言·c++
OneQ6668 小时前
C++讲解---创建日期类
开发语言·c++·算法
Coding小公仔10 小时前
C++ bitset 模板类
开发语言·c++
菜鸟看点10 小时前
自定义Cereal XML输出容器节点
c++·qt
悲伤小伞12 小时前
linux_git的使用
linux·c语言·c++·git
ysa05103012 小时前
数论基础知识和模板
数据结构·c++·笔记·算法