mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-01-27 07:02:10 +00:00
61 lines
2.2 KiB
Plaintext
61 lines
2.2 KiB
Plaintext
[/
|
|
Copyright 2011 - 2020 John Maddock.
|
|
Copyright 2013 - 2019 Paul A. Bristow.
|
|
Copyright 2013 Christopher Kormanyos.
|
|
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE_1_0.txt or copy at
|
|
http://www.boost.org/LICENSE_1_0.txt).
|
|
]
|
|
|
|
[section:internals Internal Support Code]
|
|
|
|
There are some traits classes which authors of new backends should be aware of:
|
|
|
|
namespace boost{ namespace multiprecision{ namespace detail{
|
|
|
|
template<typename From, typename To>
|
|
struct is_explicitly_convertible;
|
|
|
|
}}}
|
|
|
|
Inherits from `boost::integral_constant<bool,true>` if type `From` has an explicit conversion from `To`.
|
|
|
|
For compilers that support C++11 SFINAE-expressions this trait should "just work". Otherwise it inherits
|
|
from `boost::is_convertible<From, To>::type`, and will need to be specialised for Backends that have
|
|
constructors marked as `explicit`.
|
|
|
|
template <class From, class To>
|
|
struct is_lossy_conversion
|
|
{
|
|
static const bool value = see below;
|
|
};
|
|
|
|
Member `value` is true if the conversion from `From` to `To` would result in a loss of precision, and `false` otherwise.
|
|
|
|
The default version of this trait simply checks whether the ['kind] of conversion (for example from a floating-point to an integer type)
|
|
is inherently lossy. Note that if either of the types `From` or `To` are of an unknown number category (because `number_category` is not
|
|
specialised for that type) then this trait will be `true`.
|
|
|
|
template<typename From, typename To>
|
|
struct is_restricted_conversion
|
|
{
|
|
static const bool value = see below;
|
|
};
|
|
|
|
Member `value` is `true` if `From` is only explicitly convertible to `To` and not implicitly convertible, or
|
|
if `is_lossy_conversion<From, To>::value` is `true`. Otherwise `false`.
|
|
|
|
Note that while this trait is the ultimate arbiter of which constructors are marked as `explicit` in class `number`,
|
|
authors of backend types should generally specialise one of the traits above, rather than this one directly.
|
|
|
|
template <class T>
|
|
is_signed_number;
|
|
template <class T>
|
|
is_unsigned_number;
|
|
|
|
These two traits inherit from either `mpl::true_` or `mpl::false_`, by default types are assumed to be signed unless
|
|
`is_unsigned_number` is specialized for that type.
|
|
|
|
[endsect]
|