abir basak wrote:
Hi, I am not sure if it is the proper newsgroup to get answers related to boost usage. I am facing a problem with boost::sub_range for a const container which is not allowing me to access the indexed operator. Below a short program to demonstrate the problem. Necessary headers are included. Boost version 1.33.1 typedef vector<int> VI; VI v(10); int data[] = {0,1,2,3,4,5,6,7,8,9}; copy(data,data+10,v.begin());///inserted a few int to std::vector<int>
Hm... this is not legal. It is "not legal" or "not preferred" ? I think it is legal, as I have a statement like VI v(10); rather than VI v; copy doesn't grow memory, or change size. But here I am just copying! Of course the other (and better ) way is, VI v; int data[] = {0,1,2,3,4,5,6,7,8,9}; v.assign(data,data+10);
May I suggest
v = boost::assign::list_of(0)(1)(2)(3)(4)(5)(6) ... ;
?
///prints 0 1 2 3 4 5 6 7 8 9 copy(v.begin(),v.end(),ostream_iterator<int>(cout," ")); cout<
not allowed gives error under Visual Studio 7.1 cannot convert from 'const std::allocator<_Ty>::value_type' to 'boost::iterator_range<IteratorT>::value_type &' Why it tried to convert it to value_type& instead of const value_type& ? cout< This is an error in the range lib that should be fixed in the upcoming version of boost. Is the correction is in the CVS head ? Or can you suggest what should be
Thorsten Ottosen wrote: the correction, if it is a small correction? Thanks for answering. abir
-Thorsten