//tuple
std::tuple<int, int, int, int, QString> Thorface::getUserInfoToJudgeOpendoor(QString strUserCode) { int iunpaidOrderList = 0; int iunhandledOrderList = 0; int istatus = 0; int ibindFace = 0; QString strUserName = ""; return std::make_tuple(iunpaidOrderList, iunhandledOrderList, istatus, ibindFace, strUserName); }
//tie解析
int iunpaidOrderList = 0;
int iunhandledOrderList = 0;
int istatus = -1;
int ibindFace = -1;
QString strUserName = "";
std::tie(iunpaidOrderList, iunhandledOrderList, istatus, ibindFace, strUserName) = getUserInfoToJudgeOpendoor(strName);
tuple是一个固定大小的不同类型值的集合,是泛化的std::pair。和c#中的tuple类似,但是比c#中的tuple强大得多。我们也可以把他当做一个通用的结构体来用,不需要创建结构体又获取结构体的特征,在某些情况下可以取代结构体使程序更简洁,直观。