first commit

This commit is contained in:
Yura 2024-09-15 15:12:16 +03:00
commit 417e54da96
5696 changed files with 900003 additions and 0 deletions

View file

@ -0,0 +1,4 @@
cdef extern from *:
ctypedef bint bool
ctypedef void* nullptr_t
nullptr_t nullptr

View file

@ -0,0 +1,43 @@
from libcpp cimport bool
cdef extern from "<algorithm>" namespace "std" nogil:
# Sorting and searching
bool binary_search[Iter, T](Iter first, Iter last, const T& value)
bool binary_search[Iter, T, Compare](Iter first, Iter last, const T& value,
Compare comp)
Iter lower_bound[Iter, T](Iter first, Iter last, const T& value)
Iter lower_bound[Iter, T, Compare](Iter first, Iter last, const T& value,
Compare comp)
Iter upper_bound[Iter, T](Iter first, Iter last, const T& value)
Iter upper_bound[Iter, T, Compare](Iter first, Iter last, const T& value,
Compare comp)
void partial_sort[Iter](Iter first, Iter middle, Iter last)
void partial_sort[Iter, Compare](Iter first, Iter middle, Iter last,
Compare comp)
void sort[Iter](Iter first, Iter last)
void sort[Iter, Compare](Iter first, Iter last, Compare comp)
# Removing duplicates
Iter unique[Iter](Iter first, Iter last)
Iter unique[Iter, BinaryPredicate](Iter first, Iter last, BinaryPredicate p)
# Binary heaps (priority queues)
void make_heap[Iter](Iter first, Iter last)
void make_heap[Iter, Compare](Iter first, Iter last, Compare comp)
void pop_heap[Iter](Iter first, Iter last)
void pop_heap[Iter, Compare](Iter first, Iter last, Compare comp)
void push_heap[Iter](Iter first, Iter last)
void push_heap[Iter, Compare](Iter first, Iter last, Compare comp)
void sort_heap[Iter](Iter first, Iter last)
void sort_heap[Iter, Compare](Iter first, Iter last, Compare comp)
# Copy
OutputIter copy[InputIter,OutputIter](InputIter,InputIter,OutputIter)

View file

@ -0,0 +1,12 @@
# Defines the standard C++ cast operators.
#
# Due to type restrictions, these are only defined for pointer parameters,
# however that is the only case where they are significantly more interesting
# than the standard C cast operator which can be written "<T>(expression)" in
# Cython.
cdef extern from * nogil:
cdef T dynamic_cast[T](void *) except + # nullptr may also indicate failure
cdef T static_cast[T](void *)
cdef T reinterpret_cast[T](void *)
cdef T const_cast[T](void *)

View file

@ -0,0 +1,101 @@
# Note: add integer versions of the functions?
cdef extern from "<complex>" namespace "std" nogil:
cdef cppclass complex[T]:
complex() except +
complex(T, T) except +
complex(complex[T]&) except +
# How to make the converting constructor, i.e. convert complex[double]
# to complex[float]?
complex[T] operator+(complex[T]&)
complex[T] operator-(complex[T]&)
complex[T] operator+(complex[T]&, complex[T]&)
complex[T] operator+(complex[T]&, T&)
complex[T] operator+(T&, complex[T]&)
complex[T] operator-(complex[T]&, complex[T]&)
complex[T] operator-(complex[T]&, T&)
complex[T] operator-(T&, complex[T]&)
complex[T] operator*(complex[T]&, complex[T]&)
complex[T] operator*(complex[T]&, T&)
complex[T] operator*(T&, complex[T]&)
complex[T] operator/(complex[T]&, complex[T]&)
complex[T] operator/(complex[T]&, T&)
complex[T] operator/(T&, complex[T]&)
bint operator==(complex[T]&, complex[T]&)
bint operator==(complex[T]&, T&)
bint operator==(T&, complex[T]&)
bint operator!=(complex[T]&, complex[T]&)
bint operator!=(complex[T]&, T&)
bint operator!=(T&, complex[T]&)
# Access real part
T real()
void real(T)
# Access imaginary part
T imag()
void imag(T)
# Return real part
T real[T](complex[T]&)
long double real(long double)
double real(double)
float real(float)
# Return imaginary part
T imag[T](complex[T]&)
long double imag(long double)
double imag(double)
float imag(float)
T abs[T](complex[T]&)
T arg[T](complex[T]&)
long double arg(long double)
double arg(double)
float arg(float)
T norm[T](complex[T])
long double norm(long double)
double norm(double)
float norm(float)
complex[T] conj[T](complex[T]&)
complex[long double] conj(long double)
complex[double] conj(double)
complex[float] conj(float)
complex[T] proj[T](complex[T])
complex[long double] proj(long double)
complex[double] proj(double)
complex[float] proj(float)
complex[T] polar[T](T&, T&)
complex[T] ploar[T](T&)
complex[T] exp[T](complex[T]&)
complex[T] log[T](complex[T]&)
complex[T] log10[T](complex[T]&)
complex[T] pow[T](complex[T]&, complex[T]&)
complex[T] pow[T](complex[T]&, T&)
complex[T] pow[T](T&, complex[T]&)
# There are some promotion versions too
complex[T] sqrt[T](complex[T]&)
complex[T] sin[T](complex[T]&)
complex[T] cos[T](complex[T]&)
complex[T] tan[T](complex[T]&)
complex[T] asin[T](complex[T]&)
complex[T] acos[T](complex[T]&)
complex[T] atan[T](complex[T]&)
complex[T] sinh[T](complex[T]&)
complex[T] cosh[T](complex[T]&)
complex[T] tanh[T](complex[T]&)
complex[T] asinh[T](complex[T]&)
complex[T] acosh[T](complex[T]&)
complex[T] atanh[T](complex[T]&)

