|
Boost : |
Subject: Re: [boost] [Proto][Phoenix] Use default transform with SFINAE for expressions?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-09-12 22:38:58
On 12/09/2010 21:04, Daniel Walker wrote:
> I'm not sure if this could work. The C++0x draft is pretty specific
> about the context in which substitution failure is allowed, namely,
> it's only allowed in the immediate context of the function and not as
> a side effect of instantiating a template (such as a Proto class).
> Here's the relevant language from 14.8.2.
SFINAE does apply in that kind of context:
template<typename T, typename U>
decltype(make<T>() + make<U>()) add(T t, U u)
{
return t + u;
}
The overload is not considered if the expression isn't valid. Of course
this works with sizeof too, and in C++03 as well (if the compilers
supports it).
This is the kind of thing I want Proto's default transform to do.
> However, I just checked, and I was pleased to find that gcc 4.5 is now
> accepting some SFINAE for expressions.
It's been there since 4.4 I think, but has only been working well since 4.5.
I've put a macro for it in Boost.Config a while ago.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk