Overloads Custom overloads of size may be provided for classes and enumerations that do not expose a suitable size () member function, yet can be detected. Overloads of size found by argument-dependent lookup can be used to customize the behavior of std::ranges::size, std::ranges::ssize, and std::ranges::empty.
Example [edit] The following code uses size to display the number of elements in a std::vectorThe default implementation of size () member function obtains the size of the range by calculating the difference between the sentinel and the beginning iterator.
Example [edit] The following code uses size to display the number of elements in a std::array: Run this code #include