
Peng Yu:
On Wed, Oct 22, 2008 at 9:28 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
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 code.
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 the signature. Wherever you need to use BOOST_TYPEOF( T1() * T2() ) in a function signature, you replace it with typename multiply_helper<T1,T2>::type where 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