Boost logo

Boost Users :

From: pbristow_at_[hidden]
Date: 2020-05-18 13:30:41


From: Boost-users <boost-users-bounces_at_[hidden]> On Behalf Of A.Dmitrovsky via Boost-users
Sent: 15 May 2020 11:03
To: boost-users_at_[hidden]
Cc: A.Dmitrovsky <tdiff_at_[hidden]>
Subject: [Boost-users] [Multiprecision] number conversion to __int128

Hi,
 
Boost::multiprecision docs [1] mentions that the type parameter of number::convert_to method should be "fundamental", pointing to the list of standard types ('A number can be converted to any https://en.cppreference.com/w/cpp/language/types type)'.
This is different to number::convert_to reference [2], which states that "Type T may be any arithmetic type".
 
Can [unsigned] __int128 be treated as "fundamental" on compilers/platforms which support it?
 
[1] https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html
[2] https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_multiprecision/ref/number.html

Does

“
  *Interconversions between number types of the same family are allowed and are implicit conversions if no loss of precision is involved, and explicit if it is:
  â€¦

"

In https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html

Not cover your case _uint128 ? and thus allowed for conversion.

Even if the _uint* and _int* types are not fundamental builtin types (regrettably - blame the glacial process of C and C++ standardization and the millstone of C (don't ask) - but they might as well be for most purposes, including this one).

HTH

Paul


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