Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
b40ce578
Commit
b40ce578
authored
Feb 13, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
DEBUGGING_MSVC_2015: implemening is_smart_holder_type_caster based on std::is_base_of.
parent
cd9e99ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
+17
-16
include/pybind11/cast.h
include/pybind11/cast.h
+16
-15
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+1
-1
No files found.
include/pybind11/cast.h
View file @
b40ce578
...
@@ -1218,19 +1218,11 @@ struct smart_holder_type_caster_class_hooks {
...
@@ -1218,19 +1218,11 @@ struct smart_holder_type_caster_class_hooks {
}
}
};
};
template
<
typename
T
>
template
<
typename
T
,
typename
SFINAE
=
void
>
struct
is_smart_holder_type_caster
{
struct
is_smart_holder_type_caster
{
static
constexpr
bool
value
=
false
;
};
#ifndef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
static
constexpr
bool
value
=
false
;
#else
static
constexpr
bool
value
=
true
;
#endif
};
template
<
typename
T
>
template
<
typename
T
>
inline
bool
check_is_smart_holder_type_caster
()
{
inline
bool
check_is_smart_holder_type_caster
();
return
detail
::
is_smart_holder_type_caster
<
T
>::
value
;
}
template
<
typename
T
>
template
<
typename
T
>
struct
smart_holder_type_caster_load
{
struct
smart_holder_type_caster_load
{
...
@@ -1638,8 +1630,6 @@ struct smart_holder_type_caster<std::unique_ptr<T const, D>>
...
@@ -1638,8 +1630,6 @@ struct smart_holder_type_caster<std::unique_ptr<T const, D>>
namespace pybind11 { \
namespace pybind11 { \
namespace detail { \
namespace detail { \
template <> \
template <> \
struct is_smart_holder_type_caster<T> { static constexpr bool value = true; }; \
template <> \
class type_caster<T> : public smart_holder_type_caster<T> {}; \
class type_caster<T> : public smart_holder_type_caster<T> {}; \
template <> \
template <> \
class type_caster<std::shared_ptr<T>> : public smart_holder_type_caster<std::shared_ptr<T>> { \
class type_caster<std::shared_ptr<T>> : public smart_holder_type_caster<std::shared_ptr<T>> { \
...
@@ -1671,8 +1661,6 @@ template <typename T> class type_caster_for_class_ : public type_caster_base<T>
...
@@ -1671,8 +1661,6 @@ template <typename T> class type_caster_for_class_ : public type_caster_base<T>
namespace pybind11 { \
namespace pybind11 { \
namespace detail { \
namespace detail { \
template <> \
template <> \
struct is_smart_holder_type_caster<T> { static constexpr bool value = false; }; \
template <> \
class type_caster<T> : public type_caster_base<T> {}; \
class type_caster<T> : public type_caster_base<T> {}; \
template <> \
template <> \
class type_caster<__VA_ARGS__> : public type_caster_holder<T, __VA_ARGS__> {}; \
class type_caster<__VA_ARGS__> : public type_caster_holder<T, __VA_ARGS__> {}; \
...
@@ -1704,6 +1692,19 @@ template <typename type, typename SFINAE = void> class type_caster : public type
...
@@ -1704,6 +1692,19 @@ template <typename type, typename SFINAE = void> class type_caster : public type
template
<
typename
type
>
using
make_caster
=
type_caster
<
intrinsic_t
<
type
>>
;
template
<
typename
type
>
using
make_caster
=
type_caster
<
intrinsic_t
<
type
>>
;
template
<
typename
T
>
struct
is_smart_holder_type_caster
<
T
,
typename
std
::
enable_if
<
std
::
is_base_of
<
smart_holder_type_caster_class_hooks
,
make_caster
<
T
>>::
value
>::
type
>
{
static
constexpr
bool
value
=
true
;
};
template
<
typename
T
>
inline
bool
check_is_smart_holder_type_caster
()
{
return
detail
::
is_smart_holder_type_caster
<
T
>::
value
;
}
// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
template
<
typename
T
>
typename
make_caster
<
T
>::
template
cast_op_type
<
T
>
cast_op
(
make_caster
<
T
>
&
caster
)
{
template
<
typename
T
>
typename
make_caster
<
T
>::
template
cast_op_type
<
T
>
cast_op
(
make_caster
<
T
>
&
caster
)
{
return
caster
.
operator
typename
make_caster
<
T
>::
template
cast_op_type
<
T
>();
return
caster
.
operator
typename
make_caster
<
T
>::
template
cast_op_type
<
T
>();
...
...
include/pybind11/pybind11.h
View file @
b40ce578
...
@@ -1286,7 +1286,7 @@ public:
...
@@ -1286,7 +1286,7 @@ public:
none_of
<
std
::
is_same
<
multiple_inheritance
,
Extra
>
...
>::
value
),
// no multiple_inheritance attr
none_of
<
std
::
is_same
<
multiple_inheritance
,
Extra
>
...
>::
value
),
// no multiple_inheritance attr
"Error: multiple inheritance bases must be specified via class_ template options"
);
"Error: multiple inheritance bases must be specified via class_ template options"
);
# if
0
# if
1
static
constexpr
bool
holder_is_smart_holder
=
std
::
is_same
<
holder_type
,
smart_holder
>::
value
;
static
constexpr
bool
holder_is_smart_holder
=
std
::
is_same
<
holder_type
,
smart_holder
>::
value
;
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_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
;
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
;
...
...
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