[enable_if] Why any other than lazy?

Boost.EnableIf defines enable_if etc, and goes on to define lazy_enable_if, which the documentation states is for the circumstances and compilers when the non-lazy version would break since the instantiation for which SFINAE should apply is a nested instantiation which is not properly processed by some compilers. What I don't understand is why anyone would wish to use the non-lazy versions, since AFAICS the lazy version will always work. Then the obvious question is why the non-lazy versions exist at all? Thanks, Rob. -- ACCU - Professionalism in programming - http://www.accu.org

AMDG Robert Jones wrote:
Boost.EnableIf defines enable_if etc, and goes on to define lazy_enable_if, which the documentation states is for the circumstances and compilers when the non-lazy version would break since the instantiation for which SFINAE should apply is a nested instantiation which is not properly processed by some compilers.
What I don't understand is why anyone would wish to use the non-lazy versions, since AFAICS the lazy version will always work.
Then the obvious question is why the non-lazy versions exist at all?
The non-lazy versions exist for ease of use. The lazy versions take a metafunction and are useful when the result is computed. The non-lazy versions are simpler to use when the return type is fixed. For example template<class T> typename boost::enable_if<boost::is_arithmetic<T>, T>::type foo(const T&); There is no point to using the lazy versions. In Christ, Steven Watanabe

On Fri, Aug 8, 2008 at 10:22 PM, Steven Watanabe <watanabesj@gmail.com>wrote:
AMDG For example
template<class T> typename boost::enable_if<boost::is_arithmetic<T>, T>::type foo(const T&);
There is no point to using the lazy versions.
Understood, but how would that be rewritten using lazy versions? It is more complicated than simply replacing enabe_if with lazy_enable_if? - Rob. -- ACCU - Professionalism in programming - http://www.accu.org

AMDG Robert Jones wrote:
Understood, but how would that be rewritten using lazy versions? It is more complicated than simply replacing enabe_if with lazy_enable_if?
template<class T> typename boost::enable_if<boost::is_arithmetic<T>, boost::mpl::identity<T> >::type foo(const T&); In Christ, Steven Watanabe
participants (2)
-
Robert Jones
-
Steven Watanabe