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
}
相关推荐
Q***l68725 分钟前
C++在计算机图形学中的渲染
开发语言·c++
oioihoii41 分钟前
C++语言演进之路:从“C with Classes”到现代编程基石
java·c语言·c++
咔咔咔的1 小时前
3190. 使所有元素都可以被 3 整除的最少操作数
c++
T***16072 小时前
C++在游戏开发中的AI行为树
开发语言·c++
自由生长20242 小时前
为什么C++项目偏爱.cxx扩展名:从MongoDB驱动说起
c++
CSDN_RTKLIB3 小时前
【GNU、GCC、g++、MinGW、MSVC】上
c++·gnu
b***74883 小时前
C++在系统中的内存对齐
开发语言·c++
散峰而望3 小时前
C++数组(三)(算法竞赛)
开发语言·c++·算法·github
4***14903 小时前
C++在系统中的编译优化
开发语言·c++
mit6.8243 小时前
[HomeKey] 握手协议 | NFC协议处理器
c++