Is it okay to “Move” an object from a queue, if you’re about to pop from it?

Yes, this is perfectly safe:

std::queue<T> q;
// add stuff...

T top = std::move(q.front());
q.pop();

pop() doesn’t have any preconditions on the first element in the q having a specified state, and since you’re not subsequently using q.front() you don’t have to deal with that object being invalidated any more.

Sounds like a good idea to do!

Leave a Comment

casinojojobetpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişcasinoholiganbet girişholiganbet güncel giriş