Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-19 12:08:43


Ian McCulloch wrote:
> Peter Dimov wrote:
>
>> Peter Dimov wrote:
>>> Ian McCulloch wrote:
>>>> Peter Dimov wrote:
>>>
>>> [...]
>>>
>>>> I don't get it: can't you detect whether
>>>> nested::result<nested(T)>::type exists? As long as the primary
>>>> template of nested::result is defined as an empty struct this
>>>> should work fine(?).
>>>
>>> No, consider what happens when 'nested' is int (*) (), for example.
>>
>> Hm, it can't be int (*) (), because result_of will not attempt to
>> look for a nested result, but it can be an user-defined type with no
>> nested result, or a member named result.
>
> Wouldn't both those cases (no nested result, or a member named
> result) cause a substitution failure?

Allowed but not required by 14.8.2/2, I think.

> template <typename T>
> typename T::result<T(int)>::type
> func(T const& x)
> {
> std::cout << "func(T const&)\n";
> return typename T::result<T(int)>::type();
> }

There should be a "template" before "result".

> This compiles cleanly with g++ 3.3.4

Yes, it also works on MSVC 7.1 and (with "template" added before "result")
on Comeau 4.3.0.1 strict, so it seems that this is a "supported" case of
substitution failure. However tr1::result_of implementations aren't required
to use this trick (which, to the best of my knowledge, hasn't been
publicized anywhere so far) to not generate errors when
::result<F(Ai...)>::type is not defined, and boost::result_of doesn't,
either.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net