Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-02-06 21:31:33


Hi Andy,

"Andy Little" <andy_at_[hidden]> wrote

> I have been testing out replacing my return type deduction scheme in
signatures
> with typeof. see code and errors at the end.

I've seen this kind of problem before. It exists in gcc in both native and
compliant mode, and can be workarounded by factoring out typeof invocation
into a separate template, something like this:

template<class T, class T1>
struct wknd
{
    typedef BOOST_TYPEOF_TPL(T(1) + T1(1)) type;
};

template <typename T>
class udt{
    T m_value;
public:
    T get_value()const{ return m_value;}
    udt():m_value(0){}
    explicit udt(T const & in) : m_value(in){}
    template <typename T1>
        udt<typename wknd<T, T1>::type>
        operator +( udt<T1> const & in)const
    {
        typedef udt<typename wknd<T, T1>::type> result_type;
        result_type result(m_value + in.get_value());
        return result;
    }
};

With this fix it seems to be compiling OK in both compliant and native mode
(mingw 3.4.2)

Regards,
Arkadiy


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