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
d805e996
Unverified
Commit
d805e996
authored
Jun 30, 2024
by
Michael Carlstrom
Committed by
GitHub
Jun 30, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(types) Adds special Case for empty C++ tuple type annotation (#5214)
* add special case and unit test * add newline
parent
51c2aa16
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
include/pybind11/cast.h
+7
-0
tests/test_builtin_casters.py
+2
-0
No files found.
include/pybind11/cast.h
View file @
d805e996
...
@@ -740,6 +740,13 @@ class type_caster<std::pair<T1, T2>> : public tuple_caster<std::pair, T1, T2> {}
...
@@ -740,6 +740,13 @@ class type_caster<std::pair<T1, T2>> : public tuple_caster<std::pair, T1, T2> {}
template
<
typename
...
Ts
>
template
<
typename
...
Ts
>
class
type_caster
<
std
::
tuple
<
Ts
...
>>
:
public
tuple_caster
<
std
::
tuple
,
Ts
...
>
{};
class
type_caster
<
std
::
tuple
<
Ts
...
>>
:
public
tuple_caster
<
std
::
tuple
,
Ts
...
>
{};
template
<>
class
type_caster
<
std
::
tuple
<>>
:
public
tuple_caster
<
std
::
tuple
>
{
public
:
// PEP 484 specifies this syntax for an empty tuple
static
constexpr
auto
name
=
const_name
(
"tuple[()]"
);
};
/// Helper class which abstracts away certain actions. Users can provide specializations for
/// Helper class which abstracts away certain actions. Users can provide specializations for
/// custom holders, but it's only necessary if the type has a non-standard interface.
/// custom holders, but it's only necessary if the type has a non-standard interface.
template
<
typename
T
>
template
<
typename
T
>
...
...
tests/test_builtin_casters.py
View file @
d805e996
...
@@ -368,6 +368,8 @@ def test_tuple(doc):
...
@@ -368,6 +368,8 @@ def test_tuple(doc):
"""
"""
)
)
assert
doc
(
m
.
empty_tuple
)
==
"""empty_tuple() -> tuple[()]"""
assert
m
.
rvalue_pair
()
==
(
"rvalue"
,
"rvalue"
)
assert
m
.
rvalue_pair
()
==
(
"rvalue"
,
"rvalue"
)
assert
m
.
lvalue_pair
()
==
(
"lvalue"
,
"lvalue"
)
assert
m
.
lvalue_pair
()
==
(
"lvalue"
,
"lvalue"
)
assert
m
.
rvalue_tuple
()
==
(
"rvalue"
,
"rvalue"
,
"rvalue"
)
assert
m
.
rvalue_tuple
()
==
(
"rvalue"
,
"rvalue"
,
"rvalue"
)
...
...
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