binders and negator

This is a discussion on binders and negator within the C++ Programming forums, part of the General Programming Boards category; Just to establish something quickly here... I definitely cannot use function adaptors to alter the interface to regular predicate functions. ...

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,581

    binders and negator

    Just to establish something quickly here...

    I definitely cannot use function adaptors to alter the interface to regular predicate functions. Only if my predicate function is a function object. Correct?
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Correct?
    Sort of. You can do it by using ptr_fun, mem_fun, and friends. But technically, implementation-wise you can't because even the interfaces provided will wrap your function within a function object for actual use by the adapter.
    My best code is written with the delete key.

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,581
    Ok. Thanks Prelude. I was having an hard time interpreting the compiler errors. I was unsure if my design of the unary pred was flawed or if it had to do with the expected parameters to bind2nd(). Had to check.

    A function object solved my problem and even removed the need for the adaptor.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21