From 5d4beeb5cd7a7d9709d4d46766b0ba32071c5e9f Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 12 Jan 2026 16:02:01 -0500 Subject: [PATCH 1/2] fixup libint::any to handle copies of null objects correctly --- include/libint2/util/any.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/libint2/util/any.h b/include/libint2/util/any.h index 3df1baa93..e545fab95 100644 --- a/include/libint2/util/any.h +++ b/include/libint2/util/any.h @@ -68,7 +68,7 @@ class any { public: // this is constexpr in the standard any() : impl_(nullptr) {} - any(const any& other) : impl_(other.impl_->clone()) {} + any(const any& other) : impl_(other.impl_ ? other.impl_->clone() : nullptr) {} any(any&& other) = default; template > @@ -78,7 +78,7 @@ class any { ~any() = default; any& operator=(const any& rhs) { - impl_ = decltype(impl_)(rhs.impl_->clone()); + impl_ = decltype(impl_)(rhs.impl_ ? rhs.impl_->clone() : nullptr); return *this; } any& operator=(any&& rhs) { From f745471f218d4fe5afbb3c2b6393e875552e3e74 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 12 Jan 2026 16:02:10 -0500 Subject: [PATCH 2/2] always assume std::any is available if C++17 is available --- include/libint2/util/any.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/include/libint2/util/any.h b/include/libint2/util/any.h index e545fab95..f52ee0acf 100644 --- a/include/libint2/util/any.h +++ b/include/libint2/util/any.h @@ -29,23 +29,9 @@ // Include C++17 any header, if available AND functional #if __cplusplus >= 201703L -// macos < 10.14 do not have any_cast in their libc++ -#include // see https://stackoverflow.com/a/31658120 -#if defined(_LIBCPP_VERSION) && defined(__APPLE__) -#include -#ifdef __MAC_OS_X_VERSION_MIN_ALLOWED -#if __MAC_OS_X_VERSION_MIN_ALLOWED >= 10140 #define LIBINT_HAS_CXX17_ANY -#endif // 10.14 or later -#endif // have macos version -#else // libc++ on macos -#define LIBINT_HAS_CXX17_ANY -#endif // libc++ on macos -#endif // c++17 - -#ifdef LIBINT_HAS_CXX17_ANY #include -#endif +#endif // c++17 namespace libint2 {