
On 12/04/2011 05:15 PM, Dave Abrahams wrote:
I don't know whether this is actually possible, but I was thinking today that there might be a way to use the new SFINAE to detect errors in a large class of invalid expressions without actually causing a hard error, and thereby build an assertion that fails compilation when passed a valid expression and passes for any invalid expression in the large class mentioned above.
Any takers?
Why not just something like template<class T> decltype(my_expr_that_depends_on_T, char) foo(int); template<class T> int foo(...); static const bool valid = sizeof(foo<T>(0)) == sizeof(char); BOOST_MPL_ASSERT(!valid, ...) I suppose the problem with the macro will be to be able to find a nice syntax to specify the template arguments the expression must depend on.