Commit 8baa9dba authored by Lars Buitinck's avatar Lars Buitinck

fix nested C++ template syntax

parent 07c422a5
...@@ -3153,10 +3153,8 @@ class CppClassType(CType): ...@@ -3153,10 +3153,8 @@ class CppClassType(CType):
if for_display: if for_display:
brackets = "[%s]" brackets = "[%s]"
else: else:
brackets = "<%s>" brackets = "<%s> "
templates = brackets % ",".join(template_strings) templates = brackets % ",".join(template_strings)
if templates[-2:] == ">>":
templates = templates[:-2] + "> >"
else: else:
templates = "" templates = ""
if pyrex or for_display: if pyrex or for_display:
......
...@@ -16,6 +16,8 @@ cdef extern from "templates.h": ...@@ -16,6 +16,8 @@ cdef extern from "templates.h":
T getValue1() T getValue1()
U getValue2() U getValue2()
void template_function[T](TemplateTest1[T] &)
cdef TemplateTest1[int] a cdef TemplateTest1[int] a
cdef TemplateTest1[int]* b = new TemplateTest1[int]() cdef TemplateTest1[int]* b = new TemplateTest1[int]()
...@@ -39,3 +41,11 @@ cdef TemplateTest1_int aa ...@@ -39,3 +41,11 @@ cdef TemplateTest1_int aa
# Verify that T767 is fixed. # Verify that T767 is fixed.
cdef public int func(int arg): cdef public int func(int arg):
return arg return arg
# Regression test: the function call used to produce
# template_function<TemplateTest1<int>>(__pyx_v_t);
# which is valid C++11, but not valid C++98 because the ">>" would be
# parsed as a single token.
cdef public void use_nested_templates():
cdef TemplateTest1[TemplateTest1[int]] t
template_function(t)
...@@ -22,4 +22,9 @@ public: ...@@ -22,4 +22,9 @@ public:
U getValue2() { return value2; } U getValue2() { return value2; }
}; };
template <typename T>
void template_function(TemplateTest1<T> &)
{
}
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment