diff options
-rw-r--r-- | gc_cpp.cc | 12 | ||||
-rw-r--r-- | include/gc_allocator.h | 5 | ||||
-rw-r--r-- | include/gc_cpp.h | 4 | ||||
-rw-r--r-- | tests/test_cpp.cc | 3 |
4 files changed, 13 insertions, 11 deletions
@@ -50,12 +50,12 @@ built-in "new" and "delete". # endif # ifdef GC_NEW_DELETE_NEED_THROW -# if __cplusplus < 201703L -# define GC_DECL_NEW_THROW throw(std::bad_alloc) -# else - // The "dynamic exception" syntax was deprecated in C++11 - // and removed in C++17. +# if __cplusplus >= 201703L || _MSVC_LANG >= 201703L + // The "dynamic exception" syntax had been deprecated in C++11 + // and was removed in C++17. # define GC_DECL_NEW_THROW noexcept(false) +# else +# define GC_DECL_NEW_THROW throw(std::bad_alloc) # endif # else # define GC_DECL_NEW_THROW /* empty */ @@ -111,7 +111,7 @@ built-in "new" and "delete". } # endif // GC_OPERATOR_NEW_ARRAY -# if __cplusplus > 201103L // C++14 +# if __cplusplus >= 201402L || _MSVC_LANG >= 201402L // C++14 void operator delete(void* obj, size_t size) GC_NOEXCEPT { (void)size; // size is ignored GC_FREE(obj); diff --git a/include/gc_allocator.h b/include/gc_allocator.h index eceb5a42..df580437 100644 --- a/include/gc_allocator.h +++ b/include/gc_allocator.h @@ -44,7 +44,8 @@ #include <new> // for placement new and bad_alloc #ifndef GC_ATTR_EXPLICIT -# if (__cplusplus >= 201103L) && !defined(__clang__) || defined(CPPCHECK) +# if __cplusplus >= 201103L && !defined(__clang__) || _MSVC_LANG >= 201103L \ + || defined(CPPCHECK) # define GC_ATTR_EXPLICIT explicit # else # define GC_ATTR_EXPLICIT /* empty */ @@ -65,7 +66,7 @@ # ifndef GC_NEW_ABORTS_ON_OOM # define GC_NEW_ABORTS_ON_OOM # endif -# elif __cplusplus >= 201103L +# elif __cplusplus >= 201103L || _MSVC_LANG >= 201103L # define GC_NOEXCEPT noexcept # else # define GC_NOEXCEPT throw() diff --git a/include/gc_cpp.h b/include/gc_cpp.h index e2c062de..90cd36aa 100644 --- a/include/gc_cpp.h +++ b/include/gc_cpp.h @@ -182,7 +182,7 @@ by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined. # ifndef GC_NEW_ABORTS_ON_OOM # define GC_NEW_ABORTS_ON_OOM # endif -# elif __cplusplus >= 201103L +# elif __cplusplus >= 201103L || _MSVC_LANG >= 201103L # define GC_NOEXCEPT noexcept # else # define GC_NOEXCEPT throw() @@ -342,7 +342,7 @@ inline void* operator new(size_t size, GC_NS_QUALIFY(GCPlacement) gcp, GC_FREE(obj); } -# if __cplusplus > 201103L // C++14 +# if __cplusplus >= 201402L || _MSVC_LANG >= 201402L // C++14 inline void operator delete(void* obj, size_t size) GC_NOEXCEPT { (void)size; // size is ignored GC_FREE(obj); diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index 3ee951e4..a9165a96 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -76,7 +76,8 @@ extern "C" { exit( 1 ); } #ifndef GC_ATTR_EXPLICIT -# if (__cplusplus >= 201103L) && !defined(__clang__) || defined(CPPCHECK) +# if __cplusplus >= 201103L && !defined(__clang__) || _MSVC_LANG >= 201103L \ + || defined(CPPCHECK) # define GC_ATTR_EXPLICIT explicit # else # define GC_ATTR_EXPLICIT /* empty */ |