Boost logo

Boost :

From: Sergey Shandar (sergey_at_[hidden])
Date: 2007-11-10 05:58:55


Giovanni Piero Deretta wrote:
> Wow! Does this really work? You can really apply SFINAE to conversion
> opreators by
> (ab)using the exception specification? Is this only a gcc thing or is
> it "by the standard"?
>
It works on GCC and solves the particular problem, I don't know much
about other compilers and "by the standard". It has to be checked if we
want to use it in other cases.
> If the latter, boost::enable_if documents might need to be updated :)
>
Yes, may be some extensions to the boost::enable_if library:

  namespace boost
  {
  namespace detail
  {
  class never_throw
  {
  };
  }
  }

  #define BOOST_ENABLE_IF(...) throw (typename ::boost::enable_if<
    __VA_ARGS__, ::boost::detail::never_throw>::type)

And using:

  template <class T>
  T foo(T t)
    BOOST_ENABLE_IF(boost::is_arithmetic<T>)
  {
    ...
  }

etc.


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