Thread: about unary_function

  1. #1
    Registered User
    Join Date
    May 2006

    about unary_function

    Hello everyone,

    I am wondering what is the practical usage of unary_function? Could anyone list some practical benefits?

    My question is, a class like

    class Foo : public std::unary_function<class A, class B>

    is always the same (could use similar implementation) to

    template <class A, class B> class Foo

    So we could always use the alternative approach to replace unary_function.

    thanks in advance,

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    All unary_function does is add the result_type and argument_type (might be mistaken about the names) typedefs to your functor. You can always replace unary_function by simply doing this yourself.

    These typedefs are needed by the standard functor adapters.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed