$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-10-11 13:23:48
Brian McNamara wrote:
> On Sat, Oct 11, 2003 at 08:37:24PM +0300, Peter Dimov wrote:
>> Joel de Guzman wrote:
>>
>>> typedef result_of_plus<int, double>::type result;
>>
>> You should name that
>>
>> typedef result_of<plus(int, double)>::type result;
>>
>> instead. :-)
>
> There is a smiley, but seriously, if you did
>
> struct op_plus {
> template <class R> struct result;
> template <class F, class A1, class A2> struct result<F(A1,A2)> {
> typedef typename result_of_plus<A1,A2>::type type;
> };
> };
> // etc.
>
> then
>
> typedef result_of< op_plus(int, double) >::type result;
>
> would truly work. (Names like op_plus are just used as tags which
> stand for the corresponding C++ operators.)
Or even:
struct plus;
template<class A1, class A2> struct result_of<plus(A1, A2)>
{
// result_of_plus<A1, A2> goes here
};
struct plus
{
template<class A1, class A2> typename result_of<plus(A1, A2)>::type
operator()(A1 const & a1, A2 const & a2) { return a1 + a2; }
};
Which one is more "correct" is not clear. It's better to leave result_of
unspecialized if your wonderful TR1 implementation always does the right
thing. It's better to specialize it otherwise, since the nested result<>
forwarding sometimes "breaks" SFINAE.
Let's just hope that one day the proper decltype() will arrive and render
the issue moot.