From 0f042a8da67890868e9aafac0662b33b9a7741bc Mon Sep 17 00:00:00 2001 From: ObeliskGate Date: Fri, 23 Aug 2024 12:59:08 +0800 Subject: [PATCH 1/3] fix: use `__cpp_nontype_template_args` instead of gnu extensions --- include/pybind11/typing.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/pybind11/typing.h b/include/pybind11/typing.h index b0feb9464a..7c6aea2dea 100644 --- a/include/pybind11/typing.h +++ b/include/pybind11/typing.h @@ -100,9 +100,7 @@ class Never : public none { using none::none; }; -#if defined(__cpp_nontype_template_parameter_class) \ - && (/* See #5201 */ !defined(__GNUC__) \ - || (__GNUC__ > 10 || (__GNUC__ == 10 && __GNUC_MINOR__ >= 3))) +#if defined(__cpp_nontype_template_args) # define PYBIND11_TYPING_H_HAS_STRING_LITERAL template struct StringLiteral { From f114df8b596cbd7adffdc36a8e69a4a34961e1d0 Mon Sep 17 00:00:00 2001 From: ObeliskGate Date: Fri, 23 Aug 2024 13:01:39 +0800 Subject: [PATCH 2/3] fix: add feature test value --- include/pybind11/typing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/typing.h b/include/pybind11/typing.h index 7c6aea2dea..84aaf9f702 100644 --- a/include/pybind11/typing.h +++ b/include/pybind11/typing.h @@ -100,7 +100,7 @@ class Never : public none { using none::none; }; -#if defined(__cpp_nontype_template_args) +#if defined(__cpp_nontype_template_args) && __cpp_nontype_template_args >= 201911L # define PYBIND11_TYPING_H_HAS_STRING_LITERAL template struct StringLiteral { From 761b9cd48c91fdeb1a7e33dfb34382ee853c727e Mon Sep 17 00:00:00 2001 From: ObeliskGate Date: Fri, 23 Aug 2024 13:34:02 +0800 Subject: [PATCH 3/3] fix: change `PYBIND11_TYPING_H_HAS_STRING_LITERAL` skip reason --- tests/test_pytypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index 218092b434..a75dce5090 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -1026,7 +1026,7 @@ def test_optional_object_annotations(doc): @pytest.mark.skipif( not m.defined_PYBIND11_TYPING_H_HAS_STRING_LITERAL, - reason="C++20 feature not available.", + reason="C++20 non-type template args feature not available.", ) def test_literal(doc): assert ( @@ -1037,7 +1037,7 @@ def test_literal(doc): @pytest.mark.skipif( not m.defined_PYBIND11_TYPING_H_HAS_STRING_LITERAL, - reason="C++20 feature not available.", + reason="C++20 non-type template args feature not available.", ) def test_typevar(doc): assert (