View file

@ -0,0 +1,86 @@
cdef extern from "<deque>" namespace "std" nogil:
cdef cppclass deque[T,ALLOCATOR=*]:
ctypedef T value_type
ctypedef ALLOCATOR allocator_type
# these should really be allocator_type.size_type and
# allocator_type.difference_type to be true to the C++ definition
# but cython doesn't support deferred access on template arguments
ctypedef size_t size_type
ctypedef ptrdiff_t difference_type
cppclass iterator:
T& operator*()
iterator operator++()
iterator operator--()
iterator operator+(size_type)
iterator operator-(size_type)
difference_type operator-(iterator)
bint operator==(iterator)
bint operator!=(iterator)
bint operator<(iterator)
bint operator>(iterator)
bint operator<=(iterator)
bint operator>=(iterator)
cppclass reverse_iterator:
T& operator*()
reverse_iterator operator++()
reverse_iterator operator--()
reverse_iterator operator+(size_type)
reverse_iterator operator-(size_type)
difference_type operator-(reverse_iterator)
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):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
deque() except +
deque(deque&) except +
deque(size_t) except +
deque(size_t, T&) except +
#deque[input_iterator](input_iterator, input_iterator)
T& operator[](size_t)
#deque& operator=(deque&)
bint operator==(deque&, deque&)
bint operator!=(deque&, deque&)
bint operator<(deque&, deque&)
bint operator>(deque&, deque&)
bint operator<=(deque&, deque&)
bint operator>=(deque&, deque&)
void assign(size_t, T&)
void assign(input_iterator, input_iterator)
T& at(size_t)
T& back()
iterator begin()
const_iterator const_begin "begin"()
void clear()
bint empty()
iterator end()
const_iterator const_end "end"()
iterator erase(iterator)
iterator erase(iterator, iterator)
T& front()
iterator insert(iterator, T&)
void insert(iterator, size_t, T&)
void insert(iterator, input_iterator, input_iterator)
size_t max_size()
void pop_back()
void pop_front()
void push_back(T&)
void push_front(T&)
reverse_iterator rbegin()
#const_reverse_iterator rbegin()
reverse_iterator rend()
#const_reverse_iterator rend()
void resize(size_t)
void resize(size_t, T&)
size_t size()
void swap(deque&)
# C++11 methods
void shrink_to_fit()

View file

@ -0,0 +1,62 @@
cdef extern from "<forward_list>" namespace "std" nogil:
cdef cppclass forward_list[T,ALLOCATOR=*]:
ctypedef T value_type
ctypedef ALLOCATOR allocator_type
# these should really be allocator_type.size_type and
# allocator_type.difference_type to be true to the C++ definition
# but cython doesn't support deferred access on template arguments
ctypedef size_t size_type
ctypedef ptrdiff_t difference_type
cppclass iterator:
iterator()
iterator(iterator &)
T& operator*()
iterator operator++()
bint operator==(iterator)
bint operator!=(iterator)
cppclass const_iterator(iterator):
pass
forward_list() except +
forward_list(forward_list&) except +
forward_list(size_t, T&) except +
#forward_list& operator=(forward_list&)
bint operator==(forward_list&, forward_list&)
bint operator!=(forward_list&, forward_list&)
bint operator<(forward_list&, forward_list&)
bint operator>(forward_list&, forward_list&)
bint operator<=(forward_list&, forward_list&)
bint operator>=(forward_list&, forward_list&)
void assign(size_t, T&)
T& front()
iterator before_begin()
const_iterator const_before_begin "before_begin"()
iterator begin()
const_iterator const_begin "begin"()
iterator end()
const_iterator const_end "end"()
bint empty()
size_t max_size()
void clear()
iterator insert_after(iterator, T&)
void insert_after(iterator, size_t, T&)
iterator erase_after(iterator)
iterator erase_after(iterator, iterator)
void push_front(T&)
void pop_front()
void resize(size_t)
void resize(size_t, T&)
void swap(forward_list&)
void merge(forward_list&)
void merge[Compare](forward_list&, Compare)
void splice_after(iterator, forward_list&)
void splice_after(iterator, forward_list&, iterator)
void splice_after(iterator, forward_list&, iterator, iterator)
void remove(const T&)
void remove_if[Predicate](Predicate)
void reverse()
void unique()
void unique[Predicate](Predicate)
void sort()
void sort[Compare](Compare)

