Predicate with argument

Discussion in 'C++' started by Christopher, Feb 5, 2009.

  1. Christopher

    Christopher Guest

    How do I use std::find_if with a predicate that takes an argument?

    For example,
    If I have a vector of pointers to classes that contain ints
    I want to search for the first occurence a class containing, the
    number 7
    Later, I want to search for the first occurence of a class in the same
    vector, containg the numer 5
    Where the number is the argument I want to pass to the predicate

    In my real code the argument is a string
    The vector contains smart pointers to classes that contain a string
    amongst other things.

    I am searching for the first occurence that have one string
    Then I am changing the string and searching.
     
    Christopher, Feb 5, 2009
    #1
    1. Advertisements

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. Bhushit Joshipura

    defaulting argument to previous argument

    Bhushit Joshipura, Dec 29, 2003, in forum: C++
    Replies:
    5
    Views:
    631
  2. Ben Kial
    Replies:
    1
    Views:
    958
    Eric Enright
    Nov 15, 2004
  3. S?ren Gammelmark
    Replies:
    1
    Views:
    2,272
    Eric Sosman
    Jan 7, 2005
  4. nw
    Replies:
    0
    Views:
    519
  5. Reckoner
    Replies:
    11
    Views:
    1,002
    Steven D'Aprano
    Jan 19, 2009
  6. Ian Collins

    Re: Predicate with argument

    Ian Collins, Feb 5, 2009, in forum: C++
    Replies:
    3
    Views:
    421
    Christopher
    Feb 5, 2009
  7. AikidoGuy
    Replies:
    11
    Views:
    804
    Seebs
    Nov 21, 2011
  8. Trans
    Replies:
    3
    Views:
    351
    Robert Klemme
    Jan 26, 2005
Loading...