|
Boost : |
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-05-21 11:00:06
On May 21, 2007, at 7:49 AM, Peter Dimov wrote:
> This special case is needed in situations such as:
>
> template<class F> struct X
> {
> F f_;
>
> result_of<F()>::type operator()() { return f_; }
>
> template<class A1>
> result_of<F(A1)>::type operator()(A1& a1) { return f_(a1); }
>
> // ...
> };
>
> where X can be instantiated with non-nullary function objects, or
> with types
> that aren't function objects at all, as in:
>
> X<int> x;
>
> The above instantiates the declaration of X::operator()(), which
> attempts to
> instantiate result_of<int()>, which would fail without the kludge.
Yep, this is exactly the reason.
> With variadic templates a special case is no longer necessary and I
> believe
> that the C++0x result_of no longer has one.
As soon as decltype gets in the language, result_of just "does the
right thing" without this (or any) kludges. The LWG has accepted the
appropriate change in principle, but of course it can't go in until
decltype goes in.
- Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk