queue<pair<int,int>> q;
    q.push({1,2});
q.push(make_pair(1,2)); q.emplace(
1,2);

上面三种方法是ok的,emplace会直接构造,而push需要显式地调用一下。

q.push((1,2));
//error: no matching function for call to 'std::queue<std::pair<int, int> >::push(int)'

上面的方法是错误的,不能隐式构造。下面也是:

q.push(1,2);
//error: no matching function for call to 'std::queue<std::pair<int, int> >::push(int, int)'

2.从queue中取pair 

auto [x, y] = Q.front();

auto+[]中括号。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
  • 2021-09-22
  • 2021-11-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-13
  • 2021-08-17
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
相关资源
相似解决方案