Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
19d5dd91
Commit
19d5dd91
authored
Dec 04, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test of parital specialization type parameter deduction.
parent
50e2d48e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
tests/run/cpp_template_functions.pyx
tests/run/cpp_template_functions.pyx
+12
-0
tests/run/cpp_template_functions_helper.h
tests/run/cpp_template_functions_helper.h
+4
-0
No files found.
tests/run/cpp_template_functions.pyx
View file @
19d5dd91
...
...
@@ -8,6 +8,7 @@ cdef extern from "cpp_template_functions_helper.h":
cdef
pair
[
T
,
U
]
two_params
[
T
,
U
](
T
,
U
)
cdef
cppclass
A
[
T
]:
pair
[
T
,
U
]
method
[
U
](
T
,
U
)
U
part_method
[
U
](
pair
[
T
,
U
])
cdef
T
nested_deduction
[
T
](
const
T
*
)
pair
[
T
,
U
]
pair_arg
[
T
,
U
](
pair
[
T
,
U
]
a
)
cdef
T
*
pointer_param
[
T
](
T
*
)
...
...
@@ -43,6 +44,17 @@ def test_method(int x, int y):
return
a_int
.
method
[
float
](
x
,
y
),
a_double
.
method
[
int
](
x
,
y
)
# return a_int.method[double](x, y), a_double.method[int](x, y)
def
test_part_method
(
int
x
,
int
y
):
"""
>>> test_part_method(5, 10)
(10.0, 10)
"""
cdef
A
[
int
]
a_int
cdef
pair
[
int
,
double
]
p_int
=
(
x
,
y
)
cdef
A
[
double
]
a_double
cdef
pair
[
double
,
int
]
p_double
=
(
x
,
y
)
return
a_int
.
part_method
(
p_int
),
a_double
.
part_method
(
p_double
)
def
test_simple_deduction
(
int
x
,
double
y
):
"""
>>> test_simple_deduction(1, 2)
...
...
tests/run/cpp_template_functions_helper.h
View file @
19d5dd91
...
...
@@ -20,6 +20,10 @@ class A {
std
::
pair
<
T
,
U
>
method
(
T
a
,
U
b
)
{
return
std
::
pair
<
T
,
U
>
(
a
,
b
);
}
template
<
typename
U
>
U
part_method
(
std
::
pair
<
T
,
U
>
p
)
{
return
p
.
second
;
}
};
template
<
typename
T
>
...
...
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