Is there a reason std::front and std::back are not present in C++11?
There is std::begin and std::end so to me, having the equivalent with regards to actual instances would make sense.
1 Answer
std::begin() and std::end() are supposed to work for all fundamental containers (including C-style arrays).
In fact, if the container supports member begin() and end() functions, std::begin() and std::end() forward the call to those member functions.
However, not all containers support front() and back() member functions.
-
Just to clarify, all containers really mean all containers, even plain arrays. Feb 14, 2013 at 17:09
-
-
2
-
4@LCIDFire: True. That's a container adapter though, not a fundamental container. Feb 14, 2013 at 17:13
-
2@LCIDFire: Not all fundamental containers have a bidirectional iterator though (see
forward_list). Feb 14, 2013 at 17:17