View file

@ -0,0 +1,13 @@
cdef extern from "<functional>" namespace "std" nogil:
cdef cppclass function[T]:
function() except +
function(T*) except +
function(function&) except +
function(void*) except +
function operator=(T*)
function operator=(function&)
function operator=(void*)
function operator=[U](U)
bint operator bool()

View file

@ -0,0 +1,32 @@
#Basic reference: http://www.cplusplus.com/reference/iterator/
#Most of these classes are in fact empty structs
cdef extern from "<iterator>" namespace "std" nogil:
cdef cppclass iterator[Category,T,Distance,Pointer,Reference]:
pass
cdef cppclass output_iterator_tag:
pass
cdef cppclass input_iterator_tag:
pass
cdef cppclass forward_iterator_tag(input_iterator_tag):
pass
cdef cppclass bidirectional_iterator_tag(forward_iterator_tag):
pass
cdef cppclass random_access_iterator_tag(bidirectional_iterator_tag):
pass
cdef cppclass back_insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]):
pass
cdef cppclass front_insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]):
pass
cdef cppclass insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]):
pass
back_insert_iterator[CONTAINER] back_inserter[CONTAINER](CONTAINER &)
front_insert_iterator[CONTAINER] front_inserter[CONTAINER](CONTAINER &)
##Note: this is the C++98 version of inserter.
##The C++11 versions's prototype relies on typedef members of classes, which Cython doesn't currently support:
##template <class Container>
##insert_iterator<Container> inserter (Container& x, typename Container::iterator it)
insert_iterator[CONTAINER] inserter[CONTAINER,ITERATOR](CONTAINER &, ITERATOR)

View file

@ -0,0 +1,61 @@
cdef extern from "<limits>" namespace "std" nogil:
enum float_round_style:
round_indeterminate = -1
round_toward_zero = 0
round_to_nearest = 1
round_toward_infinity = 2
round_toward_neg_infinity = 3
enum float_denorm_style:
denorm_indeterminate = -1
denorm_absent = 0
denorm_present = 1
#The static methods can be called as, e.g. numeric_limits[int].round_error(), etc.
#The const data members should be declared as static. Cython currently doesn't allow that
#and/or I can't figure it out, so you must instantiate an object to access, e.g.
#cdef numeric_limits[double] lm
#print lm.round_style
cdef cppclass numeric_limits[T]:
const bint is_specialized
@staticmethod
T min()
@staticmethod
T max()
const int digits
const int digits10
const bint is_signed
const bint is_integer
const bint is_exact
const int radix
@staticmethod
T epsilon()
@staticmethod
T round_error()
const int min_exponent
const int min_exponent10
const int max_exponent
const int max_exponent10
const bint has_infinity
const bint has_quiet_NaN
const bint has_signaling_NaN
const float_denorm_style has_denorm
const bint has_denorm_loss
@staticmethod
T infinity()
@staticmethod
T quiet_NaN()
@staticmethod
T signaling_NaN()
@staticmethod
T denorm_min()
const bint is_iec559
const bint is_bounded
const bint is_modulo
const bint traps
const bint tinyness_before
const float_round_style round_style

View file

@ -0,0 +1,78 @@
cdef extern from "<list>" namespace "std" nogil:
cdef cppclass list[T,ALLOCATOR=*]:
ctypedef T value_type
ctypedef ALLOCATOR allocator_type
# these should really be allocator_type.size_type and
# allocator_type.difference_type to be true to the C++ definition
# but cython doesn't support deferred access on template arguments
ctypedef size_t size_type
ctypedef ptrdiff_t difference_type
cppclass iterator:
iterator()
iterator(iterator &)
T& operator*()
iterator operator++()
iterator operator--()
bint operator==(iterator)
bint operator!=(iterator)
cppclass reverse_iterator:
reverse_iterator()
reverse_iterator(iterator &)
T& operator*()
reverse_iterator operator++()
reverse_iterator operator--()
bint operator==(reverse_iterator)
bint operator!=(reverse_iterator)
cppclass const_iterator(iterator):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
list() except +
list(list&) except +
list(size_t, T&) except +
#list operator=(list&)
bint operator==(list&, list&)
bint operator!=(list&, list&)
bint operator<(list&, list&)
bint operator>(list&, list&)
bint operator<=(list&, list&)
bint operator>=(list&, list&)
void assign(size_t, T&)
T& back()
iterator begin()
const_iterator const_begin "begin"()
void clear()
bint empty()
iterator end()
const_iterator const_end "end"()
iterator erase(iterator)
iterator erase(iterator, iterator)
T& front()
iterator insert(iterator, T&)
void insert(iterator, size_t, T&)
size_t max_size()
void merge(list&)
#void merge(list&, BinPred)
void pop_back()
void pop_front()
void push_back(T&)
void push_front(T&)
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "rbegin"()
void remove(T&)
#void remove_if(UnPred)
reverse_iterator rend()
const_reverse_iterator const_rend "rend"()
void resize(size_t, T&)
void reverse()
size_t size()
void sort()
#void sort(BinPred)
void splice(iterator, list&)
void splice(iterator, list&, iterator)
void splice(iterator, list&, iterator, iterator)
void swap(list&)
void unique()
#void unique(BinPred)

View file

@ -0,0 +1,68 @@
from .utility cimport pair
cdef extern from "<map>" namespace "std" nogil:
cdef cppclass map[T, U, COMPARE=*, ALLOCATOR=*]:
ctypedef T key_type
ctypedef U mapped_type
ctypedef pair[const T, U] value_type
ctypedef COMPARE key_compare
ctypedef ALLOCATOR allocator_type
cppclass iterator:
pair[T, U]& operator*()
iterator operator++()
iterator operator--()
bint operator==(iterator)
bint operator!=(iterator)
cppclass reverse_iterator:
pair[T, U]& operator*()
iterator operator++()
iterator operator--()
bint operator==(reverse_iterator)
bint operator!=(reverse_iterator)
cppclass const_iterator(iterator):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
map() except +
map(map&) except +
#map(key_compare&)
U& operator[](T&)
#map& operator=(map&)
bint operator==(map&, map&)
bint operator!=(map&, map&)
bint operator<(map&, map&)
bint operator>(map&, map&)
bint operator<=(map&, map&)
bint operator>=(map&, map&)
U& at(const T&) except +
const U& const_at "at"(const T&) except +
iterator begin()
const_iterator const_begin "begin" ()
void clear()
size_t count(const T&)
bint empty()
iterator end()
const_iterator const_end "end" ()
pair[iterator, iterator] equal_range(const T&)
#pair[const_iterator, const_iterator] equal_range(key_type&)
void erase(iterator)
void erase(iterator, iterator)
size_t erase(const T&)
iterator find(const T&)
const_iterator const_find "find" (const T&)
pair[iterator, bint] insert(pair[T, U]) except + # XXX pair[T,U]&
iterator insert(iterator, pair[T, U]) except + # XXX pair[T,U]&
#void insert(input_iterator, input_iterator)
#key_compare key_comp()
iterator lower_bound(const T&)
const_iterator const_lower_bound "lower_bound"(const T&)
size_t max_size()
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend()
const_reverse_iterator const_rend "rend"()
size_t size()
void swap(map&)
iterator upper_bound(const T&)
const_iterator const_upper_bound "upper_bound"(const T&)
#value_compare value_comp()

View file

@ -0,0 +1,115 @@
from libcpp cimport bool, nullptr_t, nullptr
cdef extern from "<memory>" namespace "std" nogil:
cdef cppclass default_delete[T]:
default_delete()
cdef cppclass allocator[T]:
allocator()
allocator(const allocator &)
#allocator(const allocator[U] &) #unique_ptr unit tests fail w/this
T * address(T &)
const T * address(const T &) const
T * allocate( size_t n ) # Not to standard. should be a second default argument
void deallocate(T * , size_t)
size_t max_size() const
void construct( T *, const T &) #C++98. The C++11 version is variadic AND perfect-forwarding
void destroy(T *) #C++98
void destroy[U](U *) #unique_ptr unit tests fail w/this
cdef cppclass unique_ptr[T,DELETER=*]:
unique_ptr()
unique_ptr(nullptr_t)
unique_ptr(T*)
unique_ptr(unique_ptr[T]&)
# Modifiers
T* release()
void reset()
void reset(nullptr_t)
void reset(T*)
void swap(unique_ptr&)
# Observers
T* get()
T& operator*()
#T* operator->() # Not Supported
bool operator bool()
bool operator!()
bool operator==(const unique_ptr&)
bool operator!=(const unique_ptr&)
bool operator<(const unique_ptr&)
bool operator>(const unique_ptr&)
bool operator<=(const unique_ptr&)
bool operator>=(const unique_ptr&)
bool operator==(nullptr_t)
bool operator!=(nullptr_t)
# Forward Declaration not working ("Compiler crash in AnalyseDeclarationsTransform")
#cdef cppclass weak_ptr[T]
cdef cppclass shared_ptr[T]:
shared_ptr()
shared_ptr(nullptr_t)
shared_ptr(T*)
shared_ptr(shared_ptr[T]&)
shared_ptr(shared_ptr[T]&, T*)
shared_ptr(unique_ptr[T]&)
#shared_ptr(weak_ptr[T]&) # Not Supported
# Modifiers
void reset()
void reset(T*)
void swap(shared_ptr&)
# Observers
T* get()
T& operator*()
#T* operator->() # Not Supported
long use_count()
bool unique()
bool operator bool()
bool operator!()
#bool owner_before[Y](const weak_ptr[Y]&) # Not Supported
bool owner_before[Y](const shared_ptr[Y]&)
bool operator==(const shared_ptr&)
bool operator!=(const shared_ptr&)
bool operator<(const shared_ptr&)
bool operator>(const shared_ptr&)
bool operator<=(const shared_ptr&)
bool operator>=(const shared_ptr&)
bool operator==(nullptr_t)
bool operator!=(nullptr_t)
cdef cppclass weak_ptr[T]:
weak_ptr()
weak_ptr(weak_ptr[T]&)
weak_ptr(shared_ptr[T]&)
# Modifiers
void reset()
void swap(weak_ptr&)
# Observers
long use_count()
bool expired()
shared_ptr[T] lock()
bool owner_before[Y](const weak_ptr[Y]&)
bool owner_before[Y](const shared_ptr[Y]&)
# Smart pointer non-member operations
shared_ptr[T] make_shared[T](...) except +
# Temporaries used for exception handling break generated code
unique_ptr[T] make_unique[T](...) # except +
# No checking on the compatibility of T and U.
cdef shared_ptr[T] static_pointer_cast[T, U](const shared_ptr[U]&)
cdef shared_ptr[T] dynamic_pointer_cast[T, U](const shared_ptr[U]&)
cdef shared_ptr[T] const_pointer_cast[T, U](const shared_ptr[U]&)
cdef shared_ptr[T] reinterpret_pointer_cast[T, U](const shared_ptr[U]&)

View file

@ -0,0 +1 @@
from .utility cimport pair

View file

@ -0,0 +1,25 @@
cdef extern from "<queue>" namespace "std" nogil:
cdef cppclass queue[T]:
queue() except +
queue(queue&) except +
#queue(Container&)
T& back()
bint empty()
T& front()
void pop()
void push(T&)
size_t size()
# C++11 methods
void swap(queue&)
cdef cppclass priority_queue[T]:
priority_queue() except +
priority_queue(priority_queue&) except +
#priority_queue(Container&)
bint empty()
void pop()
void push(T&)
size_t size()
T& top()
# C++11 methods
void swap(priority_queue&)

View file

@ -0,0 +1,61 @@
from .utility cimport pair
cdef extern from "<set>" namespace "std" nogil:
cdef cppclass set[T]:
ctypedef T value_type
cppclass iterator:
T& operator*()
iterator operator++()
iterator operator--()
bint operator==(iterator)
bint operator!=(iterator)
cppclass reverse_iterator:
T& operator*()
iterator operator++()
iterator operator--()
bint operator==(reverse_iterator)
bint operator!=(reverse_iterator)
cppclass const_iterator(iterator):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
set() except +
set(set&) except +
#set(key_compare&)
#set& operator=(set&)
bint operator==(set&, set&)
bint operator!=(set&, set&)
bint operator<(set&, set&)
bint operator>(set&, set&)
bint operator<=(set&, set&)
bint operator>=(set&, set&)
iterator begin()
const_iterator const_begin "begin"()
void clear()
size_t count(const T&)
bint empty()
iterator end()
const_iterator const_end "end"()
pair[iterator, iterator] equal_range(const T&)
#pair[const_iterator, const_iterator] equal_range(T&)
iterator erase(iterator)
iterator erase(iterator, iterator)
size_t erase(T&)
iterator find(T&)
const_iterator const_find "find"(T&)
pair[iterator, bint] insert(const T&) except +
iterator insert(iterator, const T&) except +
void insert(iterator, iterator) except +
#key_compare key_comp()
iterator lower_bound(T&)
const_iterator const_lower_bound "lower_bound"(T&)
size_t max_size()
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend()
const_reverse_iterator const_rend "rend"()
size_t size()
void swap(set&)
iterator upper_bound(const T&)
const_iterator const_upper_bound "upper_bound"(const T&)
#value_compare value_comp()

View file

@ -0,0 +1,11 @@
cdef extern from "<stack>" namespace "std" nogil:
cdef cppclass stack[T]:
ctypedef T value_type
stack() except +
stack(stack&) except +
#stack(Container&)
bint empty()
void pop()
void push(T&)
size_t size()
T& top()

View file

