about unary_function

This is a discussion on about unary_function within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, I am wondering what is the practical usage of unary_function? Could anyone list some practical benefits? My question ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    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,
    George

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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!
    CornedBee

    "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

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