Boost Users :
Subject: Re: [Boost-users] Can not compile a program that uses typeofpackage by gcc?
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-10-23 08:28:11
> On Wed, Oct 22, 2008 at 9:28 PM, Steven Watanabe <watanabesj_at_[hidden]>
>> Peng Yu wrote:
>>> Because of a bug in GCC, BOOST_TYPEOF (which essentially is a macro
>>> for 'typeof') does not work for the attached code. I tried GCC 4.1.1,
>>> somebody else tried GCC 4.3.0. Neither of them work for the attached
>> What attached code?
> Sorry, I forgot to attach the code. Here is the attached code.
This is not what Steven meant. It was probably the use of the term "traits"
that threw you away. multiply_traits is not a traits class; it's just an
implementation detail that places a level of indirection between typeof and
Wherever you need to use
BOOST_TYPEOF( T1() * T2() )
in a function signature, you replace it with
template<class T1, class T2> struct multiply_helper
typedef BOOST_TYPEOF( T1() * T2() ) type;
Nobody specializes multiply_helper. It just moves the typeof a bit to
satisfy the compiler.
The underlying reason for all this dance is that compilers cannot mangle an
arbitrary expression into a function name, and typeof allows one to put
arbitrary expressions in signatures.
-- Peter Dimov http://www.pdplayer.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