I have some code that needs to assign the first and last elements of a vector as a special case.
Is somevector.back() an lvalue? Will the following code work?
some_vector.front()=first_value;
some_vector.back()=last_value;
Yes it can, as it returns a reference to the last element. Better make sure it's not empty first!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With