Container access with non-member functions

Standard containers provide the begin() and end() member functions for retrieving iterators to the first and one-past-last element of the container. There are actually four sets of these functions. Apart from begin()/end(), containers provide cbegin()/cend() to return constant iterators, rbegin()/rend() to return mutable reverse iterators, and crbegin()/crend() to return constant reverse iterators. In C++11/C++14, all these have non-member equivalents that work with standard containers, C-like arrays, and any custom type that specializes them. In C++17, even more non-member functions have been added; std::data()--that returns a pointer to the block of memory containing the elements of the container, std::size()--that returns the size of a container or array, and std::empty()--that returns whether the given container is empty.  These non-member functions are intended for generic code but can be used anywhere in your code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset