Most terse and reusable way of wrapping template or overloaded functions in function objects
- 阅读更多 关于 Most terse and reusable way of wrapping template or overloaded functions in function objects
问题 Scenario 1: a template function pred template<typename T> bool pred(T t) { /* return a bool based on t */ } Scenario 2: a set of functions overloaded on the same name pred bool pred(A t) { /* return a bool based on t */ } bool pred(B t) { /* return a bool based on t */ } bool pred(C t) { /* return a bool based on t */ } ... Whichever of the two scenarii we're in, the bottom line is that pred does not refer to a function, and so it cannot be passed around, e.g. as a unary predicate to std: