Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] trouble with transform
From: Michel Morin (mimomorin_at_[hidden])
Date: 2011-11-12 01:48:03


Try this

struct make_b {
   template<typename Sig> struct result;

    template <typename DS>
    struct result<make_b(DS)>
    {
        typedef typename DS::B type;
    };

   template <typename DS>
    struct result<make_b(DS const&)>
    {
        typedef typename DS::B type;
    };

   template <typename T>
    typename T::B
        operator()(T const& t) const { return t.make_b(); }
};

or this

struct make_b {
   template<typename Sig> struct result;

    template <typename This, typename DS>
    struct result<This(DS)>
    {
        typedef typename DS::B type;
    };

   template <typename This, typename DS>
    struct result<This(DS const&)>
    {
        typedef typename DS::B type;
    };

   template <typename T>
    typename T::B
        operator()(T const& t) const { return t.make_b(); }
};

The latter code would be more robust, because the code allows both of
boost::result_of<make_b(DS)> and boost::result_of<const make_b(DS)>.

Regards,
Michel


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