Boost logo

Boost :

Subject: Re: [boost] [result_of] now uses decltype on release branch
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-09-08 12:02:12


Daniel Walker wrote:
>> Not a small number of people have complained about the disability of
>> std/boost::result_of for SFINAE.
>
> Where has this come up before? I just don't remember. It would be
> interesting to know the history of this problem.

I learned this problem from this blog post:
(Note: written in Japanese
 http://d.hatena.ne.jp/gintenlabo/20110420/1303288950 )
This post listed defects in FDIS. One of them is that some meta-functions
(std::result_of and common_type) cannot be used for SFINAE.

On gcc bugzilla, Paolo Carlini said the following
( http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50711 )

  Unfortunately, I don't think you can use std::result_of for sfinae purposes,
  if I understand correctly it's a well know annoyance which you have to
  overcome by open coding with std::declval.

  Eg, if you simply open the <functional> header you will find plenty of
  decltype( std::declval... for sfinae, which cannot be replaced by a concise
  std::result_of

Also, quick google finds an old boost-user ML post:
( http://thread.gmane.org/gmane.comp.lib.boost.user/9967/focus=10030 )

  From: Ian McCulloch
  Subject: Re: result_of tutorial
  Date: 2005-03-17 08:22:29 GMT

  Thanks Peter, I think I understand how it works now. Unfortunately, the
  lack of SFINAE is a real showstopper for me. I want to write functions
  like

  template <typename T>
  typename result_of<negate(T)>::type
  operator-(T const& x)
  {
     return negate()(x);
  }

  but the lack of SFINAE here makes boost::result_of essentially useless for
  this. But I imagine it won't be difficult to make a new version based on
  boost that would work.

Regards,
Michel


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