@ -0,0 +1,227 @@
# deprecated cimport for backwards compatibility:
from libc.string cimport const_char
cdef extern from "<string>" namespace "std::string" nogil:
const size_t npos
cdef extern from "<string>" namespace "std" nogil:
cdef cppclass string:
cppclass iterator:
iterator()
char& operator*()
iterator(iterator&)
iterator operator++()
iterator operator--()
bint operator==(iterator)
bint operator!=(iterator)
cppclass reverse_iterator:
char& operator*()
iterator operator++()
iterator operator--()
iterator operator+(size_t)
iterator operator-(size_t)
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):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
string() except +
string(const string& s) except +
string(const string& s, size_t pos) except +
string(const string& s, size_t pos, size_t len) except +
string(const char* s) except +
string(const char* s, size_t n) except +
string(size_t n, char c) except +
string(iterator first, iterator last) except +
iterator begin()
const_iterator const_begin "begin"()
iterator end()
const_iterator const_end "end"()
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend()
const_reverse_iterator const_rend "rend"()
const char* c_str()
const char* data()
size_t size()
size_t max_size()
size_t length()
void resize(size_t) except +
void resize(size_t, char) except +
void shrink_to_fit() except +
size_t capacity()
void reserve(size_t) except +
void clear()
bint empty()
iterator erase(iterator first, iterator last)
iterator erase(iterator p)
iterator erase(const_iterator first, const_iterator last)
iterator erase(const_iterator p)
string& erase(size_t pos, size_t len) except +
string& erase(size_t pos) except +
string& erase() except +
char& at(size_t pos) except +
char& operator[](size_t pos)
char& front()
char& back()
int compare(const string& s)
int compare(size_t pos, size_t len, const string& s) except +
int compare(size_t pos, size_t len, const string& s, size_t subpos, size_t sublen) except +
int compare(const char* s) except +
int compare(size_t pos, size_t len, const char* s) except +
int compare(size_t pos, size_t len, const char* s , size_t n) except +
string& append(const string& s) except +
string& append(const string& s, size_t subpos, size_t sublen) except +
string& append(const char* s) except +
string& append(const char* s, size_t n) except +
string& append(size_t n, char c) except +
void push_back(char c) except +
void pop_back()
string& assign(const string& s) except +
string& assign(const string& s, size_t subpos, size_t sublen) except +
string& assign(const char* s, size_t n) except +
string& assign(const char* s) except +
string& assign(size_t n, char c) except +
string& insert(size_t pos, const string& s, size_t subpos, size_t sublen) except +
string& insert(size_t pos, const string& s) except +
string& insert(size_t pos, const char* s, size_t n) except +
string& insert(size_t pos, const char* s) except +
string& insert(size_t pos, size_t n, char c) except +
void insert(iterator p, size_t n, char c) except +
iterator insert(iterator p, char c) except +
size_t copy(char* s, size_t len, size_t pos) except +
size_t copy(char* s, size_t len) except +
size_t find(const string& s, size_t pos)
size_t find(const string& s)
size_t find(const char* s, size_t pos, size_t n)
size_t find(const char* s, size_t pos)
size_t find(const char* s)
size_t find(char c, size_t pos)
size_t find(char c)
size_t rfind(const string&, size_t pos)
size_t rfind(const string&)
size_t rfind(const char* s, size_t pos, size_t n)
size_t rfind(const char* s, size_t pos)
size_t rfind(const char* s)
size_t rfind(char c, size_t pos)
size_t rfind(char c)
size_t find_first_of(const string&, size_t pos)
size_t find_first_of(const string&)
size_t find_first_of(const char* s, size_t pos, size_t n)
size_t find_first_of(const char* s, size_t pos)
size_t find_first_of(const char* s)
size_t find_first_of(char c, size_t pos)
size_t find_first_of(char c)
size_t find_first_not_of(const string& s, size_t pos)
size_t find_first_not_of(const string& s)
size_t find_first_not_of(const char* s, size_t pos, size_t n)
size_t find_first_not_of(const char* s, size_t pos)
size_t find_first_not_of(const char*)
size_t find_first_not_of(char c, size_t pos)
size_t find_first_not_of(char c)
size_t find_last_of(const string& s, size_t pos)
size_t find_last_of(const string& s)
size_t find_last_of(const char* s, size_t pos, size_t n)
size_t find_last_of(const char* s, size_t pos)
size_t find_last_of(const char* s)
size_t find_last_of(char c, size_t pos)
size_t find_last_of(char c)
size_t find_last_not_of(const string& s, size_t pos)
size_t find_last_not_of(const string& s)
size_t find_last_not_of(const char* s, size_t pos, size_t n)
size_t find_last_not_of(const char* s, size_t pos)
size_t find_last_not_of(const char* s)
size_t find_last_not_of(char c, size_t pos)
size_t find_last_not_of(char c)
string substr(size_t pos, size_t len) except +
string substr(size_t pos) except +
string substr()
#string& operator= (const string&)
#string& operator= (const char*)
#string& operator= (char)
string operator+ (const string&) except +
string operator+ (const char*) except +
bint operator==(const string&)
bint operator==(const char*)
bint operator!= (const string&)
bint operator!= (const char*)
bint operator< (const string&)
bint operator< (const char*)
bint operator> (const string&)
bint operator> (const char*)
bint operator<= (const string&)
bint operator<= (const char*)
bint operator>= (const string&)
bint operator>= (const char*)
string to_string(int val) except +
string to_string(long val) except +
string to_string(long long val) except +
string to_string(unsigned val) except +
string to_string(size_t val) except +
string to_string(ssize_t val) except +
string to_string(unsigned long val) except +
string to_string(unsigned long long val) except +
string to_string(float val) except +
string to_string(double val) except +
string to_string(long double val) except +
int stoi(const string& s, size_t* idx, int base) except +
int stoi(const string& s, size_t* idx) except +
int stoi(const string& s) except +
long stol(const string& s, size_t* idx, int base) except +
long stol(const string& s, size_t* idx) except +
long stol(const string& s) except +
long long stoll(const string& s, size_t* idx, int base) except +
long long stoll(const string& s, size_t* idx) except +
long long stoll(const string& s) except +
unsigned long stoul(const string& s, size_t* idx, int base) except +
unsigned long stoul(const string& s, size_t* idx) except +
unsigned long stoul(const string& s) except +
unsigned long long stoull(const string& s, size_t* idx, int base) except +
unsigned long long stoull(const string& s, size_t* idx) except +
unsigned long long stoull(const string& s) except +
float stof(const string& s, size_t* idx) except +
float stof(const string& s) except +
double stod(const string& s, size_t* idx) except +
double stod(const string& s) except +
long double stold(const string& s, size_t* idx) except +
long double stold(const string& s) except +

