Google Группы больше не поддерживают новые публикации и подписки в сети Usenet. Опубликованный ранее контент останется доступен.

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

92 просмотра
Перейти к первому непрочитанному сообщению

vlad....@mail.ru

не прочитано,
17 янв. 2012 г., 11:33:5917.01.2012
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 новых сообщений