Просмотр исходного кода

config: removed ENTT_NOEXCEPT, added ENTT_NOEXCEPTION

Michele Caini 4 лет назад
Родитель
Сommit
ca34309f75
2 измененных файлов с 14 добавлено и 6 удалено
  1. 5 5
      docs/md/config.md
  2. 9 1
      src/entt/config/config.h

+ 5 - 5
docs/md/config.md

@@ -7,7 +7,7 @@
 
 * [Introduction](#introduction)
 * [Definitions](#definitions)
-  * [ENTT_NOEXCEPT](#entt_noexcept)
+  * [ENTT_NOEXCEPTION](#entt_noexcept)
   * [ENTT_USE_ATOMIC](#entt_use_atomic)
   * [ENTT_ID_TYPE](#entt_id_type)
   * [ENTT_SPARSE_PAGE](#entt_sparse_page)
@@ -38,11 +38,11 @@ Each parameter can result in internal library definitions. It's not recommended
 to try to also modify these definitions, since there is no guarantee that they
 will remain stable over time unlike the options below.
 
-## ENTT_NOEXCEPT
+## ENTT_NOEXCEPTION
 
-The purpose of this parameter is to suppress the use of `noexcept` by this
-library.<br/>
-To do this, simply define the variable without assigning any value to it.
+This parameter can be used to switch off exception handling in `EnTT`.<br/>
+To do this, simply define the variable without assigning any value to it. This
+is roughly equivalent to setting the compiler flag `-ff-noexceptions`.
 
 ## ENTT_USE_ATOMIC
 

+ 9 - 1
src/entt/config/config.h

@@ -2,8 +2,16 @@
 #define ENTT_CONFIG_CONFIG_H
 
 
-#ifndef ENTT_NOEXCEPT
+#if defined(__cpp_exceptions) && !defined(ENTT_NOEXCEPTION)
 #   define ENTT_NOEXCEPT noexcept
+#   define ENTT_THROW throw
+#   define ENTT_TRY try
+#   define ENTT_CATCH catch(...)
+#else
+#   define ENTT_NOEXCEPT
+#   define ENTT_THROW
+#   define ENTT_TRY if(true)
+#   define ENTT_CATCH if(false)
 #endif