From d0e5daf4412e90674866a09951457865c3fa8209 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Fri, 15 Nov 2019 12:11:44 -0800 Subject: [PATCH] fix ctad warning in llvm --- include/gsl/pointers | 9 ++++++++- tests/no_exception_ensure_tests.cpp | 2 +- tests/no_exception_throw_tests.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index 7373826..2520f9e 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -100,7 +100,7 @@ public: constexpr operator T() const { return get(); } constexpr T operator->() const { return get(); } - constexpr decltype(auto) operator*() const { return *get(); } + constexpr decltype(auto) operator*() const { return *get(); } // prevents compilation when someone attempts to assign a null pointer constant not_null(std::nullptr_t) = delete; @@ -119,6 +119,13 @@ private: T ptr_; }; +#if (defined(__cplusplus) && (__cplusplus >= 201703L)) +// deduction guide to prevent the ctad-maybe-unsupported warning +template +not_null(T ptr) -> not_null; + +#endif (defined(__cplusplus) && (__cplusplus >= 201703L)) + template auto make_not_null(T&& t) { return not_null>>{std::forward(t)}; diff --git a/tests/no_exception_ensure_tests.cpp b/tests/no_exception_ensure_tests.cpp index b1ae15b..2ec0ebb 100644 --- a/tests/no_exception_ensure_tests.cpp +++ b/tests/no_exception_ensure_tests.cpp @@ -28,7 +28,7 @@ int operator_subscript_no_throw() noexcept void setup_termination_handler() noexcept { -#if defined(_MSC_VER) +#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) auto& handler = gsl::details::get_terminate_handler(); handler = &test_terminate; diff --git a/tests/no_exception_throw_tests.cpp b/tests/no_exception_throw_tests.cpp index b28ad00..ddb6b07 100644 --- a/tests/no_exception_throw_tests.cpp +++ b/tests/no_exception_throw_tests.cpp @@ -28,7 +28,7 @@ int narrow_no_throw() void setup_termination_handler() noexcept { -#if defined(_MSC_VER) +#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) auto& handler = gsl::details::get_terminate_handler(); handler = &test_terminate;