Re: [Boost-users] boost::sub_range vs boost::iterator_range

At 14:16 2005-12-05, François Duranleau wrote:
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed X-MIME-Autoconverted: from 8bit to quoted-printable by milliways.osl.iu.edu id jB5LNecL002899
On Sat, 3 Dec 2005, Victor A. Wagner Jr. wrote:
After reading (and re-reading a few times) the documentation on range, it appears to me that there is little (if any) difference between: boost::sub_range<T> and boost::iterator_range<T::iterator>
Seems to me that sub_range is a convenience class to describe iterator ranges from ranges or containers that model ForwardRange, from which you can propagate constness.
yup, that's what I thought also
I've been working on a N way merge algorithm for work, and thought it might be a nice chance to learn bost::range and maybe even get it general enough to submit for boost utility some day. At any rate. Here's the problem: I've written a test case and two implementations (work still in progress) but I get compile errors when I try to use sub_range.
the code can be found at http://www.noidea128.org/sourcefiles/15646~
to change the program from compiling/running the iterator_range to sub_range simply change the lne from:
Nway_merge(contain, ourmerged); -to- SNway_merge(contain, ourmerged);
my compiler (VC-8_0) gives two errors which I cannot decipher. Any assistance would be appreciated.... especially if I've misunderstood why sub_range instead of iterator_range.
Mm, I don't know. The only thing g++-4.0 (sorry, I can't help you with VC) was complaining about are the missing 'typename's for the declaration of member_container_iterator and iterator_range_iterator in Nway_merge, and sub_range_iterator in SNway_merge. What are the errors reported by the compiler?
I put in the typenames you (your compiler) suggested, that didn't fix the compile here... I still get: 1>------ Build started: Project: MergeTesting, Configuration: Release Win32 ------ 1>Compiling... 1>MergeTesting.cpp 1>c:\boost\include\boost-1_33\boost/range/iterator_range.hpp(61) : error C2440: '<function-style-cast>' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>' to 'std::_Vector_iterator<_Ty,_Alloc>' 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> No constructor could take the source type, or constructor overload resolution was ambiguous 1> c:\boost\include\boost-1_33\boost/range/iterator_range.hpp(238) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_begin<const ForwardRange>(ForwardRange &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=boost::sub_range<member_container> 1> ] 1> c:\boost\include\boost-1_33\boost/range/iterator_range.hpp(245) : see reference to function template instantiation 'boost::iterator_range<IteratorT> &boost::iterator_range<IteratorT>::operator =<boost::sub_range<ForwardRange>>(const boost::sub_range<ForwardRange> &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=member_container 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xmemory(160) : while compiling class template member function 'void std::allocator<_Ty>::destroy(std::vector<int> *)' 1> with 1> [ 1> _Ty=ci 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(416) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled 1> with 1> [ 1> _Ty=ci 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(426) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled 1> with 1> [ 1> _Ty=ci, 1> _Alloc=std::allocator<ci> 1> ] 1> .\MergeTesting.cpp(21) : see reference to class template instantiation 'std::vector<_Ty>' being compiled 1> with 1> [ 1> _Ty=ci 1> ] 1>c:\boost\include\boost-1_33\boost/range/iterator_range.hpp(68) : error C2440: '<function-style-cast>' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>' to 'std::_Vector_iterator<_Ty,_Alloc>' 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> No constructor could take the source type, or constructor overload resolution was ambiguous 1> c:\boost\include\boost-1_33\boost/range/iterator_range.hpp(239) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_end<const ForwardRange>(ForwardRange &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=boost::sub_range<member_container> 1> ] 1>Build log was saved at "file://c:\Projects\Viper2005\MergeTesting\Release\BuildLog.htm" 1>MergeTesting - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== I changed my compiler to use the latest 1_33_1 and I get: 1>------ Build started: Project: MergeTesting, Configuration: Release Win32 ------ 1>Compiling... 1>MergeTesting.cpp 1>c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(61) : error C2440: '<function-style-cast>' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>' to 'std::_Vector_iterator<_Ty,_Alloc>' 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> No constructor could take the source type, or constructor overload resolution was ambiguous 1> c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(238) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_begin<const ForwardRange>(ForwardRange &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=boost::sub_range<member_container> 1> ] 1> c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(245) : see reference to function template instantiation 'boost::iterator_range<IteratorT> &boost::iterator_range<IteratorT>::operator =<boost::sub_range<ForwardRange>>(const boost::sub_range<ForwardRange> &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=member_container 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xmemory(160) : while compiling class template member function 'void std::allocator<_Ty>::destroy(std::vector<int> *)' 1> with 1> [ 1> _Ty=ci 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(416) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled 1> with 1> [ 1> _Ty=ci 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(426) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled 1> with 1> [ 1> _Ty=ci, 1> _Alloc=std::allocator<ci> 1> ] 1> .\MergeTesting.cpp(21) : see reference to class template instantiation 'std::vector<_Ty>' being compiled 1> with 1> [ 1> _Ty=ci 1> ] 1>c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(68) : error C2440: '<function-style-cast>' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>' to 'std::_Vector_iterator<_Ty,_Alloc>' 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> No constructor could take the source type, or constructor overload resolution was ambiguous 1> c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(239) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_end<const ForwardRange>(ForwardRange &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=boost::sub_range<member_container> 1> ] 1>Build log was saved at "file://c:\Projects\Viper2005\MergeTesting\Release\BuildLog.htm" 1>MergeTesting - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-- François Duranleau LIGUM, Université de Montréal
"There once was a boy who dreamed of being a hero, who believed sincerely in the battle to banish Darkness from a world of Light. But Light and Darkness are equal, and where one exists, so too must the other. And when the boy finally realized this, he had taken the first step toward being a true hero." - from Record of Lodoss War
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"

"Victor A. Wagner Jr." <vawjr@rudbek.com> writes:
At 14:16 2005-12-05, François Duranleau wrote:
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed X-MIME-Autoconverted: from 8bit to quoted-printable by milliways.osl.iu.edu id jB5LNecL002899
On Sat, 3 Dec 2005, Victor A. Wagner Jr. wrote:
After reading (and re-reading a few times) the documentation on range, it appears to me that there is little (if any) difference between: boost::sub_range<T> and boost::iterator_range<T::iterator>
Seems to me that sub_range is a convenience class to describe iterator ranges from ranges or containers that model ForwardRange, from which you can propagate constness.
yup, that's what I thought also
So what's the distinction? The constness of a subrange affects the constness of its iterators? or...? Having two such beasts in Boost seems on the surface like a clear case of brokenness. -- Dave Abrahams Boost Consulting www.boost-consulting.com

At 12:04 2005-12-06, you wrote:
"Victor A. Wagner Jr." <vawjr@rudbek.com> writes:
At 14:16 2005-12-05, François Duranleau wrote:
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed X-MIME-Autoconverted: from 8bit to quoted-printable by milliways.osl.iu.edu id jB5LNecL002899
On Sat, 3 Dec 2005, Victor A. Wagner Jr. wrote:
After reading (and re-reading a few times) the documentation on range, it appears to me that there is little (if any) difference between: boost::sub_range<T> and boost::iterator_range<T::iterator>
Seems to me that sub_range is a convenience class to describe iterator ranges from ranges or containers that model ForwardRange, from which you can propagate constness.
yup, that's what I thought also
So what's the distinction? The constness of a subrange affects the constness of its iterators? or...?
Having two such beasts in Boost seems on the surface like a clear case of brokenness.
I don't know, my problem, though, is that I cannot get it to compile
-- Dave Abrahams Boost Consulting www.boost-consulting.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"

On Mon, 5 Dec 2005, Victor A. Wagner Jr. wrote:
At 14:16 2005-12-05, François Duranleau wrote:
I've been working on a N way merge algorithm for work, and thought it might be a nice chance to learn bost::range and maybe even get it general enough to submit for boost utility some day. At any rate. Here's the problem: I've written a test case and two implementations (work still in progress) but I get compile errors when I try to use sub_range.
the code can be found at http://www.noidea128.org/sourcefiles/15646~
to change the program from compiling/running the iterator_range to sub_range simply change the lne from:
Nway_merge(contain, ourmerged); -to- SNway_merge(contain, ourmerged);
my compiler (VC-8_0) gives two errors which I cannot decipher. Any assistance would be appreciated.... especially if I've misunderstood why sub_range instead of iterator_range.
Mm, I don't know. The only thing g++-4.0 (sorry, I can't help you with VC) was complaining about are the missing 'typename's for the declaration of member_container_iterator and iterator_range_iterator in Nway_merge, and sub_range_iterator in SNway_merge. What are the errors reported by the compiler?
I put in the typenames you (your compiler) suggested, that didn't fix the compile here... I still get:
[snip]
1>------ Build started: Project: MergeTesting, Configuration: Release Win32 ------ 1>Compiling... 1>MergeTesting.cpp 1>c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(61) : error C2440: '<function-style-cast>' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>' to 'std::_Vector_iterator<_Ty,_Alloc>' 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> No constructor could take the source type, or constructor overload resolution was ambiguous 1> c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(238) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_begin<const ForwardRange>(ForwardRange &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=boost::sub_range<member_container> 1> ] 1> c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(245) : see reference to function template instantiation 'boost::iterator_range<IteratorT> &boost::iterator_range<IteratorT>::operator =<boost::sub_range<ForwardRange>>(const boost::sub_range<ForwardRange> &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=member_container 1> ]
There is clearly a probleme here. A const sub_range is attempted to be assigned to a non-const one. However, from the rest of the error messages, I can't figure out from which point of instantiation in your source code this error is caused (or what is at line 21 in MergeTesting.cpp?). In the file at the URL you mentioned before, it is just an initialization of a vector that has no relation with ranges.
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xmemory(160) : while compiling class template member function 'void std::allocator<_Ty>::destroy(std::vector<int> *)' 1> with 1> [ 1> _Ty=ci 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(416) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled 1> with 1> [ 1> _Ty=ci 1> ] 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(426) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled 1> with 1> [ 1> _Ty=ci, 1> _Alloc=std::allocator<ci> 1> ] 1> .\MergeTesting.cpp(21) : see reference to class template instantiation 'std::vector<_Ty>' being compiled 1> with 1> [ 1> _Ty=ci 1> ] 1>c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(68) : error C2440: '<function-style-cast>' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>' to 'std::_Vector_iterator<_Ty,_Alloc>' 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> No constructor could take the source type, or constructor overload resolution was ambiguous 1> c:\boost\include\boost-1_33_1\boost/range/iterator_range.hpp(239) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_end<const ForwardRange>(ForwardRange &)' being compiled 1> with 1> [ 1> IteratorT=std::_Vector_iterator<int,std::allocator<int>>, 1> ForwardRange=boost::sub_range<member_container> 1> ] 1>Build log was saved at "file://c:\Projects\Viper2005\MergeTesting\Release\BuildLog.htm" 1>MergeTesting - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-- François Duranleau LIGUM, Université de Montréal "When there are others, I can perceive myself as an individual. If I am alone, then I will be the same as everything else. There will be no difference between myself and nothing!" - from _Neon Genesis Evangelion_

François Duranleau <duranlef@iro.umontreal.ca> writes: <snip reams of quoted text>
1> ]
There is clearly a probleme here. <snip reams of quoted text>
Yeah, too much quoting! Please limit the amount of quotation in your postings. http://www.boost.org/more/discussion_policy.htm#quoting -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
David Abrahams
-
François Duranleau
-
Victor A. Wagner Jr.