Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-01-11 11:28:07


Thorsten Ottosen wrote:
> Eric Niebler wrote:
>> Thorsten Ottosen wrote:
>
>>>> This is on HEAD, BTW.
>>> Fixed
>>
>> Thanks. You might want to add a test for this as well <nudge>.
>
> Will don when I get some more time.

Thanks.

>> While we're at it, this trivial code fails to compile on msvc-7.1:
>>
>> int rg[5] = {};
>> boost::begin(rg);
>>
>> Clearly, it's a compiler bug. But the work-around is simple enough. In
>> range/begin.hpp, the begin() overloads have the following signatures:
>>
>> template< class T >
>> typename range_iterator<T>::type begin( T& r )
>>
>> template< class T >
>> typename range_iterator<const T>::type begin( const T& r )
>>
>> If there were defined as follows:
>>
>> template< class T >
>> typename range_mutable_iterator<T>::type begin( T& r )
>>
>> template< class T >
>> typename range_const_iterator<T>::type begin( const T& r )
>>
>> .... the problem would go away, I think. Same is true for end(), size(),
>
> Hm ... I don't recall vc7.1 having any problems with this before.
> AFAICT, it has to do with mpl:
>
> ..\..\..\boost\range\iterator.hpp(33) : error C2039: 'type' : is not a
> member of
> 'boost::mpl::eval_if_c<C,F1,F2>'
> with
> [
> C=false,
> F1=boost::range_const_iterator<boost::remove_const<wchar_t
> [20]>::ty
> pe>,
> F2=boost::range_mutable_iterator<wchar_t [20]>
> ]

This is not an mpl-specific problem. As Shunsuke correctly observed, it
has to do with your use of "T const" in the begin() function's return
type, when T is deduced by msvc-7.1 as an array type. Please either try
my suggestion above, or Shunsuke's (to use "add_const<T>::type" instead
of "T const") to confirm that it does indeed fix the problem.

Thanks.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk