std::pair는 두 개의 값을 함께 저장하는데 사용된다.
파이썬의 튜플과 유사.
벡터와 쌍을 함께 사용하면, (int, int) 형태의 2차원 좌표를 저장하는데 유용하다.
#include <vector>
#include <iostream>
#include <utility>
using namespace std;
int main() {
vector<pair<int, int>> points;
points.push_back(make_pair(1, 2));
points.push_back(make_pair(3, 4));
points.push_back(make_pair(10, -1));
for (const auto& point : points) {
cout << point.first << ", " << point.second << endl;
}
return 0;
}
1, 2
3, 4
10, -1