stl中的tuple(tie)

来源:互联网 发布:淘宝货源外国 编辑:程序博客网 时间:2024/04/30 10:20

看的C++标准库(第二版)

书中关于tie()介绍看不懂,不知道这玩意到底能干啥,自己试了一波

tuple <int, float, string> t(55, 22.2, "hello");

    int i,i1;
    float f,f1;
    string s,s1;
    make_tuple(ref(i), ref(f), ref(s)) = t;
    cout << "i = " << i << endl;
    cout << "f = " << f << endl;
    cout << "s = " << s << endl;

    tie(i1, f1, s1) = t;
    cout << "i1 = " << i1 << endl;

    cout << "f1 = " << f1 << endl;

    cout << "s1 = " << s1 << endl;

这就是说的提取?



0 0