Reputation: 1205
I want to stack or queue arrays/vectors in c++.
I've tried multiple variants, including with vectors, but unsuccessful. I thought this would be a quite "standard" problem, but cannot fint resources on it. Here is one suggested implementation of queuing vectors, but compilation doesn't like it.
#include <queue>
queue<int[2]> q;
q.push({9,3});
q.push({5,2});
Upvotes: 1
Views: 746
Reputation: 17668
This q.push({9,3});
does not work because C-style array does not have initialise-list constructor.
One solution is to use std::array instead of C-style array as the type of your queue:
#include <array>
std::queue<std::array<int, 2>> q;
q.push({9,3});
q.push({5,2});
Upvotes: 5