Boost logo

Boost Users :

Subject: Re: [Boost-users] Can not compile a program that uses typeof package by gcc?
From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2008-10-20 12:18:49

On Mon, Oct 20, 2008 at 11:14 AM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> Peng Yu wrote:
>> template <typename T1, typename T2>
>> struct multiply_traits;
>> template <typename T1, typename T2>
>> struct multiply_traits<X<T1>, T2> {
>> typedef X<T1> result_type;
>> };
> The most reliable way to define multiply_traits in general is
> template<class T>
> T make();
> template<class T1, class T2>
> struct multiply_traits {
> BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, make<T1>() * make<T2>());
> typedef typename nested::type type;
> };
>> Y<BOOST_TYPEOF(T1() * T2())> operator*(const Y<T1> &y, const T2 &t)
> You need to use BOOST_TYPEOF_TPL.
> Some compilers can handle this (I just tried it on msvc 9.0), but I strongly
> advise using multiply_traits as defined above for portability.

Does this mean the error that I saw is not due to a GCC bug? Or it is
due to a GCC bug, but most other compilers would have the same bug so
that I have to use your way as a walkaround?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at