Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Absence of global functions std::cbegin() and std::cend()

92 views
Skip to first unread message

vlad....@mail.ru

unread,
Jan 17, 2012, 11:33:59 AM1/17/12
to
Along with global functions std::begin() and std::end() there should
be their visavis in the C++ Standard: global functions std::cbegin()
and std::cend() which return const_iterator for containers or pointers
to constant arrays.

For example

#include<iostream>
#include<algorithm>
#include<iterator>

int main()
{
const int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

std::vector<int> v( std::cbegin( a ), std::cend( a ) );

std::copy( std::cbegin( a ), std::cend( a ),
std::ostream_iterator<int>( std::cout, " " ) );
std::copy( std::cbegin( v ), std::cend( v ),
std::ostream_iterator<int>( std::cout, " " ) );
}


--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp...@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
0 new messages