Boost logo

Boost Users :

Subject: Re: [Boost-users] Is 'double' a signed type? (boost type traits)
From: Mika Fischer (mika.fischer_at_[hidden])
Date: 2012-12-21 10:13:03


On Fri, Dec 21, 2012 at 2:14 PM, cdmh <cdm.henderson_at_[hidden]> wrote:
> (v11). I used boost::is_signed<T>::value where T is double and it evaluates
> to false, but I expected true as double can hold negative numbers.

Quoting the documentation for boost::is_unsigned [1]:
"Inherits: If T is an signed integer type or an enumerated type with
an underlying signed integer type, then inherits from true_type,
otherwise inherits from false_type."

So, boost::is_signed will only ever be true for integer types (and
similarly for is_unsigned). You might want to additionally use
boost::is_floating_point, as AFAIK, there are no unsigned floating
point types.

Best,
 Mika

[1] http://www.boost.org/doc/libs/1_52_0/libs/type_traits/doc/html/boost_typetraits/reference/is_signed.html


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