Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
52238cb9
Commit
52238cb9
authored
Feb 11, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Adding messages to terse `static_assert`s, for pre-C++17 compatibility.
parent
87369106
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+19
-5
No files found.
include/pybind11/pybind11.h
View file @
52238cb9
...
...
@@ -1291,13 +1291,27 @@ public:
static
constexpr
bool
type_caster_type_is_smart_holder_type_caster
=
detail
::
is_smart_holder_type_caster
<
type
>::
value
;
static
constexpr
bool
type_caster_type_is_type_caster_base_subtype
=
std
::
is_base_of
<
detail
::
type_caster_base
<
type
>
,
detail
::
type_caster
<
type
>>::
value
;
// Necessary conditions, but not strict.
static_assert
(
!
(
detail
::
is_instantiation
<
std
::
unique_ptr
,
holder_type
>::
value
&&
type_caster_type_is_smart_holder_type_caster
));
static_assert
(
!
(
detail
::
is_instantiation
<
std
::
shared_ptr
,
holder_type
>::
value
&&
type_caster_type_is_smart_holder_type_caster
));
static_assert
(
!
(
holder_is_smart_holder
&&
type_caster_type_is_type_caster_base_subtype
));
static_assert
(
!
(
detail
::
is_instantiation
<
std
::
unique_ptr
,
holder_type
>::
value
&&
type_caster_type_is_smart_holder_type_caster
),
"py::class_ holder vs type_caster mismatch:"
" missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, std::unique_ptr<T>)?"
);
static_assert
(
!
(
detail
::
is_instantiation
<
std
::
shared_ptr
,
holder_type
>::
value
&&
type_caster_type_is_smart_holder_type_caster
),
"py::class_ holder vs type_caster mismatch:"
" missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, std::shared_ptr<T>)?"
);
static_assert
(
!
(
holder_is_smart_holder
&&
type_caster_type_is_type_caster_base_subtype
),
"py::class_ holder vs type_caster mismatch:"
" missing PYBIND11_SMART_HOLDER_TYPE_CASTERS(T)?"
);
#ifdef PYBIND11_STRICT_ASSERTS_CLASS_HOLDER_VS_TYPE_CASTER_MIX
// Strict conditions cannot be enforced universally at the moment (PR #2836).
static_assert
(
holder_is_smart_holder
==
type_caster_type_is_smart_holder_type_caster
);
static_assert
(
!
holder_is_smart_holder
==
type_caster_type_is_type_caster_base_subtype
);
static_assert
(
holder_is_smart_holder
==
type_caster_type_is_smart_holder_type_caster
,
"py::class_ holder vs type_caster mismatch:"
" missing PYBIND11_SMART_HOLDER_TYPE_CASTERS(T)"
" or collision with custom py::detail::type_caster<T>?"
);
static_assert
(
!
holder_is_smart_holder
==
type_caster_type_is_type_caster_base_subtype
,
"py::class_ holder vs type_caster mismatch:"
" missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, ...)"
" or collision with custom py::detail::type_caster<T>?"
);
#endif
type_record
record
;
record
.
scope
=
scope
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment