I think the return type tends to be compatible with std::count , which takes two iterators (thinks of pointers) and returns values ββbetween them (which you can consider as the difference of two pointers). The difference of pointers (as used in ptrdiff_t ) should be significant.
Thanks to compatibility with std::count you can easily compare the results of these two functions.
Edit: here there is no restriction related to the range using the signed value, since the value will at least be in the range [0, std::count] , which itself will be in the range [0, end_ptr - start_ptr] . Since end_ptr - start_ptr is entered as ptrdiff_t or similar, it is signed.
source share