cppreference shows this signature for std::cbegin
:
template< class C >
constexpr auto cbegin( const C& c ) -> decltype(std::begin(c));
Shouldn't it return something like C::const_iterator
instead?
c
is a const
reference, so std::begin(c)
it will return whatever the const
overload of C::begin()
returns. For standard library types, this is a const_iterator
. For an array type, it is a pointer to const
.
Note that this relies on other, non-standard library user defined C
, being implemented sanely with a const
overload for C::begin()
that returns an iterator that gives you const
access to the container's elements.
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