
On Apr 27, 2013, at 12:40 PM, "Peter Dimov"
Daniel Walker wrote:
On Apr 21, 2013, at 10:36 PM, Peter Dimov
wrote: I can't think of a reason to ever use TR1 (and whichever version of > result_of) in C++11. Even less so in C++14, which will have deduced > return types unless the N3638 formal motion failed, and I very much hope > it did not.
Agreed, and we recommend in the boost::result_of documentation that C++11 users use std::result_of rather than boost::result_of.
I actually meant that C++11 users should use decltype directly rather than result_of.
A library that wanted to support both would do something like
template<...>
#if C++11
auto f(...) -> decltype(...)
#else
boost::result_of<...>::type f(...)
#endif
{ ... }
That's not very nice as it forces you to write everything twice, but it keeps C++11 users isolated from anything C++03-related. In particular, it no longer matters whether boost::result_of works with lambdas. (Well... it could matter if decltype is not N32whatever but lambdas work fine, but ideally, it shouldn't.)
Yeah, this could work for some folks in some situations. But there are also all those containers out there that have been generated to store results from some function. I know I've seen code like the following over the years.
template