cpp_templates.pyx 603 Bytes
Newer Older
1 2
cdef extern from "templates.h":
    cdef cppclass TemplateTest1[T]:
3
        TemplateTest1()
4 5 6 7 8
        T value
        int t
        T getValue()

    cdef cppclass TemplateTest2[T, U]:
9
        TemplateTest2()
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
        T value1
        U value2
        T getValue1()
        U getValue2()

cdef TemplateTest1[int] a
cdef TemplateTest1[int]* b = new TemplateTest1[int]()

cdef int c = a.getValue()
c = b.getValue()

cdef TemplateTest2[int, char] d
cdef TemplateTest2[int, char]* e = new TemplateTest2[int, char]()

c = d.getValue1()
c = e.getValue2()

cdef char f = d.getValue2()
f = e.getValue2()
29 30

del b, e