mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
fix: add guard for GCC <10.3 on C++20 (#5205)
* Update CI * update define guard * style: pre-commit fixes * updated define guard * style: pre-commit fixes * update guard * testing new guards * update guards * surely this time * style: pre-commit fixes * Define PYBIND11_TYPING_H_HAS_STRING_LITERAL to avoid repeating a complex expression. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
This commit is contained in:
committed by
GitHub
parent
e0f9e77466
commit
08f946a431
@@ -109,7 +109,7 @@ void m_defs(py::module_ &m) {
|
||||
|
||||
} // namespace handle_from_move_only_type_with_operator_PyObject
|
||||
|
||||
#if defined(__cpp_nontype_template_parameter_class)
|
||||
#if defined(PYBIND11_TYPING_H_HAS_STRING_LITERAL)
|
||||
namespace literals {
|
||||
enum Color { RED = 0, BLUE = 1 };
|
||||
|
||||
@@ -905,7 +905,7 @@ TEST_SUBMODULE(pytypes, m) {
|
||||
m.def("annotate_optional_to_object",
|
||||
[](py::typing::Optional<int> &o) -> py::object { return o; });
|
||||
|
||||
#if defined(__cpp_nontype_template_parameter_class)
|
||||
#if defined(PYBIND11_TYPING_H_HAS_STRING_LITERAL)
|
||||
py::enum_<literals::Color>(m, "Color")
|
||||
.value("RED", literals::Color::RED)
|
||||
.value("BLUE", literals::Color::BLUE);
|
||||
@@ -919,8 +919,8 @@ TEST_SUBMODULE(pytypes, m) {
|
||||
m.def("annotate_listT_to_T",
|
||||
[](const py::typing::List<typevar::TypeVarT> &l) -> typevar::TypeVarT { return l[0]; });
|
||||
m.def("annotate_object_to_T", [](const py::object &o) -> typevar::TypeVarT { return o; });
|
||||
m.attr("if_defined__cpp_nontype_template_parameter_class") = true;
|
||||
m.attr("defined_PYBIND11_TYPING_H_HAS_STRING_LITERAL") = true;
|
||||
#else
|
||||
m.attr("if_defined__cpp_nontype_template_parameter_class") = false;
|
||||
m.attr("defined_PYBIND11_TYPING_H_HAS_STRING_LITERAL") = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user