File: tuple.cpp

package info (click to toggle)
yrmcds 1.0.4-6
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 924 kB
  • ctags: 1,346
  • sloc: cpp: 9,634; sh: 133; makefile: 97
file content (24 lines) | stat: -rw-r--r-- 547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <tuple>
#include <iostream>
#include <vector>
#include <cstdlib>

int main(int argc, char** argv) {
    std::vector<std::tuple<void*, int>> p;
    void* vv = std::malloc(10);
    std::cout << vv << std::endl;
    p.emplace_back(vv, 3);
    for( auto t: p ) {
        void* v;
        std::tie(v, std::ignore) = t;
        std::cout << v << std::endl;
    }
    std::free(vv);

    auto tt = std::make_tuple(1, "abc");
    std::get<0>(tt) = 3;
    int n;
    std::tie(n, std::ignore) = tt;
    std::cout << n << std::endl;
    return 0;
}