C++ 在标准::unordered_map中设置 std::tuple 值

C++ Setting std::tuple values in an std::unordered_map

本文关键字:std 设置 tuple 标准 unordered C++ map      更新时间:2023-10-16

我有一个带有字符串键的无序映射和一个由三个字符串和一个整数组成的元组。如何访问各个元组以设置它们。

鉴于:

std::unordered_map<string,std::tuple<string, string, string,int>> foo_data_by_username;

如何设置foo_data_by_username[some_user];的单个元组值

std::get<0>(foo_data_by_username[some_user]) = "new string";

其中0是您感兴趣的元组的任何索引。