I am using C++ Builder 10.4 with Dinkumware 8.03. The non-member function std::cbegin sometimes returns an iterator when it should always be a const_iterator. The following program will not compile due to b1 being deduced as iterator and b2 a const_iterator. There is no problem with c1 and c2. The fix is to add const to the parameter _Container & as described in the book.
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> a1(100, 2);
std::vector<int> const a2(100, 3);
auto const
b1= std:: cbegin(a1),
b2= std::cbegin(a2);
/*auto const
c1= a1.cbegin(),
c2= a2.cbegin(); */
// See item 13 of Effective Modern C++ for explanation.
return 0;
}
/* line 1672 of xiter
template<class _Container>
_CONST_FUN auto inline cbegin(_Container& _Cont) _NOEXCEPT_OP(_NOEXCEPT_OP(_STD begin(_Cont)))
-> decltype(_STD begin(_Cont))
{ // get beginning of sequence
return (_STD begin(_Cont));
} */