gnucash master: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sun Oct 2 14:45:57 EDT 2022
Updated via https://github.com/Gnucash/gnucash/commit/eb24099a (commit)
via https://github.com/Gnucash/gnucash/commit/23ca899a (commit)
from https://github.com/Gnucash/gnucash/commit/a6e2842e (commit)
commit eb24099a915b6bacc090b2a216b476abf7e01785
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Sep 17 15:47:05 2022 -0700
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.
diff --git a/libgnucash/engine/gnc-int128.hpp b/libgnucash/engine/gnc-int128.hpp
index 67c88d64a..db463fad8 100644
--- a/libgnucash/engine/gnc-int128.hpp
+++ b/libgnucash/engine/gnc-int128.hpp
@@ -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');
commit 23ca899a77c10c60740269b38c15fb22690c8a64
Author: John Ralls <jralls at ceridwen.us>
Date: Wed Sep 14 17:39:21 2022 -0700
Fix build on Apple Silicon or maybe Apple-clang-14.0
The compiler complains that there's no matching
gnc_register_number_range_option for GncOptionDB*, which without this
commit is true because the explicit templates are for GncOptionDBPtr&.
Note that the original template definition is for GncOptionDB* and
that the header-defined inlines that take GncOptionDBPtr& call the
GncOptionDB* version.
diff --git a/libgnucash/engine/gnc-optiondb.cpp b/libgnucash/engine/gnc-optiondb.cpp
index 0a2d82caf..3d1decc6c 100644
--- a/libgnucash/engine/gnc-optiondb.cpp
+++ b/libgnucash/engine/gnc-optiondb.cpp
@@ -1312,11 +1312,11 @@ gnc_option_db_lookup_qofinstance_value(GncOptionDB* odb, const char* section,
}
// Force creation of templates
-template void gnc_register_number_range_option(GncOptionDBPtr& db,
+template void gnc_register_number_range_option(GncOptionDB* db,
const char* section, const char* name,
const char* key, const char* doc_string,
int value, int min, int max, int step);
-template void gnc_register_number_range_option(GncOptionDBPtr& db,
+template void gnc_register_number_range_option(GncOptionDB* db,
const char* section, const char* name,
const char* key, const char* doc_string,
double value, double min,
Summary of changes:
libgnucash/engine/gnc-int128.hpp | 33 ++++++++++-----------------------
libgnucash/engine/gnc-optiondb.cpp | 4 ++--
2 files changed, 12 insertions(+), 25 deletions(-)
More information about the gnucash-changes
mailing list