
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"