Boost logo

Boost :

From: Jordan DeLong (jordan.delong_at_[hidden])
Date: 2006-12-15 13:15:55


The other day I wrote a line that looked something like:

foo.erase(
  std::remove_if(foo.begin(), foo.end(),
    some_condition ? !boost::is_any_of("blah")
                   : boost::is_any_of("blah")),
  foo.end());

This compiled fine, but behaved unexpectedly at runtime. It seems that
the compiler decides to instantiate the remove_if template with the
predicate type as the negator class, which has an implicit constructor.
So even when some_condition is false, it still ended up negating the
predicate.

The class involved is algorithm::detail::pred_notF<>. Is there any reason
for the constructor to be implicit? (Some of the other constructors in
classification.hpp are also implicit.)

Thanks,

-- 
Jordan DeLong
jordan.delong_at_[hidden]



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