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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
a8e96fd3
Commit
a8e96fd3
authored
Jan 20, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A couple more template inference fixes.
parent
9361decf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-0
tests/run/cpp_template_functions.pyx
tests/run/cpp_template_functions.pyx
+17
-0
tests/run/cpp_template_functions_helper.h
tests/run/cpp_template_functions_helper.h
+11
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
a8e96fd3
...
...
@@ -3517,6 +3517,8 @@ class CppClassType(CType):
return
{}
elif
actual
.
is_cpp_class
:
self_template_type
=
self
.
template_type
or
self
while
getattr
(
self_template_type
,
'template_type'
,
None
):
self_template_type
=
self_template_type
.
template_type
def
all_bases
(
cls
):
yield
cls
for
parent
in
cls
.
base_classes
:
...
...
tests/run/cpp_template_functions.pyx
View file @
a8e96fd3
...
...
@@ -2,6 +2,7 @@
cimport
cython
from
libcpp.pair
cimport
pair
from
libcpp.vector
cimport
vector
cdef
extern
from
"cpp_template_functions_helper.h"
:
cdef
T
no_arg
[
T
]()
...
...
@@ -11,6 +12,9 @@ cdef extern from "cpp_template_functions_helper.h":
pair
[
T
,
U
]
method
[
U
](
T
,
U
)
U
part_method
[
U
](
pair
[
T
,
U
])
U
part_method_ref
[
U
](
pair
[
T
,
U
]
&
)
int
overloaded
(
double
x
)
T
overloaded
(
pair
[
T
,
T
])
U
overloaded
[
U
](
vector
[
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
*
)
...
...
@@ -99,3 +103,16 @@ def test_inference(int k):
res
=
one_param
(
&
k
)
assert
cython
.
typeof
(
res
)
==
'int *'
,
cython
.
typeof
(
res
)
return
res
[
0
]
def
test_overload_GH1583
():
"""
>>> test_overload_GH1583()
"""
cdef
A
[
int
]
a
assert
a
.
overloaded
(
1.5
)
==
1
cdef
pair
[
int
,
int
]
p
=
(
2
,
3
)
assert
a
.
overloaded
(
p
)
==
2
cdef
vector
[
double
]
v
=
[
0.25
,
0.125
]
assert
a
.
overloaded
(
v
)
==
0.25
# GH Issue #1584
# assert a.overloaded[double](v) == 0.25
tests/run/cpp_template_functions_helper.h
View file @
a8e96fd3
...
...
@@ -28,6 +28,17 @@ class A {
U
part_method_ref
(
const
std
::
pair
<
T
,
U
>&
p
)
{
return
p
.
second
;
}
int
overloaded
(
double
d
)
{
return
(
int
)
d
;
}
T
overloaded
(
std
::
pair
<
T
,
T
>
p
)
{
return
p
.
first
;
}
template
<
typename
U
>
U
overloaded
(
std
::
vector
<
U
>
v
)
{
return
v
[
0
];
}
};
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