#include <queue>
#include <deque>
#include <iostream>
template<typename T, typename Container=std::deque<T> >
class iterable_queue : public std::queue<T,Container>
{
public:
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator const_iterator;
iterator begin() { return this->c.begin(); }
iterator end() { return this->c.end(); }
const_iterator begin() const { return this->c.begin(); }
const_iterator end() const { return this->c.end(); }
};
int main() {
iterable_queue<int> int_queue;
for(int i=0; i<10; ++i)
int_queue.push(i);
for(auto it=int_queue.begin(); it!=int_queue.end();++it)
std::cout << *it << "\n";
return 0;
}
I2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8ZGVxdWU+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCnRlbXBsYXRlPHR5cGVuYW1lIFQsIHR5cGVuYW1lIENvbnRhaW5lcj1zdGQ6OmRlcXVlPFQ+ID4KY2xhc3MgaXRlcmFibGVfcXVldWUgOiBwdWJsaWMgc3RkOjpxdWV1ZTxULENvbnRhaW5lcj4KewpwdWJsaWM6CiAgICB0eXBlZGVmIHR5cGVuYW1lIENvbnRhaW5lcjo6aXRlcmF0b3IgaXRlcmF0b3I7CiAgICB0eXBlZGVmIHR5cGVuYW1lIENvbnRhaW5lcjo6Y29uc3RfaXRlcmF0b3IgY29uc3RfaXRlcmF0b3I7CgogICAgaXRlcmF0b3IgYmVnaW4oKSB7IHJldHVybiB0aGlzLT5jLmJlZ2luKCk7IH0KICAgIGl0ZXJhdG9yIGVuZCgpIHsgcmV0dXJuIHRoaXMtPmMuZW5kKCk7IH0KICAgIGNvbnN0X2l0ZXJhdG9yIGJlZ2luKCkgY29uc3QgeyByZXR1cm4gdGhpcy0+Yy5iZWdpbigpOyB9CiAgICBjb25zdF9pdGVyYXRvciBlbmQoKSBjb25zdCB7IHJldHVybiB0aGlzLT5jLmVuZCgpOyB9Cn07CgppbnQgbWFpbigpIHsKICAgIGl0ZXJhYmxlX3F1ZXVlPGludD4gaW50X3F1ZXVlOwogICAgZm9yKGludCBpPTA7IGk8MTA7ICsraSkKICAgICAgICBpbnRfcXVldWUucHVzaChpKTsKICAgIGZvcihhdXRvIGl0PWludF9xdWV1ZS5iZWdpbigpOyBpdCE9aW50X3F1ZXVlLmVuZCgpOysraXQpCiAgICAgICAgc3RkOjpjb3V0IDw8ICppdCA8PCAiXG4iOwogICAgcmV0dXJuIDA7Cn0=