Boost logo

Boost Users :

From: Andy Little (andy_at_[hidden])
Date: 2006-01-20 10:50:18


Hi all,

Using gcc3.2 the concatenation of 1##Num where Num is negative leaves a space
eg 1e#-1 --> 1e -1 as can be seen by the preprocessed output below. The only
way round it that I can see is to simply not use a macro for this compiler
Is there a preprocessor workaround for this problem? Is this even the correct
behaviour?
Any help appreciated.

#define POW_EVAL(Num, Float_type)\
       template <>\
       struct pow_eval< \
            Float_type BOOST_PP_COMMA() Num BOOST_PP_COMMA()\
             1 BOOST_PP_COMMA() false\
>{\
           enum{ required = true};\
           typedef Float_type result_type;\
           result_type operator()()const\
           { result_type result\
                = static_cast< Float_type > (1e ## Num);\
                return result;\
            }\
       };

POW_EVAL(-60, double)
POW_EVAL(-59, double)
POW_EVAL(58, double)
POW_EVAL(57, double)

// preprocessor output

template <> struct pow_eval< double , -60 , 1 , false >{ enum{ required = true};
typedef double result_type; result_type operator()()const { result_type result =
static_cast< double > (1e- 60); return result; } };
template <> struct pow_eval< double , -59 , 1 , false >{ enum{ required = true};
typedef double result_type; result_type operator()()const { result_type result =
static_cast< double > (1e- 59); return result; } };
template <> struct pow_eval< double , 58 , 1 , false >{ enum{ required = true};
typedef double result_type; result_type operator()()const { result_type result =
static_cast< double > (1e58); return result; } };
template <> struct pow_eval< double , 57 , 1 , false >{ enum{ required = true};
typedef double result_type; result_type operator()()const { result_type result =
static_cast< double > (1e57); return result; } };

regards
Andy Little


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