View file

@ -0,0 +1,15 @@
from libcpp cimport bool
from .typeinfo cimport type_info
# This class is C++11-only
cdef extern from "<typeindex>" namespace "std" nogil:
cdef cppclass type_index:
type_index(const type_info &)
const char* name()
size_t hash_code()
bool operator==(const type_index &)
bool operator!=(const type_index &)
bool operator<(const type_index &)
bool operator<=(const type_index &)
bool operator>(const type_index &)
bool operator>=(const type_index &)

View file

@ -0,0 +1,10 @@
from libcpp cimport bool
cdef extern from "<typeinfo>" namespace "std" nogil:
cdef cppclass type_info:
const char* name()
int before(const type_info&)
bool operator==(const type_info&)
bool operator!=(const type_info&)
# C++11-only
size_t hash_code()

View file

@ -0,0 +1,74 @@
from .utility cimport pair
cdef extern from "<unordered_map>" namespace "std" nogil:
cdef cppclass unordered_map[T, U, HASH=*, PRED=*, ALLOCATOR=*]:
ctypedef T key_type
ctypedef U mapped_type
ctypedef pair[const T, U] value_type
cppclass iterator:
pair[T, U]& operator*()
iterator operator++()
iterator operator--()
bint operator==(iterator)
bint operator!=(iterator)
cppclass reverse_iterator:
pair[T, U]& operator*()
iterator operator++()
iterator operator--()
bint operator==(reverse_iterator)
bint operator!=(reverse_iterator)
cppclass const_iterator(iterator):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
unordered_map() except +
unordered_map(unordered_map&) except +
#unordered_map(key_compare&)
U& operator[](T&)
#unordered_map& operator=(unordered_map&)
bint operator==(unordered_map&, unordered_map&)
bint operator!=(unordered_map&, unordered_map&)
bint operator<(unordered_map&, unordered_map&)
bint operator>(unordered_map&, unordered_map&)
bint operator<=(unordered_map&, unordered_map&)
bint operator>=(unordered_map&, unordered_map&)
U& at(const T&)
const U& const_at "at"(const T&)
iterator begin()
const_iterator const_begin "begin"()
void clear()
size_t count(T&)
bint empty()
iterator end()
const_iterator const_end "end"()
pair[iterator, iterator] equal_range(T&)
pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&)
iterator erase(iterator)
iterator erase(iterator, iterator)
size_t erase(T&)
iterator find(T&)
const_iterator const_find "find"(T&)
pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]&
iterator insert(iterator, pair[T, U]) # XXX pair[T,U]&
iterator insert(iterator, iterator)
#key_compare key_comp()
iterator lower_bound(T&)
const_iterator const_lower_bound "lower_bound"(T&)
size_t max_size()
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend()
const_reverse_iterator const_rend "rend"()
size_t size()
void swap(unordered_map&)
iterator upper_bound(T&)
const_iterator const_upper_bound "upper_bound"(T&)
#value_compare value_comp()
void max_load_factor(float)
float max_load_factor()
void rehash(size_t)
void reserve(size_t)
size_t bucket_count()
size_t max_bucket_count()
size_t bucket_size(size_t)
size_t bucket(const T&)

View file

