mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Limit instantiation of GncInt128 constructors to integral values.
Instead of using static_assert. This prevents the compiler from even trying and avoids weird compilation errors when testing types for instantiating other templates.
This commit is contained in:
parent
23ca899a77
commit
eb24099a91
@ -90,38 +90,25 @@ enum // Values for m_flags
|
||||
*/
|
||||
/** Default constructor. Makes 0. */
|
||||
GncInt128();
|
||||
template <typename T>
|
||||
template <typename T,
|
||||
std::enable_if_t<std::is_integral<T>::value, bool> = true>
|
||||
GncInt128(T lower) : GncInt128(INT64_C(0), static_cast<int64_t>(lower))
|
||||
{
|
||||
static_assert (std::is_integral<T>(),
|
||||
"GncInt128 can be constructed only with "
|
||||
"integral arguments.");
|
||||
}
|
||||
{}
|
||||
GncInt128(uint64_t lower) : GncInt128 {UINT64_C(0), lower} {}
|
||||
/** Double-integer constructor template.
|
||||
*/
|
||||
template <typename T, typename U>
|
||||
template <typename T, typename U,
|
||||
std::enable_if_t<(std::is_integral<T>::value &&
|
||||
std::is_integral<U>::value), bool> = true>
|
||||
GncInt128(T upper, U lower, unsigned char flags = '\0') :
|
||||
GncInt128 {static_cast<int64_t>(upper),
|
||||
static_cast<int64_t>(lower), flags}
|
||||
{
|
||||
static_assert (std::is_integral<T>(),
|
||||
"GncInt128 can be constructed only with "
|
||||
"integral arguments.");
|
||||
static_assert (std::is_integral<U>(),
|
||||
"GncInt128 can be constructed only with "
|
||||
"integral arguments.");
|
||||
}
|
||||
static_cast<int64_t>(lower), flags} {}
|
||||
|
||||
GncInt128 (int64_t upper, int64_t lower, unsigned char flags = '\0');
|
||||
template <typename T>
|
||||
template <typename T,
|
||||
std::enable_if_t<std::is_integral<T>::value, bool> = true>
|
||||
GncInt128(T upper, uint64_t lower) :
|
||||
GncInt128 {static_cast<int64_t>(upper), lower}
|
||||
{
|
||||
static_assert (std::is_integral<T>(),
|
||||
"GncInt128 can be constructed only with "
|
||||
"integral arguments.");
|
||||
}
|
||||
GncInt128 {static_cast<int64_t>(upper), lower} {}
|
||||
|
||||
GncInt128 (int64_t upper, uint64_t lower, unsigned char flags = '\0');
|
||||
GncInt128 (uint64_t upper, uint64_t lower, unsigned char flags = '\0');
|
||||
|
Loading…
Reference in New Issue
Block a user