Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-08-08 17:22:06


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net