tupleを使った変数の交換
まあ、使い道はないです。参照を使うというのもなくはないかな~
int main() { using std::tuple; int x = 1, y = 2; tuple<int&, int&> t(x, y); t = std::make_tuple(y, x); printf("%d, %d", x, y); // 2, 1 getchar(); return 0; }
まあ、使い道はないです。参照を使うというのもなくはないかな~
int main() { using std::tuple; int x = 1, y = 2; tuple<int&, int&> t(x, y); t = std::make_tuple(y, x); printf("%d, %d", x, y); // 2, 1 getchar(); return 0; }