@H_301_1@元组:
#include <tuple> // std::tuple,std::make_tuple,std::tie int num; char letter; std::tuple<int,char> num_letter; num_letter = std::make_tuple(10,'a'); std::tie(num,letter) = num_letter; // unpack num_letter into num and letter
有配对的东西吗?
// ... num_letter = std::make_pair(10,'a'); std::pair_tie(num,letter) = num_letter;
解决方法
实际上,对于代码是完全一样的,因为std :: tuple有
operator =
with std::pair
as an argument.
num_letter = std::make_pair(10,letter) = num_letter;