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 1/6] 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; From 4610f26b33525ad17153b8dc5d754cf254fa33c6 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Fri, 15 Nov 2019 12:43:33 -0800 Subject: [PATCH 2/6] forgot comment --- include/gsl/pointers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index 2520f9e..f1c831e 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -124,7 +124,7 @@ private: template not_null(T ptr) -> not_null; -#endif (defined(__cplusplus) && (__cplusplus >= 201703L)) +#endif // (defined(__cplusplus) && (__cplusplus >= 201703L)) template auto make_not_null(T&& t) { From 8e481ebe19e1113fddfeeaa6734cb58a5ae1b69f Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Fri, 15 Nov 2019 14:41:38 -0800 Subject: [PATCH 3/6] adding deduction guide for strict_not_null --- include/gsl/pointers | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index f1c831e..f96d064 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -119,13 +119,6 @@ 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)}; @@ -279,6 +272,16 @@ auto make_strict_not_null(T&& t) { return strict_not_null>>{std::forward(t)}; } +#if (defined(__cplusplus) && (__cplusplus >= 201703L)) + +// deduction guides to prevent the ctad-maybe-unsupported warning +template +not_null(T ptr) -> not_null; +template +strict_not_null(T ptr) -> strict_not_null; + +#endif // (defined(__cplusplus) && (__cplusplus >= 201703L)) + } // namespace gsl namespace std From 128b4356ac1dbd4babc911a0a2544acd097b1dbc Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Fri, 15 Nov 2019 16:29:41 -0800 Subject: [PATCH 4/6] changing check from __cplusplus 201703L to __cpp_deduction_guides 201907L --- include/gsl/pointers | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index f96d064..ae6f8c5 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -272,15 +272,13 @@ auto make_strict_not_null(T&& t) { return strict_not_null>>{std::forward(t)}; } -#if (defined(__cplusplus) && (__cplusplus >= 201703L)) +#if (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201907L)) // deduction guides to prevent the ctad-maybe-unsupported warning -template -not_null(T ptr) -> not_null; -template -strict_not_null(T ptr) -> strict_not_null; +template not_null(T) -> not_null; +template strict_not_null(T) -> strict_not_null; -#endif // (defined(__cplusplus) && (__cplusplus >= 201703L)) +#endif // (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201907L)) } // namespace gsl From a7759e6d3f7514f70ed698dc05f8369d9278c69c Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Mon, 18 Nov 2019 10:14:05 -0800 Subject: [PATCH 5/6] lower __cpp_deduction_guide version number from 201907 to 201611 --- include/gsl/pointers | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index ae6f8c5..bc6a91c 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -272,13 +272,13 @@ auto make_strict_not_null(T&& t) { return strict_not_null>>{std::forward(t)}; } -#if (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201907L)) +#if (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L)) // deduction guides to prevent the ctad-maybe-unsupported warning template not_null(T) -> not_null; template strict_not_null(T) -> strict_not_null; -#endif // (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201907L)) +#endif // (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L)) } // namespace gsl From 263440f2a10cf016b0ab18071508b6fde4ebdfc6 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Mon, 18 Nov 2019 11:39:36 -0800 Subject: [PATCH 6/6] changing white-space in comment to get tests to rerun --- include/gsl/pointers | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index bc6a91c..7afed1c 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -272,13 +272,13 @@ auto make_strict_not_null(T&& t) { return strict_not_null>>{std::forward(t)}; } -#if (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L)) +#if ( defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L) ) // deduction guides to prevent the ctad-maybe-unsupported warning template not_null(T) -> not_null; template strict_not_null(T) -> strict_not_null; -#endif // (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L)) +#endif // ( defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L) ) } // namespace gsl