Why have unary_function, binary_function been removed from C++11?

后端 未结 2 679
春和景丽
春和景丽 2020-12-09 04:29

I found that binary_function is removed from C++11. I am wondering why.

C++98:

template  struct less : binary_function &l         


        
2条回答
  •  离开以前
    2020-12-09 05:16

    With variadic templates, a lot of general function composing can be expressed much more simply and consistently, so all of the old cruft is no longer necessary:

    Do use:

    • std::function
    • std::bind
    • std::mem_fn
    • std::result_of
    • lambdas

    Don't use:

    • std::unary_function, std::binary_function
    • std::mem_fun
    • std::bind1st, std::bind2nd

提交回复
热议问题