Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
d9f49c83
Commit
d9f49c83
authored
Jan 17, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding & using PYBIND11_CLASSH_TYPE_CASTERS define.
parent
87d26bf1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
20 deletions
+19
-20
include/pybind11/detail/classh_type_casters.h
+18
-0
tests/test_classh_wip.cpp
+1
-20
No files found.
include/pybind11/detail/classh_type_casters.h
View file @
d9f49c83
...
...
@@ -374,5 +374,23 @@ struct classh_type_caster<std::unique_ptr<T const>> : smart_holder_type_caster_l
operator
std
::
unique_ptr
<
T
const
>
()
{
return
this
->
loaded_as_unique_ptr
();
}
};
#define PYBIND11_CLASSH_TYPE_CASTERS(T) \
namespace pybind11 { \
namespace detail { \
template <> \
class type_caster<T> : public classh_type_caster<T> {}; \
template <> \
class type_caster<std::shared_ptr<T>> : public classh_type_caster<std::shared_ptr<T>> {}; \
template <> \
class type_caster<std::shared_ptr<T const>> \
: public classh_type_caster<std::shared_ptr<T const>> {}; \
template <> \
class type_caster<std::unique_ptr<T>> : public classh_type_caster<std::unique_ptr<T>> {}; \
template <> \
class type_caster<std::unique_ptr<T const>> \
: public classh_type_caster<std::unique_ptr<T const>> {}; \
} \
}
}
// namespace detail
}
// namespace pybind11
tests/test_classh_wip.cpp
View file @
d9f49c83
...
...
@@ -49,26 +49,7 @@ std::unique_ptr<mpty> unique_ptr_roundtrip(std::unique_ptr<mpty> obj) { return o
}
// namespace classh_wip
}
// namespace pybind11_tests
namespace
pybind11
{
namespace
detail
{
using
mpty
=
pybind11_tests
::
classh_wip
::
mpty
;
template
<>
class
type_caster
<
mpty
>
:
public
classh_type_caster
<
mpty
>
{};
template
<>
class
type_caster
<
std
::
shared_ptr
<
mpty
>>
:
public
classh_type_caster
<
std
::
shared_ptr
<
mpty
>>
{};
template
<>
class
type_caster
<
std
::
shared_ptr
<
mpty
const
>>
:
public
classh_type_caster
<
std
::
shared_ptr
<
mpty
const
>>
{};
template
<>
class
type_caster
<
std
::
unique_ptr
<
mpty
>>
:
public
classh_type_caster
<
std
::
unique_ptr
<
mpty
>>
{};
template
<>
class
type_caster
<
std
::
unique_ptr
<
mpty
const
>>
:
public
classh_type_caster
<
std
::
unique_ptr
<
mpty
const
>>
{};
}
// namespace detail
}
// namespace pybind11
PYBIND11_CLASSH_TYPE_CASTERS
(
pybind11_tests
::
classh_wip
::
mpty
)
namespace
pybind11_tests
{
namespace
classh_wip
{
...
...
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