From 18c5600eac7aec2cc9789537f64083adea644dc6 Mon Sep 17 00:00:00 2001 From: Terry Cojean Date: Thu, 4 May 2023 19:16:10 +0200 Subject: [PATCH] Adapt to `std::uncaught_exception()` deprecation --- cuda/base/pointer_mode_guard.hpp | 5 +++-- hip/base/pointer_mode_guard.hip.hpp | 5 +++-- include/ginkgo/core/base/std_extensions.hpp | 11 +++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cuda/base/pointer_mode_guard.hpp b/cuda/base/pointer_mode_guard.hpp index 713affa3d68..005febb96d3 100644 --- a/cuda/base/pointer_mode_guard.hpp +++ b/cuda/base/pointer_mode_guard.hpp @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include namespace gko { @@ -79,7 +80,7 @@ class pointer_mode_guard { ~pointer_mode_guard() noexcept(false) { /* Ignore the error during stack unwinding for this call */ - if (std::uncaught_exception()) { + if (xstd::uncaught_exception()) { cublasSetPointerMode(*l_handle, CUBLAS_POINTER_MODE_DEVICE); } else { GKO_ASSERT_NO_CUBLAS_ERRORS( @@ -126,7 +127,7 @@ class pointer_mode_guard { ~pointer_mode_guard() noexcept(false) { /* Ignore the error during stack unwinding for this call */ - if (std::uncaught_exception()) { + if (xstd::uncaught_exception()) { cusparseSetPointerMode(l_handle, CUSPARSE_POINTER_MODE_DEVICE); } else { GKO_ASSERT_NO_CUSPARSE_ERRORS( diff --git a/hip/base/pointer_mode_guard.hip.hpp b/hip/base/pointer_mode_guard.hip.hpp index 2ad996bd439..681839ec9e2 100644 --- a/hip/base/pointer_mode_guard.hip.hpp +++ b/hip/base/pointer_mode_guard.hip.hpp @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include namespace gko { @@ -81,7 +82,7 @@ class pointer_mode_guard { ~pointer_mode_guard() noexcept(false) { /* Ignore the error during stack unwinding for this call */ - if (std::uncaught_exception()) { + if (xstd::uncaught_exception()) { hipblasSetPointerMode(reinterpret_cast(l_handle), HIPBLAS_POINTER_MODE_DEVICE); } else { @@ -131,7 +132,7 @@ class pointer_mode_guard { ~pointer_mode_guard() noexcept(false) { /* Ignore the error during stack unwinding for this call */ - if (std::uncaught_exception()) { + if (xstd::uncaught_exception()) { hipsparseSetPointerMode( reinterpret_cast(l_handle), HIPSPARSE_POINTER_MODE_DEVICE); diff --git a/include/ginkgo/core/base/std_extensions.hpp b/include/ginkgo/core/base/std_extensions.hpp index c7bfa96f397..460460178e5 100644 --- a/include/ginkgo/core/base/std_extensions.hpp +++ b/include/ginkgo/core/base/std_extensions.hpp @@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_ +#include #include #include #include @@ -69,6 +70,16 @@ template using void_t = typename detail::make_void::type; +// Disable deprecation warnings when using standard > 2014 +inline bool uncaught_exception() noexcept { +#if __cplusplus > 201402L + return std::uncaught_exceptions() > 0; +#else + return std::uncaught_exception(); +#endif +} + + // Kept for backward compatibility. template using enable_if_t = std::enable_if_t;