Commit a0d13cb1 authored by Stefan Behnel's avatar Stefan Behnel

Merge remote-tracking branch 'origin/master'

parents 346243fe 4e5f0365
...@@ -12,8 +12,8 @@ cdef extern from "<deque>" namespace "std" nogil: ...@@ -12,8 +12,8 @@ cdef extern from "<deque>" namespace "std" nogil:
iterator operator--() iterator operator--()
bint operator==(reverse_iterator) bint operator==(reverse_iterator)
bint operator!=(reverse_iterator) bint operator!=(reverse_iterator)
#cppclass const_iterator(iterator): cppclass const_iterator(iterator):
# pass pass
#cppclass const_reverse_iterator(reverse_iterator): #cppclass const_reverse_iterator(reverse_iterator):
# pass # pass
deque() except + deque() except +
...@@ -34,11 +34,11 @@ cdef extern from "<deque>" namespace "std" nogil: ...@@ -34,11 +34,11 @@ cdef extern from "<deque>" namespace "std" nogil:
T& at(size_t) T& at(size_t)
T& back() T& back()
iterator begin() iterator begin()
#const_iterator begin() const_iterator const_begin "begin"()
void clear() void clear()
bint empty() bint empty()
iterator end() iterator end()
#const_iterator end() const_iterator const_end "end"()
iterator erase(iterator) iterator erase(iterator)
iterator erase(iterator, iterator) iterator erase(iterator, iterator)
T& front() T& front()
......
...@@ -16,10 +16,10 @@ cdef extern from "<list>" namespace "std" nogil: ...@@ -16,10 +16,10 @@ cdef extern from "<list>" namespace "std" nogil:
reverse_iterator operator--() reverse_iterator operator--()
bint operator==(reverse_iterator) bint operator==(reverse_iterator)
bint operator!=(reverse_iterator) bint operator!=(reverse_iterator)
#cppclass const_iterator(iterator): cppclass const_iterator(iterator):
# pass pass
#cppclass const_reverse_iterator(reverse_iterator): cppclass const_reverse_iterator(reverse_iterator):
# pass pass
list() except + list() except +
list(list&) except + list(list&) except +
list(size_t, T&) except + list(size_t, T&) except +
...@@ -33,11 +33,11 @@ cdef extern from "<list>" namespace "std" nogil: ...@@ -33,11 +33,11 @@ cdef extern from "<list>" namespace "std" nogil:
void assign(size_t, T&) void assign(size_t, T&)
T& back() T& back()
iterator begin() iterator begin()
#const_iterator begin() const_iterator const_begin "begin"()
void clear() void clear()
bint empty() bint empty()
iterator end() iterator end()
#const_iterator end() const_iterator const_end "end"()
iterator erase(iterator) iterator erase(iterator)
iterator erase(iterator, iterator) iterator erase(iterator, iterator)
T& front() T& front()
...@@ -51,11 +51,11 @@ cdef extern from "<list>" namespace "std" nogil: ...@@ -51,11 +51,11 @@ cdef extern from "<list>" namespace "std" nogil:
void push_back(T&) void push_back(T&)
void push_front(T&) void push_front(T&)
reverse_iterator rbegin() reverse_iterator rbegin()
#const_reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"()
void remove(T&) void remove(T&)
#void remove_if(UnPred) #void remove_if(UnPred)
reverse_iterator rend() reverse_iterator rend()
#const_reverse_iterator rend() const_reverse_iterator const_rend "rend"()
void resize(size_t, T&) void resize(size_t, T&)
void reverse() void reverse()
size_t size() size_t size()
......
...@@ -20,8 +20,8 @@ cdef extern from "<map>" namespace "std" nogil: ...@@ -20,8 +20,8 @@ cdef extern from "<map>" namespace "std" nogil:
iterator operator--() iterator operator--()
bint operator==(reverse_iterator) bint operator==(reverse_iterator)
bint operator!=(reverse_iterator) bint operator!=(reverse_iterator)
#cppclass const_reverse_iterator(reverse_iterator): cppclass const_reverse_iterator(reverse_iterator):
# pass pass
map() except + map() except +
map(map&) except + map(map&) except +
#map(key_compare&) #map(key_compare&)
...@@ -53,14 +53,14 @@ cdef extern from "<map>" namespace "std" nogil: ...@@ -53,14 +53,14 @@ cdef extern from "<map>" namespace "std" nogil:
#void insert(input_iterator, input_iterator) #void insert(input_iterator, input_iterator)
#key_compare key_comp() #key_compare key_comp()
iterator lower_bound(const T&) iterator lower_bound(const T&)
#const_iterator lower_bound(const key_type&) const_iterator const_lower_bound "lower_bound"(const T&)
size_t max_size() size_t max_size()
reverse_iterator rbegin() reverse_iterator rbegin()
#const_reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend() reverse_iterator rend()
#const_reverse_iterator rend() const_reverse_iterator const_rend "rend"()
size_t size() size_t size()
void swap(map&) void swap(map&)
iterator upper_bound(const T&) iterator upper_bound(const T&)
#const_iterator upper_bound(const key_type&) const_iterator const_upper_bound "upper_bound"(const T&)
#value_compare value_comp() #value_compare value_comp()
...@@ -14,10 +14,10 @@ cdef extern from "<set>" namespace "std" nogil: ...@@ -14,10 +14,10 @@ cdef extern from "<set>" namespace "std" nogil:
iterator operator--() iterator operator--()
bint operator==(reverse_iterator) bint operator==(reverse_iterator)
bint operator!=(reverse_iterator) bint operator!=(reverse_iterator)
#cppclass const_iterator(iterator): cppclass const_iterator(iterator):
# pass pass
#cppclass const_reverse_iterator(reverse_iterator): cppclass const_reverse_iterator(reverse_iterator):
# pass pass
set() except + set() except +
set(set&) except + set(set&) except +
#set(key_compare&) #set(key_compare&)
...@@ -29,32 +29,32 @@ cdef extern from "<set>" namespace "std" nogil: ...@@ -29,32 +29,32 @@ cdef extern from "<set>" namespace "std" nogil:
bint operator<=(set&, set&) bint operator<=(set&, set&)
bint operator>=(set&, set&) bint operator>=(set&, set&)
iterator begin() iterator begin()
#const_iterator begin() const_iterator const_begin "begin"()
void clear() void clear()
size_t count(const T&) size_t count(const T&)
bint empty() bint empty()
iterator end() iterator end()
#const_iterator end() const_iterator const_end "end"()
pair[iterator, iterator] equal_range(const T&) pair[iterator, iterator] equal_range(const T&)
#pair[const_iterator, const_iterator] equal_range(T&) #pair[const_iterator, const_iterator] equal_range(T&)
void erase(iterator) void erase(iterator)
void erase(iterator, iterator) void erase(iterator, iterator)
size_t erase(T&) size_t erase(T&)
iterator find(T&) iterator find(T&)
#const_iterator find(T&) const_iterator const_find "find"(T&)
pair[iterator, bint] insert(const T&) except + pair[iterator, bint] insert(const T&) except +
iterator insert(iterator, const T&) except + iterator insert(iterator, const T&) except +
#void insert(input_iterator, input_iterator) #void insert(input_iterator, input_iterator)
#key_compare key_comp() #key_compare key_comp()
iterator lower_bound(T&) iterator lower_bound(T&)
#const_iterator lower_bound(T&) const_iterator const_lower_bound "lower_bound"(T&)
size_t max_size() size_t max_size()
reverse_iterator rbegin() reverse_iterator rbegin()
#const_reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend() reverse_iterator rend()
#const_reverse_iterator rend() const_reverse_iterator const_rend "rend"()
size_t size() size_t size()
void swap(set&) void swap(set&)
iterator upper_bound(const T&) iterator upper_bound(const T&)
#const_iterator upper_bound(const T&) const_iterator const_upper_bound "upper_bound"(const T&)
#value_compare value_comp() #value_compare value_comp()
...@@ -14,10 +14,10 @@ cdef extern from "<unordered_map>" namespace "std" nogil: ...@@ -14,10 +14,10 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
iterator operator--() iterator operator--()
bint operator==(reverse_iterator) bint operator==(reverse_iterator)
bint operator!=(reverse_iterator) bint operator!=(reverse_iterator)
#cppclass const_iterator(iterator): cppclass const_iterator(iterator):
# pass pass
#cppclass const_reverse_iterator(reverse_iterator): cppclass const_reverse_iterator(reverse_iterator):
# pass pass
unordered_map() except + unordered_map() except +
unordered_map(unordered_map&) except + unordered_map(unordered_map&) except +
#unordered_map(key_compare&) #unordered_map(key_compare&)
...@@ -31,34 +31,34 @@ cdef extern from "<unordered_map>" namespace "std" nogil: ...@@ -31,34 +31,34 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
bint operator>=(unordered_map&, unordered_map&) bint operator>=(unordered_map&, unordered_map&)
U& at(T&) U& at(T&)
iterator begin() iterator begin()
#const_iterator begin() const_iterator const_begin "begin"()
void clear() void clear()
size_t count(T&) size_t count(T&)
bint empty() bint empty()
iterator end() iterator end()
#const_iterator end() const_iterator const_end "end"()
pair[iterator, iterator] equal_range(T&) pair[iterator, iterator] equal_range(T&)
#pair[const_iterator, const_iterator] equal_range(key_type&) #pair[const_iterator, const_iterator] equal_range(key_type&)
void erase(iterator) void erase(iterator)
void erase(iterator, iterator) void erase(iterator, iterator)
size_t erase(T&) size_t erase(T&)
iterator find(T&) iterator find(T&)
#const_iterator find(key_type&) const_iterator const_find "find"(T&)
pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]&
iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& iterator insert(iterator, pair[T, U]) # XXX pair[T,U]&
#void insert(input_iterator, input_iterator) #void insert(input_iterator, input_iterator)
#key_compare key_comp() #key_compare key_comp()
iterator lower_bound(T&) iterator lower_bound(T&)
#const_iterator lower_bound(key_type&) const_iterator const_lower_bound "lower_bound"(T&)
size_t max_size() size_t max_size()
reverse_iterator rbegin() reverse_iterator rbegin()
#const_reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend() reverse_iterator rend()
#const_reverse_iterator rend() const_reverse_iterator const_rend "rend"()
size_t size() size_t size()
void swap(unordered_map&) void swap(unordered_map&)
iterator upper_bound(T&) iterator upper_bound(T&)
#const_iterator upper_bound(key_type&) const_iterator const_upper_bound "upper_bound"(T&)
#value_compare value_comp() #value_compare value_comp()
void max_load_factor(float) void max_load_factor(float)
float max_load_factor() float max_load_factor()
...@@ -14,10 +14,10 @@ cdef extern from "<unordered_set>" namespace "std" nogil: ...@@ -14,10 +14,10 @@ cdef extern from "<unordered_set>" namespace "std" nogil:
iterator operator--() iterator operator--()
bint operator==(reverse_iterator) bint operator==(reverse_iterator)
bint operator!=(reverse_iterator) bint operator!=(reverse_iterator)
#cppclass const_iterator(iterator): cppclass const_iterator(iterator):
# pass pass
#cppclass const_reverse_iterator(reverse_iterator): cppclass const_reverse_iterator(reverse_iterator):
# pass pass
unordered_set() except + unordered_set() except +
unordered_set(unordered_set&) except + unordered_set(unordered_set&) except +
#unordered_set(key_compare&) #unordered_set(key_compare&)
...@@ -29,32 +29,32 @@ cdef extern from "<unordered_set>" namespace "std" nogil: ...@@ -29,32 +29,32 @@ cdef extern from "<unordered_set>" namespace "std" nogil:
bint operator<=(unordered_set&, unordered_set&) bint operator<=(unordered_set&, unordered_set&)
bint operator>=(unordered_set&, unordered_set&) bint operator>=(unordered_set&, unordered_set&)
iterator begin() iterator begin()
#const_iterator begin() const_iterator const_begin "begin"()
void clear() void clear()
size_t count(T&) size_t count(T&)
bint empty() bint empty()
iterator end() iterator end()
#const_iterator end() const_iterator const_end "end"()
pair[iterator, iterator] equal_range(T&) pair[iterator, iterator] equal_range(T&)
#pair[const_iterator, const_iterator] equal_range(T&) #pair[const_iterator, const_iterator] equal_range(T&)
void erase(iterator) void erase(iterator)
void erase(iterator, iterator) void erase(iterator, iterator)
size_t erase(T&) size_t erase(T&)
iterator find(T&) iterator find(T&)
#const_iterator find(T&) const_iterator const_find "find"(T&)
pair[iterator, bint] insert(T&) pair[iterator, bint] insert(T&)
iterator insert(iterator, T&) iterator insert(iterator, T&)
#void insert(input_iterator, input_iterator) #void insert(input_iterator, input_iterator)
#key_compare key_comp() #key_compare key_comp()
iterator lower_bound(T&) iterator lower_bound(T&)
#const_iterator lower_bound(T&) const_iterator const_lower_bound "lower_bound"(T&)
size_t max_size() size_t max_size()
reverse_iterator rbegin() reverse_iterator rbegin()
#const_reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend() reverse_iterator rend()
#const_reverse_iterator rend() const_reverse_iterator const_rend "rend"()
size_t size() size_t size()
void swap(unordered_set&) void swap(unordered_set&)
iterator upper_bound(T&) iterator upper_bound(T&)
#const_iterator upper_bound(T&) const_iterator const_upper_bound "upper_bound"(T&)
#value_compare value_comp() #value_compare value_comp()
...@@ -24,10 +24,10 @@ cdef extern from "<vector>" namespace "std" nogil: ...@@ -24,10 +24,10 @@ cdef extern from "<vector>" namespace "std" nogil:
bint operator>(reverse_iterator) bint operator>(reverse_iterator)
bint operator<=(reverse_iterator) bint operator<=(reverse_iterator)
bint operator>=(reverse_iterator) bint operator>=(reverse_iterator)
#cppclass const_iterator(iterator): cppclass const_iterator(iterator):
# pass pass
#cppclass const_reverse_iterator(reverse_iterator): cppclass const_reverse_iterator(reverse_iterator):
# pass pass
vector() except + vector() except +
vector(vector&) except + vector(vector&) except +
vector(size_t) except + vector(size_t) except +
...@@ -46,12 +46,12 @@ cdef extern from "<vector>" namespace "std" nogil: ...@@ -46,12 +46,12 @@ cdef extern from "<vector>" namespace "std" nogil:
T& at(size_t) except + T& at(size_t) except +
T& back() T& back()
iterator begin() iterator begin()
#const_iterator begin() const_iterator const_begin "begin"()
size_t capacity() size_t capacity()
void clear() void clear()
bint empty() bint empty()
iterator end() iterator end()
#const_iterator end() const_iterator const_end "end"()
iterator erase(iterator) iterator erase(iterator)
iterator erase(iterator, iterator) iterator erase(iterator, iterator)
T& front() T& front()
...@@ -62,9 +62,9 @@ cdef extern from "<vector>" namespace "std" nogil: ...@@ -62,9 +62,9 @@ cdef extern from "<vector>" namespace "std" nogil:
void pop_back() void pop_back()
void push_back(T&) except + void push_back(T&) except +
reverse_iterator rbegin() reverse_iterator rbegin()
#const_reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend() reverse_iterator rend()
#const_reverse_iterator rend() const_reverse_iterator const_rend "rend"()
void reserve(size_t) void reserve(size_t)
void resize(size_t) except + void resize(size_t) except +
void resize(size_t, T&) except + void resize(size_t, T&) except +
......
# tag: cpp # tag: cpp
import cython
cimport libcpp cimport libcpp
cimport libcpp.deque cimport libcpp.deque
...@@ -67,3 +69,23 @@ def test_vector_coercion(*args): ...@@ -67,3 +69,23 @@ def test_vector_coercion(*args):
for a in args: for a in args:
v.push_back(a) v.push_back(a)
return [v[0][i] for i in range(v.size())] return [v[0][i] for i in range(v.size())]
def test_const_vector(*args):
"""
>>> test_const_vector(1.75)
[1.75]
>>> test_const_vector(1, 10, 100)
[1.0, 10.0, 100.0]
"""
cdef vector[double] v
for a in args:
v.push_back(a)
return const_vector_to_list(v)
cdef const_vector_to_list(const vector[double]& cv):
cdef vector[double].const_iterator iter = cv.const_begin()
cdef lst = []
while iter != cv.const_end():
lst.append(cython.operator.dereference(iter))
cython.operator.preincrement(iter)
return lst
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