1# mode: run 2# tag: cpp, werror 3 4from cython.operator cimport dereference as deref 5 6cdef extern from "cpp_templates_helper.h": 7 cdef cppclass Wrap[T]: 8 Wrap(T) 9 void set(T) 10 T get() 11 bint operator==(Wrap[T]) 12 13 cdef cppclass Pair[T1,T2]: 14 Pair(T1,T2) 15 T1 first() 16 T2 second() 17 bint operator==(Pair[T1,T2]) 18 bint operator!=(Pair[T1,T2]) 19 20def test_wrap_pair(int i, double x): 21 """ 22 >>> test_wrap_pair(1, 1.5) 23 (1, 1.5, True) 24 >>> test_wrap_pair(2, 2.25) 25 (2, 2.25, True) 26 """ 27 try: 28 wrap = new Wrap[Pair[int, double]](Pair[int, double](i, x)) 29 return wrap.get().first(), wrap.get().second(), deref(wrap) == deref(wrap) 30 finally: 31 del wrap 32 33def test_wrap_pair_pair(int i, int j, double x): 34 """ 35 >>> test_wrap_pair_pair(1, 3, 1.5) 36 (1, 3, 1.5, True) 37 >>> test_wrap_pair_pair(2, 5, 2.25) 38 (2, 5, 2.25, True) 39 """ 40 try: 41 wrap = new Wrap[Pair[int, Pair[int, double]]]( 42 Pair[int, Pair[int, double]](i,Pair[int, double](j, x))) 43 return (wrap.get().first(), 44 wrap.get().second().first(), 45 wrap.get().second().second(), 46 deref(wrap) == deref(wrap)) 47 finally: 48 del wrap 49