
On Sun, Aug 18, 2013 at 4:16 PM, paul Fultz
From: TONGARI J Hi folks,
It's over 2 years since this post:
http://boost.2283326.n4.nabble.com/New-powerful-way-to-use-enable-if-in-C-0x...
The macro looks sweet and I wonder if we have this macro in Boost in case that I missed it.
This is nice for C++11 and conversion operators, I was not aware of this trick. However, it would be nice if boost provided requires macros to make it easier to specify traits for enable_if. See here for an implementation:
https://github.com/pfultz2/Zen/blob/master/zen/requires.h
So functions can be defined like this:
template
ZEN_FUNCTION_REQUIRES(is_arithmetic<T>, is_arithmetic<U>) (T) max(T x, U y) { return x > y : x ? y; }
How is this different from: template< class T, class U , BOOST_ENABLE_IF( and_< is_arithmetic< T >, is_arithmetic< U > > ) > T max( T x, U y ) { /**/ } If you want to group requirements into a simple name, you can also use a typedef. As for the emulation stuff you are talking about, there's the "generic" directory in the sandbox, which is a library for concept emulation, though it's sort of in limbo. -- -Matt Calabrese