On 18/08/13 21:41, Matt Calabrese wrote:
Mathias, do you have any reason for the assertion that it's "unnecessarily inefficient" at compile time?
- It instantiates more templates (at least 4 instead of 1, and much worse if going through the function_traits path) - It increases symbol size. - It requires an additional name resolution and overload resolution step.
Please post a comparison of compile-times and I'll optimize if necessary. Otherwise, for now I'd say just use the macros when you can and use std::enable_if or boost::enable_if if you have to. I've pretty much just used the macros for the past year or so.
You just can't beat the efficiency of a single instantiation of a trivial class template like enable_if_c. Really I don't see how all that cost and portability concerns make it worthwhile to write template<class T, BOOST_ENABLE_IF(is_same<T, float>)) int f(T const&) { return 0; } instead of template<class T> typename enable_if< is_same<T, float> , int >::type f(T const&) { return 0; }