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
bd0bd943
Commit
bd0bd943
authored
Mar 28, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Yet more template parameter inference refinement.
parent
7dfa5d63
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
3 deletions
+9
-3
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-3
tests/run/cpp_template_functions.pyx
tests/run/cpp_template_functions.pyx
+2
-0
tests/run/cpp_template_functions_helper.h
tests/run/cpp_template_functions_helper.h
+4
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
bd0bd943
...
@@ -2265,7 +2265,7 @@ class CArrayType(CPointerBaseType):
...
@@ -2265,7 +2265,7 @@ class CArrayType(CPointerBaseType):
if
isinstance
(
actual
,
CArrayType
):
if
isinstance
(
actual
,
CArrayType
):
return
self
.
base_type
.
deduce_template_params
(
actual
.
base_type
)
return
self
.
base_type
.
deduce_template_params
(
actual
.
base_type
)
else
:
else
:
return
None
return
{}
def
can_coerce_to_pyobject
(
self
,
env
):
def
can_coerce_to_pyobject
(
self
,
env
):
return
self
.
base_type
.
can_coerce_to_pyobject
(
env
)
return
self
.
base_type
.
can_coerce_to_pyobject
(
env
)
...
@@ -2403,7 +2403,7 @@ class CPtrType(CPointerBaseType):
...
@@ -2403,7 +2403,7 @@ class CPtrType(CPointerBaseType):
if
isinstance
(
actual
,
CPtrType
):
if
isinstance
(
actual
,
CPtrType
):
return
self
.
base_type
.
deduce_template_params
(
actual
.
base_type
)
return
self
.
base_type
.
deduce_template_params
(
actual
.
base_type
)
else
:
else
:
return
None
return
{}
def
invalid_value
(
self
):
def
invalid_value
(
self
):
return
"1"
return
"1"
...
@@ -3516,7 +3516,7 @@ class CppClassType(CType):
...
@@ -3516,7 +3516,7 @@ class CppClassType(CType):
if
self
==
actual
:
if
self
==
actual
:
return
{}
return
{}
elif
actual
.
is_cpp_class
:
elif
actual
.
is_cpp_class
:
self_template_type
=
self
.
template_type
or
self
self_template_type
=
self
while
getattr
(
self_template_type
,
'template_type'
,
None
):
while
getattr
(
self_template_type
,
'template_type'
,
None
):
self_template_type
=
self_template_type
.
template_type
self_template_type
=
self_template_type
.
template_type
def
all_bases
(
cls
):
def
all_bases
(
cls
):
...
...
tests/run/cpp_template_functions.pyx
View file @
bd0bd943
...
@@ -15,6 +15,7 @@ cdef extern from "cpp_template_functions_helper.h":
...
@@ -15,6 +15,7 @@ cdef extern from "cpp_template_functions_helper.h":
int
overloaded
(
double
x
)
int
overloaded
(
double
x
)
T
overloaded
(
pair
[
T
,
T
])
T
overloaded
(
pair
[
T
,
T
])
U
overloaded
[
U
](
vector
[
U
])
U
overloaded
[
U
](
vector
[
U
])
X
overloaded
[
X
](
char
*
s
,
vector
[
X
])
cdef
T
nested_deduction
[
T
](
const
T
*
)
cdef
T
nested_deduction
[
T
](
const
T
*
)
pair
[
T
,
U
]
pair_arg
[
T
,
U
](
pair
[
T
,
U
]
a
)
pair
[
T
,
U
]
pair_arg
[
T
,
U
](
pair
[
T
,
U
]
a
)
cdef
T
*
pointer_param
[
T
](
T
*
)
cdef
T
*
pointer_param
[
T
](
T
*
)
...
@@ -114,5 +115,6 @@ def test_overload_GH1583():
...
@@ -114,5 +115,6 @@ def test_overload_GH1583():
assert
a
.
overloaded
(
p
)
==
2
assert
a
.
overloaded
(
p
)
==
2
cdef
vector
[
double
]
v
=
[
0.25
,
0.125
]
cdef
vector
[
double
]
v
=
[
0.25
,
0.125
]
assert
a
.
overloaded
(
v
)
==
0.25
assert
a
.
overloaded
(
v
)
==
0.25
assert
a
.
overloaded
(
"s"
,
v
)
==
0.25
# GH Issue #1584
# GH Issue #1584
# assert a.overloaded[double](v) == 0.25
# assert a.overloaded[double](v) == 0.25
tests/run/cpp_template_functions_helper.h
View file @
bd0bd943
...
@@ -39,6 +39,10 @@ class A {
...
@@ -39,6 +39,10 @@ class A {
U
overloaded
(
std
::
vector
<
U
>
v
)
{
U
overloaded
(
std
::
vector
<
U
>
v
)
{
return
v
[
0
];
return
v
[
0
];
}
}
template
<
typename
U
>
U
overloaded
(
char
*
c
,
std
::
vector
<
U
>
v
)
{
return
v
[
0
];
}
};
};
template
<
typename
T
>
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