@ -0,0 +1,69 @@
from .utility cimport pair
cdef extern from "<unordered_set>" namespace "std" nogil:
cdef cppclass unordered_set[T,HASH=*,PRED=*,ALLOCATOR=*]:
ctypedef T value_type
cppclass iterator:
T& operator*()
iterator operator++()
iterator operator--()
bint operator==(iterator)
bint operator!=(iterator)
cppclass reverse_iterator:
T& operator*()
iterator operator++()
iterator operator--()
bint operator==(reverse_iterator)
bint operator!=(reverse_iterator)
cppclass const_iterator(iterator):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
unordered_set() except +
unordered_set(unordered_set&) except +
#unordered_set(key_compare&)
#unordered_set& operator=(unordered_set&)
bint operator==(unordered_set&, unordered_set&)
bint operator!=(unordered_set&, unordered_set&)
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()
const_iterator const_begin "begin"()
void clear()
size_t count(T&)
bint empty()
iterator end()
const_iterator const_end "end"()
pair[iterator, iterator] equal_range(T&)
pair[const_iterator, const_iterator] const_equal_range "equal_range"(T&)
iterator erase(iterator)
iterator erase(iterator, iterator)
size_t erase(T&)
iterator find(T&)
const_iterator const_find "find"(T&)
pair[iterator, bint] insert(T&)
iterator insert(iterator, T&)
#key_compare key_comp()
iterator insert(iterator, iterator)
iterator lower_bound(T&)
const_iterator const_lower_bound "lower_bound"(T&)
size_t max_size()
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend()
const_reverse_iterator const_rend "rend"()
size_t size()
void swap(unordered_set&)
iterator upper_bound(T&)
const_iterator const_upper_bound "upper_bound"(T&)
#value_compare value_comp()
void max_load_factor(float)
float max_load_factor()
void rehash(size_t)
void reserve(size_t)
size_t bucket_count()
size_t max_bucket_count()
size_t bucket_size(size_t)
size_t bucket(const T&)

View file

@ -0,0 +1,30 @@
cdef extern from "<utility>" namespace "std" nogil:
cdef cppclass pair[T, U]:
ctypedef T first_type
ctypedef U second_type
T first
U second
pair() except +
pair(pair&) except +
pair(T&, U&) except +
bint operator==(pair&, pair&)
bint operator!=(pair&, pair&)
bint operator<(pair&, pair&)
bint operator>(pair&, pair&)
bint operator<=(pair&, pair&)
bint operator>=(pair&, pair&)
cdef extern from * namespace "cython_std" nogil:
"""
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
// move should be defined for these versions of MSVC, but __cplusplus isn't set usefully
#include <type_traits>
namespace cython_std {
template <typename T> typename std::remove_reference<T>::type&& move(T& t) noexcept { return std::move(t); }
template <typename T> typename std::remove_reference<T>::type&& move(T&& t) noexcept { return std::move(t); }
}
#endif
"""
cdef T move[T](T)

View file

@ -0,0 +1,88 @@
cdef extern from "<vector>" namespace "std" nogil:
cdef cppclass vector[T,ALLOCATOR=*]:
ctypedef T value_type
ctypedef ALLOCATOR allocator_type
# these should really be allocator_type.size_type and
# allocator_type.difference_type to be true to the C++ definition
# but cython doesn't support deferred access on template arguments
ctypedef size_t size_type
ctypedef ptrdiff_t difference_type
cppclass iterator:
T& operator*()
iterator operator++()
iterator operator--()
iterator operator+(size_type)
iterator operator-(size_type)
difference_type operator-(iterator)
bint operator==(iterator)
bint operator!=(iterator)
bint operator<(iterator)
bint operator>(iterator)
bint operator<=(iterator)
bint operator>=(iterator)
cppclass reverse_iterator:
T& operator*()
reverse_iterator operator++()
reverse_iterator operator--()
reverse_iterator operator+(size_type)
reverse_iterator operator-(size_type)
difference_type operator-(reverse_iterator)
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):
pass
cppclass const_reverse_iterator(reverse_iterator):
pass
vector() except +
vector(vector&) except +
vector(size_type) except +
vector(size_type, T&) except +
#vector[input_iterator](input_iterator, input_iterator)
T& operator[](size_type)
#vector& operator=(vector&)
bint operator==(vector&, vector&)
bint operator!=(vector&, vector&)
bint operator<(vector&, vector&)
bint operator>(vector&, vector&)
bint operator<=(vector&, vector&)
bint operator>=(vector&, vector&)
void assign(size_type, const T&)
void assign[input_iterator](input_iterator, input_iterator) except +
T& at(size_type) except +
T& back()
iterator begin()
const_iterator const_begin "begin"()
size_type capacity()
void clear()
bint empty()
iterator end()
const_iterator const_end "end"()
iterator erase(iterator)
iterator erase(iterator, iterator)
T& front()
iterator insert(iterator, const T&) except +
iterator insert(iterator, size_type, const T&) except +
iterator insert[Iter](iterator, Iter, Iter) except +
size_type max_size()
void pop_back()
void push_back(T&) except +
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "crbegin"()
reverse_iterator rend()
const_reverse_iterator const_rend "crend"()
void reserve(size_type)
void resize(size_type) except +
void resize(size_type, T&) except +
size_type size()
void swap(vector&)
# C++11 methods
T* data()
const T* const_data "data"()
void shrink_to_fit()