Subject: Re: [boost] [result_of] now uses decltype on release branch
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2012-09-08 12:24:42
On Sep 8, 2012, at 12:02 PM, Michel Morin wrote:
> 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
Ah, that makes sense. I guess it's not surprising that this would be a well know problem to std lib implementers.
> 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
> 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.
I'm going to add a comment to the patch with a pointer to this thread in case someone in the future is interested in the history of the problem. Nice scholarship. Do you know of any previously proposed solutions to the SFINAE problem; e.g. alternative result_of implementations?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk