Section 25, lib.algorithms, paragraph 7, defines the Predicate parameter in
std::find_if and others as returning a value that need only be usable in the
controlling-expression of an if statement. libstdc++'s find_if incorrectly
relies on the operator! function, which may not be usable.

In a case where operator! is private, this error results:

test.c: In function `_InputIterator std::__find_if(_InputIterator,
_InputIterator, _Predicate, std::input_iterator_tag) [with _InputIterator =
std::_List_iterator<double>, _Predicate = my_bool (*)(double)]':
.../include/c++/4.1.1/bits/stl_algo.h:338:   instantiated from `_InputIterator
std::find_if(_InputIterator, _InputIterator, _Predicate) [with _InputIterator =
std::_List_iterator<double>, _Predicate = my_bool (*)(double)]'
test.c:16:   instantiated from here
test.c:7: error: `bool my_bool::operator!() const' is private
.../include/c++/4.1.1/bits/stl_algo.h:188: error: within this context


-- 
           Summary: find_if uses operator! instead of conversion to bool
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: djg at cray dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31556

Reply via email to