Is there any difference between calling vector.back() and vector[vector.size() - 1] with std::vector's?
vector.back() is simpler to read and write. Also, more containers offer c.back() than c[c.size() - 1], which is important for generic code.
In a debug-runtime, both are equally likely to be trapped on empty containers, nor is the resulting code and thus their performance when using optimization expected to differ significantly.
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