Boost logo

Boost :

From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2003-12-05 16:12:18


Is this what you have in mind?

#ifndef BOOST_NO_SFINAE

  // real enable_if

#else

  template<class T> struct enable_if {
    BOOST_STATIC_ASSERT(false); // enable_if is known not to work
  };

  // same for enable_if_c, lazy_enable_if, ...

#endif

  Jaakko & Jeremiah

On Fri, 5 Dec 2003, Jonathan D. Turkanis wrote:

> "Jaakko Jarvi" <jajarvi_at_[hidden]> wrote in message
> news:Pine.LNX.4.53.0312051058570.9894_at_damogran.osl.iu.edu...
> > > Can we add conditional preprocessor guards around the contents of the
> > > enable_if.hpp header so that the templates are only defined on
> > > supporting compilers?
> > >
> >
> > Ok, I'm guarding it with BOOST_NO_SFINAE, then any use of enable_if on
> > a compiler which does not support SFINAE is an error.
> > This is the safe way, (compared to providing dummy definitions that
> > do not give the desired behavior).
> >
> > Jaakko
>
> This could lead to very uninformative compiler errors if someone tries
> to use enable_if on an unsupported compiler. I tried it on VC6 and found
> that if enable_if is used without explicit namespace qualification I
> don't get a single error which clearly states that enable_if is not defined.
>
> This might have been a reason to write enable_if without partial
> specialization, even though no compiler supports SFINAE but not partial
> spec. A static assert could inform users that SFINAE is not available.
>
> The dummies with static asserts might be a good alternative, to avoid
> complicating the main definitions.
>
> Jonathan
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk