Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-10-30 22:03:13


Eric Niebler wrote:
> Richard Crossley wrote:
> >
> > http://article.gmane.org/gmane.comp.lib.boost.user/14256
> >
> > I ended up giving up with result_of assuming I must be misunderstanding
> > something as I never got any response.
> >
>
> It appears to be the same issue. I added your much simpler test case to
> the bug report. Thanks. Sadly, giving up on result_of is not really an
> option -- it's standard, now. I hope we can find a work-around.

Ah-ha! I've found a work-around for this problem. If you have code like
this:

template<typename T>
struct Foo
{
   template<typename Sig> struct result;
   template<typename This, typename A>
   struct result<This(A)>
   {
     typedef A type;
   };
   ...
}

... you must transform it into something like this:

template<typename T>
struct msvc_Foo_result
{
   template<typename Sig> struct result;
   template<typename This, typename A>
   struct result<This(A)>
   {
     typedef A type;
   };
};

template<typename T>
struct Foo : msvc_Foo_result<T>
{
   ...
};

Then you can do result_of<Foo<int>(float)>::type, and MSVC is happy. It
only appears to be a problem when Foo is a template. MSVC won't deduce
This to be Foo<int> within the Foo template itself, but it WILL deduce
This to be Foo<int> in msvc_Foo_result<int>.

Go figure.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk