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
}
相关推荐
风中的微尘4 小时前
39.网络流入门
开发语言·网络·c++·算法
混分巨兽龙某某5 小时前
基于Qt Creator的Serial Port串口调试助手项目(代码开源)
c++·qt creator·串口助手·serial port
小冯记录编程5 小时前
C++指针陷阱:高效背后的致命危险
开发语言·c++·visual studio
C_Liu_6 小时前
C++:类和对象(下)
开发语言·c++
coderxiaohan6 小时前
【C++】类和对象1
java·开发语言·c++
阿昭L6 小时前
MFC仿真
c++·mfc
老赵的博客8 小时前
c++ unqiue指针
java·jvm·c++
程序猿编码9 小时前
基于 Linux 内核模块的字符设备 FIFO 驱动设计与实现解析(C/C++代码实现)
linux·c语言·c++·内核模块·fifo·字符设备
怎么没有名字注册了啊9 小时前
MFC_Install_Create
c++·mfc
Wadli10 小时前
C++语法 | static静态|单例模式
开发语言·c++·单例模式