• C++11新特性之tie、tuple的应用


    //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强大得多。我们也可以把他当做一个通用的结构体来用,不需要创建结构体又获取结构体的特征,在某些情况下可以取代结构体使程序更简洁,直观。

  • 相关阅读:
    【水】希望之花
    如何不用狄利克雷卷积证明莫比乌斯函数性质二
    【数学】gcd
    挂分宝典
    [luogu P6042]「ACOI2020」学园祭 题解
    [luogu P6041]「ACOI2020」布丁暗杀计划 题解
    11.19模拟
    「CSP-S2020」题解
    11.11模拟
    「洛谷P1445」樱花
  • 原文地址:https://www.cnblogs.com/xupeidong/p/10333259.html
Copyright © 2020-2023  润新知