incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: VC7 fails to compile conv_to_bool == false
Date Wed, 20 Sep 2006 23:28:31 GMT
Farid Zaripov wrote:
>   The test of the STL algorithms (25.*.cpp) uses predicate classes from
> alg_test.h.
> That classes returns conv_to_bool type from operator(). The MSVC 7.0
> fails to compile
> "conv_to_bool == false" code (that code is used in algorithms like
> find_if, ...).
> The compiler tries to apply the defined operator== for template classes
> (i.e.
> bool std::operator==(const std::pair<T,U> &, const std::pair<T,U> &))
> and fails with error:
> error C2784: 'bool std::operator ==(const std::pair<T,U> &,const
> std::pair<T,U> &)' : could not deduce template argument for 'const
> std::pair<T,U> &' from 'conv_to_bool'
> 
> If no operators defined at the moment the compiler fails with error:
> error C2676: binary '==' : 'conv_to_bool' does not define this operator
> or a conversion to a type acceptable to the predefined operator
> 
>   Although the compiler compiles the expression if
> (conv_to_bool::make(true)), bool b = conv_to_bool::make(true) without
> any errors.
> 
>   The possible way is to define conv_to_bool::operator bool especially
> for MSVC 7.0, but the comment to the conv_to_bool says
> "type used to exercise that algorithms do not apply operators to
> function objects the latter are not required to define".

Yes, that is the purpose of the type. I.e., the tests are designed
to fail to compile when the algorithms make assumptions about the
Predicate that go beyond what the standard requires. But if the
tests fail because a compiler bug prevents the test predicate
from working correctly we should either use some other technique
to exercise the absence of these assumptions or, if no alternative
exists, avoid exercising it altogether.

It would be good to have a test case for the compiler bug so we
can figure out if we can work around it and how (since MSVC 7.0
has been superseded by not just one but two more recent versions
I wouldn't spend too much time on narrowing it down to a test
case if it's hard; we can simply disable those tests for this
compiler).

Martin

Mime
View raw message