I want to store a sequence of string in a queue. This seems pretty simple if i use the member function push()
queue test;
string s0(\"s0\"), s1(
First off, your example of 'implicitly' enqueueing items has no mention of the queue - do you mean something like:
test << s0 << s1 << s2 << s3;
If so, it's possible, but I wouldn't recommend it. It really doesn't help readability that much. If you really do want it, though, put this in a header somewhere and include it wherever you want this behavior:
template
std::queue &operator<<(std::queue &q, const T &v)
{
q.push(v);
return q;
}
Note that the opposite order - s0 >> s1 >> s2 >> test
- is not possible, due to C++ precedence rules.