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
e7074970
Commit
e7074970
authored
Apr 30, 2016
by
Wenzel Jakob
Browse files
restructured code in issues.cpp
parent
ffd85b46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
example/issues.cpp
example/issues.cpp
+11
-15
No files found.
example/issues.cpp
View file @
e7074970
...
...
@@ -10,20 +10,6 @@
#include "example.h"
#include <pybind11/stl.h>
struct
Base
{
virtual
void
dispatch
(
void
)
const
=
0
;
};
struct
DispatchIssue
:
Base
{
virtual
void
dispatch
(
void
)
const
{
PYBIND11_OVERLOAD_PURE
(
void
,
Base
,
dispatch
,
/* no arguments */
);
}
};
struct
Placeholder
{
int
i
;
Placeholder
(
int
i
)
:
i
(
i
)
{
}
};
void
dispatch_issue_go
(
const
Base
*
b
)
{
b
->
dispatch
();
}
void
init_issues
(
py
::
module
&
m
)
{
py
::
module
m2
=
m
.
def_submodule
(
"issues"
);
...
...
@@ -34,12 +20,22 @@ void init_issues(py::module &m) {
m2
.
def
(
"print_char"
,
[](
char
c
)
{
std
::
cout
<<
c
<<
std
::
endl
;
});
// #159: virtual function dispatch has problems with similar-named functions
struct
Base
{
virtual
void
dispatch
(
void
)
const
=
0
;
};
struct
DispatchIssue
:
Base
{
virtual
void
dispatch
(
void
)
const
{
PYBIND11_OVERLOAD_PURE
(
void
,
Base
,
dispatch
,
/* no arguments */
);
}
};
py
::
class_
<
DispatchIssue
>
base
(
m2
,
"DispatchIssue"
);
base
.
alias
<
Base
>
()
.
def
(
py
::
init
<>
())
.
def
(
"dispatch"
,
&
Base
::
dispatch
);
m2
.
def
(
"dispatch_issue_go"
,
&
dispatch_issue_go
);
m2
.
def
(
"dispatch_issue_go"
,
[](
const
Base
*
b
)
{
b
->
dispatch
();
});
struct
Placeholder
{
int
i
;
Placeholder
(
int
i
)
:
i
(
i
)
{
}
};
py
::
class_
<
Placeholder
>
(
m2
,
"Placeholder"
)
.
def
(
py
::
init
<
int
>
())
...
...
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