
I find the use of macros to be far more readable than the direct use of templates. In fact, I was earlier toying with the idea of writing such macros myself. Needless to say that I would find them to be very helpful.
Besides readability, they actually help avoid the most vexing parse in C++(something template aliases can't fix).
Paul, can the concept be extended to a DSEL-like utility?
Well you can already write something like this on compilers that support `constexpr`: template <class T> BOOST_FUNCTION_REQUIRES(is_foo<T>() and is_bar<T>()) (T) foo(T t) { return t; } This could be made to work on older compilers by using expression templates, but then using literals such as `is_foo<T>::value` would fail. Perhaps a second macro like `BOOST_FUNCTION_REQUIRES_E` could be written to help avoid the confusion. Plus, having separate `_E` macros can actually still be useful in C++11 because of limitations of `constexpr`. For example, say we use a `trait` function that deduces the type parameters from a variable: template<template<class...> class Trait, class... Ts> constexpr auto trait(Ts&&... xs) { return Trait(std::forward<Ts>(xs)...); } template <class T> T foo(T t, BOOST_REQUIRES_E(trait<is_foo>(t) and trait<is_bar>(t))) { return t; } This is because `trait<is_foo>(t)` won't be a `constexpr` if `t` isn't a literal type. -- View this message in context: http://boost.2283326.n4.nabble.com/Adding-helpful-requires-macros-to-the-ena... Sent from the Boost - Dev mailing list archive at Nabble.com.