Boost logo

Boost :

Subject: [boost] [spirit/karma] missing specialization for char types in numeric_utils.hpp
From: Robert.Macketanz_at_[hidden]
Date: 2009-12-02 03:25:19


Hi,

while testing some stuff using the karma generator like this

>>>
template <typername T> void do_calculations()
{
  char buf [65]; // this is enough to display any of the numbers
    T val = value_getter();

    char * ptr = buf;
    boost::spirit::karma::generate( ptr, boost::spirit::karma::int_, val );
    *ptr='\0';
   std::cout << buf << std::endl;
}
<<<
the compiler (MSVC 2005) gave me errors when T was any of the "char" family
about ambiguous overloads for "fabs()".

After adding the lines
        BOOST_SPIRIT_ABSOLUTE_VALUE(signed char, unsigned char);
        BOOST_SPIRIT_ABSOLUTE_VALUE(char, unsigned char);
and
        BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(unsigned char);
in boost\spirit\home\karma\numeric\detail\numeric_utils.hpp

, the problem went away. (This is with boost 1.41.0)

I am not sure if this is the proper way to fix this or whether we'd need to
regard the possibly different implementations for "char" in various
compilers.
If this really fuixes this bug, could anyone please commit the changes to
the next release?

Cheers,
Robert


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