From 88c6d93a7527e41d294edcd61f17973115b7da50 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Thu, 24 Sep 2020 14:04:48 +0100 Subject: [PATCH] Use MARISA_DEBUG_IF in scoped-*.h as opposed to MARISA_THROW_IF These are the only two places that we throw exceptions from header files in non-debug mode. With this change, developers can take the marisa library without being forced to enable exceptions for their whole library / application. IMO, self-reset does not seem to be fatal enough to throw in production and MARISA_DEBUG_IF should be enough for us to catch it if we think it should never happen. --- include/marisa/scoped-array.h | 2 +- include/marisa/scoped-ptr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/marisa/scoped-array.h b/include/marisa/scoped-array.h index 12b5b9e..34cefa4 100644 --- a/include/marisa/scoped-array.h +++ b/include/marisa/scoped-array.h @@ -16,7 +16,7 @@ class scoped_array { } void reset(T *array = NULL) { - MARISA_THROW_IF((array != NULL) && (array == array_), MARISA_RESET_ERROR); + MARISA_DEBUG_IF((array != NULL) && (array == array_), MARISA_RESET_ERROR); scoped_array(array).swap(*this); } diff --git a/include/marisa/scoped-ptr.h b/include/marisa/scoped-ptr.h index 63d7a3d..abf48d8 100644 --- a/include/marisa/scoped-ptr.h +++ b/include/marisa/scoped-ptr.h @@ -16,7 +16,7 @@ class scoped_ptr { } void reset(T *ptr = NULL) { - MARISA_THROW_IF((ptr != NULL) && (ptr == ptr_), MARISA_RESET_ERROR); + MARISA_DEBUG_IF((ptr != NULL) && (ptr == ptr_), MARISA_RESET_ERROR); scoped_ptr(ptr).swap(*this); }