Subject: Re: [boost] [result_of] Make `cpp0x_result_of_impl` public
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-03-27 21:29:44
> >>> Why not implement boost::result_of using decltype only on compilers that have N3256 decltype,
> >>> and give users with compilers that have non-N3256 decltype the option of turning on
> >>> BOOST_RESULT_OF_USE_DECLTYPE?
> > I think Nate's suggestion is reasonable. Boost libraries which require N3256 can use tr1::result_of, so that they are more portable to non-standard compilers and do not break as easily when users request decltype-based boost::result_of, which, of course, is a perfectly reasonable request.
> I should say that Nate's suggestion *is* reasonable, but (IIUC) he's not
> suggesting turning on decltype-based result_of for non-N3256 compilers,
> as you are (right?).
(By the way, as I just realized after a search for "N3256" turned up an unrelated paper,
it's N3276, not N3256).
You are right, I was not suggesting turning on decltype-based result_of for non-N3276
compilers by default. People with non-N3276 compilers can choose to turn on
decltype-based result_of with BOOST_RESULT_OF_USE_DECLTYPE.
> His suggestion is pretty much The Plan and has been
> all along. He's merely questioning the need for an additional
> cxx11_result_of. I think it has value for people with who want to
> selectively use decltype-based result_of in their code where they know
> it is safe, regardless of whether a compiler implements N3256.
> But now that I rethink this, the use of cxx11_result_of anywhere
> necessarily makes such code non-portable to c++03 compilers, so it'll
> probably never be used within Boost. It could only be used (a) by
> Boost's users who (b) have compilers that support decltype and (c) don't
> support N3256 and (d) don't have a std::result_of that uses decltype.
> I'm pretty sure that's exactly zero people.
One could write a result_of_for_complete_types_only (with a better name of course :) )
that is implemented using decltype on all C++11 compilers (including non-N3276), and
using the TR1 protocol on others. This would then be backward-compatible to C++03,
and Boost could use it in some places.
I have been using a non-N3276 C++11 compiler, and turning on
BOOST_RESULT_OF_USE_DECLTYPE, for about a year now, and I haven't run into a
situation where I need N3276. The advantage of such a
"result_of_for_complete_types_only" for someone like me would be that if I ever do
run into a situation like that, and my compiler still does not support N3276 at that point,
so I need to turn BOOST_RESULT_OF_USE_DECLTYPE *off*, then I wouldn't need to
implement the result_of protocol for *all* my function objects, only *some* (the ones
used by Boost features that use result_of rather than result_of_for_complete_types_only).
That seems like a fairly small advantage to me, for which Boost maintains would have
to do a fair bit of work, which is why I'm suggesting not to bother with it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk