Boost logo

Boost Users :

Subject: Re: [Boost-users] [result_of]
From: Eric Niebler (eric_at_[hidden])
Date: 2009-10-26 10:06:47


er wrote:
> If G derives privately from F,
> and F::result_type is defined,
> but I provide, say, G::result<F1(T)>,
>
> boost::result_of<G(T)>::type attempts to access the private
> F::result_type, instead of G::result<G(T)>::type.
>
> I guess, if I really want to keep F a private base, I could wrap it in a
> class, W<F>, that does not expose result_type, yet I'm hoping someone
> might have a better idea.

The only solution I can think of is to (partially) specialize
boost::result_of directly, as below ...

   #include <boost/utility/result_of.hpp>

   struct B
   {
     typedef void result_type;
   };

   struct D : private B
   {
     template<class S>
     struct result
     {
       typedef int type;
     };
   };

   namespace boost
   {
     template<typename T>
     struct result_of<D(T)> : D::result<D(T)> {};

     template<typename T>
     struct result_of<D const(T)> : D::result<D const(T)> {};

     // For completeness, specialize for D volatile and
     // D const volatile, too.
   }

   int main()
   {
     typedef boost::result_of<D(int)>::type t;
   }

HTH,

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

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