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

config: decouple ENTT_NOEXCEPT and exceptions handling (close #867)

Michele Caini 3 лет назад
Родитель
Сommit
ef2f8a1a18
2 измененных файлов с 8 добавлено и 5 удалено
  1. 1 1
      TODO
  2. 7 4
      src/entt/config/config.h

+ 1 - 1
TODO

@@ -17,7 +17,7 @@ WIP:
 * entity-only and exclude-only views
 * custom allocators all over
 * remove storage::patch
-* use ENTT_NOEXCEPT_IF as appropriate (ie make compressed_pair conditionally noexcept)
+* consider removing ENTT_NOEXCEPT, use ENTT_NOEXCEPT_IF (or noexcept(...)) as appropriate in any case (ie make compressed_pair conditionally noexcept)
 
 WIP:
 * add user data to type_info

+ 7 - 4
src/entt/config/config.h

@@ -4,19 +4,22 @@
 #include "version.h"
 
 #if defined(__cpp_exceptions) && !defined(ENTT_NOEXCEPTION)
-#    define ENTT_NOEXCEPT noexcept
-#    define ENTT_NOEXCEPT_IF(expr) noexcept(expr)
 #    define ENTT_THROW throw
 #    define ENTT_TRY try
 #    define ENTT_CATCH catch(...)
 #else
-#    define ENTT_NOEXCEPT
-#    define ENTT_NOEXCEPT_IF(...)
 #    define ENTT_THROW
 #    define ENTT_TRY if(true)
 #    define ENTT_CATCH if(false)
 #endif
 
+#ifndef ENTT_NOEXCEPT
+#    define ENTT_NOEXCEPT noexcept
+#    define ENTT_NOEXCEPT_IF(expr) noexcept(expr)
+# else
+#    define ENTT_NOEXCEPT_IF(...)
+#endif
+
 #ifdef ENTT_USE_ATOMIC
 #    include <atomic>
 #    define ENTT_MAYBE_ATOMIC(Type) std::atomic<Type>