Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-02-07 04:54:34

I've just tried to use the header named above, from boost sandbox. However,
there's a serious problem with it. It includes another one, which
declares find_if algorithm in namespace boost, and that causes ambiguity with
std::find_if. The following code piece illustrates it

#include <algorithm>
#include <vector>

namespace boost {

     struct truth_teller {
         template<class T>
         bool operator()(const T&) { return true; }

     template <typename Iterator, typename Predicate>
     Iterator find_if(Iterator first, Iterator last, Predicate pred) {

     void do_the_thing(std::vector<int>& t) {
         std::remove_if(t.begin(), t.end(), truth_teller());

The situation is that implementation of std::remove_if calls find_if
(not std::find_if). Thanks to argument-dependent lookup (the predicate
is from boost namespace), boost::find_if is found, and ambiguity arises.
(This all happens with g++ 3.2).

So, what is it? A bug in standard library? A problem with the standard? Or,
providing another find_if in namespace boost can never work?

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at