Is this legal?:
Sample& sample = stack.front();
stack.pop_front();
My program works. But Sample class have boost::optional<boost::posix_time::ptime> xxx member and after pop_front, is_initialized() returns false;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, this is not legal. You must take a copy of the object, i.e. use
If you are using a
std::vector, thepop_frontcall moves the elements behind to the location and your reference points to a different element (the previously second, now first element.)