Commit 8d47713c authored by Mark Florisson's avatar Mark Florisson

Add test for C++ template pointer casting and assignment

parent 8f91ac8b
......@@ -16,6 +16,12 @@ cdef extern from "cpp_templates_helper.h":
bint operator==(Pair[T1,T2])
bint operator!=(Pair[T1,T2])
cdef cppclass SuperClass[T1, T2]:
pass
cdef cppclass SubClass[T2, T3]:
pass
def test_int(int x, int y):
"""
>>> test_int(3, 4)
......@@ -88,3 +94,13 @@ def test_func_ptr(double x):
return w.get()(x)
finally:
del w
def test_cast_template_pointer():
"""
>>> test_cast_template_pointer()
"""
cdef SubClass[int, float] *sub = new SubClass[int, float]()
cdef SuperClass[int, float] *sup
sup = sub
sup = <SubClass[int, float] *> sub
......@@ -20,3 +20,13 @@ public:
bool operator==(Pair<T1,T2> other) { return _first == other._first && _second == other._second; }
bool operator!=(Pair<T1,T2> other) { return _first != other._first || _second != other._second; }
};
template <class T1, class T2>
class SuperClass {
public:
SuperClass() {}
};
template <class T2, class T3>
class SubClass : public SuperClass<T2, T3> {
};
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