Boost logo

Boost Users :

From: François Duranleau (duranlef_at_[hidden])
Date: 2005-12-06 14:14:41


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_

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net