
From: Matt Calabrese
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 ) { /**/ }
Besides being slightly more verbose, this only works in C++11.
If you want to group requirements into a simple name, you can also use a typedef.
Grouping requirements is extremely common. Using a typedef is the equivalent
of creating a function object vs using a lambda. However, many times multiple
requirements are created because there are multiple parameters, or to avoid
ambiguities. Requirements need to be included and excluded in order to work
around ambiguities. For example, to define an equals function that work
recursively over ranges, and pairs, could be declared like this:
template
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.
I was referring to the ConceptsLite proposal. Instead of
`ZEN_FUNCTION_REQUIRES` using `enable_if` underneath, it could use the
requires clause instead(for compilers that support it). Somethng like this(its
just a rough idea):
template<class Cond>
constexpr bool has_traits()
{
return Cond::value;
}
#define ZEN_ERROR_PARENTHESIS_MUST_BE_PLACED_AROUND_THE_RETURN_TYPE(...) __VA_ARGS__
#define ZEN_FUNCTION_REQUIRES(...) \
requires has_traits