C++ tuple元组tie

#include <iostream>
#include <tuple>

int main()
{
        std::tuple<int, char, float> tuple;

        tuple = std::make_tuple(18, 'a', 2.5);

        int a;
        char b;
        float c;

        std::tie(a, b, c) = tuple;

        std::cout << a << std::endl;
        std::cout << b << std::endl;
        std::cout << c << std::endl;

        return 0;
}
# ./a.out
18
a
2.5
posted @ 2023-01-31 13:36  thomas_blog  阅读(28)  评论(0编辑  收藏  举报