The code is distributed under the Boost Software License which isn’t viral as some others are said to be. (This is not part of Boost. The author just likes their permissive open-source license.)
All symbols are declared in the bignum namespace. The throw_overflow function is defined in bignum_common.cpp.
The code can be compiled with any C++ implementation that conforms to
enum rounding
{
all_to_neg_inf, all_to_pos_inf,
all_to_zero, all_away_zero,
all_to_even, all_to_odd,
tie_to_neg_inf, tie_to_pos_inf,
tie_to_zero, tie_away_zero,
tie_to_even, tie_to_odd
};
This enumeration is a subset of one proposed in WG21’s
P1889R1 §3.3. Note
that it’s unscoped, so the enumerators are in the bignum namespace.
This is used in the decimal and rational classes.
template<typename T> using is_bool = std::is_same<typename std::remove_cv<T>::type, bool>;
Whether T is a (possibly constand/or volatile) bool.
template<typename T> using is_flt = std::is_floating_point<T>;
Whether T is a fundamental floating point type.
template<typename T>
struct is_sgn : std::integral_constant<bool,
std::is_signed<T>::value && !is_flt<T>::value> { };
Whether T is a fundamental signed integral type.
template<typename T>
struct is_uns : std::integral_constant<bool,
std::is_unsigned<T>::value && !is_bool<T>::value> { };
Whether T is a fundamental unsigned type other than bool.
template<typename T>
struct is_int : std::integral_constant<bool,
is_sgn<T>::value || is_uns<T>::value> { };
Whether T is a fundamental integral type other than bool.
template<typename T> struct name
{
static constexpr char value[] = "unknown type";
};
template<> struct name<bool>
{
static constexpr char value[] = "bool";
};
And similar specializations for all of the usual fundamental arithmetic and character types
(including char8_t if you happen to be compiling with a C++ implementation
that conforms to [[noreturn]] void throw_overflow(const char*, const char*);This function is used internally by the integer, decimal and rational classes to report overflow when converting to fundamental types.
The first argument is expected to be the type that we’re converting from; the second argument
is expected to be the type that we’re converting to (probably one of the human-readable type names
above). This is used to create an informative