Commit 65b3aec3 authored by Kevin R. Thornton's avatar Kevin R. Thornton

add default templates to STL containers + rudimentary unit tests

parent 0fc1b3a2
cdef extern from "<deque>" namespace "std" nogil:
cdef cppclass deque[T]:
cdef cppclass deque[T,ALLOCATOR=*]:
cppclass iterator:
T& operator*()
iterator operator++()
......
cdef extern from "<list>" namespace "std" nogil:
cdef cppclass list[T]:
cdef cppclass list[T,ALLOCATOR=*]:
cppclass iterator:
iterator()
iterator(iterator &)
......
from .utility cimport pair
cdef extern from "<map>" namespace "std" nogil:
cdef cppclass map[T, U]:
cdef cppclass map[T, U,COMPARE=*,ALLOCATOR=*]:
cppclass iterator:
pair[T, U]& operator*()
iterator operator++()
......
from .utility cimport pair
cdef extern from "<unordered_set>" namespace "std" nogil:
cdef cppclass unordered_set[T]:
cdef cppclass unordered_set[T,HASH=*,PRED=*,ALLOCATOR=*]:
cppclass iterator:
T& operator*()
iterator operator++()
......
cdef extern from "<vector>" namespace "std" nogil:
cdef cppclass vector[T]:
cdef cppclass vector[T,ALLOCATOR=*]:
cppclass iterator:
T& operator*()
iterator operator++()
......
......@@ -107,3 +107,12 @@ cdef int ieps = numeric_limits[int].epsilon()
cdef int iqnan = numeric_limits[int].quiet_NaN()
cdef int isnan = numeric_limits[int].signaling_NaN()
cdef int iinf = numeric_limits[int].infinity()
#API checks for containers with std::allocator declared
from libcpp.memory cimport allocator
cdef libcpp.vector.vector[int,allocator[int]] vec_alloc_int = libcpp.vector.vector[int,allocator[int]](10,1)
assert vec_alloc_int.size() == 10
cdef libcpp.list.list[int,allocator[int]] list_alloc_int = libcpp.list.list[int,allocator[int]](10,1)
assert list_alloc_int.size() == 10
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