boost::bind annoyance with home grown iterator

Discussion in 'C++' started by joe, Feb 13, 2008.

  1. joe

    joe Guest

    I'm having an annoyance with a boost::bind failure that I can't figure
    out. I'm using an iterator and have all the required fields for
    iterator (value_type, etc).

    I'm trying to call the function:

    find(obj.begin(),
    obj.end(),
    boost::bind(std::greater<double>(), _1, 4.4);

    which gives the error:
    stl_algo.h:172: error: no match for 'operator==' in (&_first)-
    >MyIter<T>::eek:perator* [with T = double]() == __val'


    I'm surprised this fails, because all the following work fine:
    double a = *obj.begin();
    double b = *obj.begin();

    and most telling:
    bool a = (*obj.begin() == 4.4);

    since the code in stl_algo.h is doing exactly that. What could boost
    be doing to the _1 placeholder? I assumed it did little more than use
    operator* on each iterator as it is passed them.

    Any ideas?
    joe, Feb 13, 2008
    #1
    1. Advertising

  2. joe

    joe Guest


    > Any ideas?


    I need to use find_if of course. that'll teach me to post too early
    joe, Feb 13, 2008
    #2
    1. Advertising

  3. joe

    Kira Yamato Guest

    On 2008-02-13 17:27:19 -0500, joe <> said:

    > I'm having an annoyance with a boost::bind failure that I can't figure
    > out. I'm using an iterator and have all the required fields for
    > iterator (value_type, etc).
    >
    > I'm trying to call the function:
    >
    > find(obj.begin(),
    > obj.end(),
    > boost::bind(std::greater<double>(), _1, 4.4);
    >
    > which gives the error:
    > stl_algo.h:172: error: no match for 'operator==' in (&_first)-
    >> MyIter<T>::eek:perator* [with T = double]() == __val'


    That's because _1 is not of type double, but rather of type

    boost::lambda::placeholder1_type.

    Have you tried using boost.lambda instead?

    using namespace boost::lambda;

    find_if(obj.begin(), obj.end(), _1 > 4.4);

    > [...]


    --

    // kira
    Kira Yamato, Feb 14, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JS Bangs

    Re: XML or home-grown format?

    JS Bangs, Jul 25, 2003, in forum: XML
    Replies:
    2
    Views:
    424
    MegaZone
    Jul 26, 2003
  2. theRat
    Replies:
    2
    Views:
    409
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Jan 31, 2007
  3. default

    home grown strtok() function for review

    default, Sep 19, 2006, in forum: C Programming
    Replies:
    4
    Views:
    344
    default
    Sep 21, 2006
  4. Replies:
    0
    Views:
    579
  5. Nathaniel Talbott

    Home grown continuations

    Nathaniel Talbott, Aug 2, 2003, in forum: Ruby
    Replies:
    3
    Views:
    84
    Jim Weirich
    Aug 2, 2003
Loading...

Share This Page