stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Far...@kyiv.vdiweb.com>
Subject VC7 fails to compile conv_to_bool == false
Date Wed, 20 Sep 2006 17:46:48 GMT
  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".

  The count of tests which are failed due to written above is 15.

Farid.

Mime
View raw message