diff options
Diffstat (limited to 'Cython/Includes/libcpp')
24 files changed, 2346 insertions, 238 deletions
diff --git a/Cython/Includes/libcpp/algorithm.pxd b/Cython/Includes/libcpp/algorithm.pxd index ec7c3835b..b961729b6 100644 --- a/Cython/Includes/libcpp/algorithm.pxd +++ b/Cython/Includes/libcpp/algorithm.pxd @@ -1,43 +1,320 @@ from libcpp cimport bool +from libcpp.utility cimport pair +from libc.stddef import ptrdiff_t 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) + # Non-modifying sequence operations + bool all_of[Iter, Pred](Iter first, Iter last, Pred pred) except + + bool all_of[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + + bool any_of[Iter, Pred](Iter first, Iter last, Pred pred) except + + bool any_of[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + + bool none_of[Iter, Pred](Iter first, Iter last, Pred pred) except + + bool none_of[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + - 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) + void for_each[Iter, UnaryFunction](Iter first, Iter last, UnaryFunction f) except + # actually returns f + void for_each[ExecutionPolicy, Iter, UnaryFunction](ExecutionPolicy&& policy, Iter first, Iter last, UnaryFunction f) except + # actually returns f - 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) + ptrdiff_t count[Iter, T](Iter first, Iter last, const T& value) except + + ptrdiff_t count[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + ptrdiff_t count_if[Iter, Pred](Iter first, Iter last, Pred pred) except + + ptrdiff_t count_if[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + - void partial_sort[Iter](Iter first, Iter middle, Iter last) - void partial_sort[Iter, Compare](Iter first, Iter middle, Iter last, - Compare comp) + pair[Iter1, Iter2] mismatch[Iter1, Iter2]( + Iter1 first1, Iter1 last1, Iter2 first2) except + # other overloads are tricky + pair[Iter1, Iter2] mismatch[ExecutionPolicy, Iter1, Iter2]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2) except + - void sort[Iter](Iter first, Iter last) - void sort[Iter, Compare](Iter first, Iter last, Compare comp) + Iter find[Iter, T](Iter first, Iter last, const T& value) except + + Iter find[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + - # Removing duplicates - Iter unique[Iter](Iter first, Iter last) - Iter unique[Iter, BinaryPredicate](Iter first, Iter last, BinaryPredicate p) + Iter find_if[Iter, Pred](Iter first, Iter last, Pred pred) except + + Iter find_if[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + + Iter find_if_not[Iter, Pred](Iter first, Iter last, Pred pred) except + + Iter find_if_not[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + - # Binary heaps (priority queues) - void make_heap[Iter](Iter first, Iter last) - void make_heap[Iter, Compare](Iter first, Iter last, Compare comp) + Iter1 find_end[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_end[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_end[Iter1, Iter2, BinaryPred]( + Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter1 find_end[ExecutionPolicy, Iter1, Iter2, BinaryPred]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + - 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) + Iter1 find_first_of[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_first_of[Iter1, Iter2, BinaryPred]( + Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter1 find_first_of[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_first_of[ExecutionPolicy, Iter1, Iter2, BinaryPred]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + - void sort_heap[Iter](Iter first, Iter last) - void sort_heap[Iter, Compare](Iter first, Iter last, Compare comp) + Iter adjacent_find[Iter](Iter first, Iter last) except + + Iter adjacent_find[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter adjacent_find[Iter, BinaryPred](Iter first, Iter last, BinaryPred pred) except + + Iter adjacent_find[ExecutionPolicy, Iter, BinaryPred](ExecutionPolicy&& policy, Iter first, Iter last, BinaryPred pred) except + - # Copy - OutputIter copy[InputIter,OutputIter](InputIter,InputIter,OutputIter) + Iter1 search[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 search[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 search[Iter1, Iter2, BinaryPred]( + Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter1 search[ExecutionPolicy, Iter1, Iter2, BinaryPred]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter search_n[Iter, Size, T](Iter first1, Iter last1, Size count, const T& value) except + + Iter search_n[ExecutionPolicy, Iter, Size, T](ExecutionPolicy&& policy, Iter first1, Iter last1, Size count, const T& value) except + + Iter search_n[Iter, Size, T, BinaryPred]( + Iter first1, Iter last1, Size count, const T& value, BinaryPred pred) except + + Iter search_n[ExecutionPolicy, Iter, Size, T, BinaryPred]( + ExecutionPolicy&& policy, Iter first1, Iter last1, Size count, const T& value, BinaryPred pred) except + + + # Modifying sequence operations + OutputIt copy[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + OutputIt copy_if[InputIt, OutputIt, Pred](InputIt first, InputIt last, OutputIt d_first, Pred pred) except + + OutputIt copy_if[ExecutionPolicy, InputIt, OutputIt, Pred](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, Pred pred) except + + OutputIt copy_n[InputIt, Size, OutputIt](InputIt first, Size count, OutputIt result) except + + OutputIt copy_n[ExecutionPolicy, InputIt, Size, OutputIt](ExecutionPolicy&& policy, InputIt first, Size count, OutputIt result) except + + Iter2 copy_backward[Iter1, Iter2](Iter1 first, Iter1 last, Iter2 d_last) except + + Iter2 copy_backward[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first, Iter1 last, Iter2 d_last) except + + + OutputIt move[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt move[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + Iter2 move_backward[Iter1, Iter2](Iter1 first, Iter1 last, Iter2 d_last) except + + Iter2 move_backward[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first, Iter1 last, Iter2 d_last) except + + + void fill[Iter, T](Iter first, Iter last, const T& value) except + + void fill[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter fill_n[Iter, Size, T](Iter first, Size count, const T& value) except + + Iter fill_n[ExecutionPolicy, Iter, Size, T](ExecutionPolicy&& policy, Iter first, Size count, const T& value) except + + + OutputIt transform[InputIt, OutputIt, UnaryOp]( + InputIt first1, InputIt last1, OutputIt d_first, UnaryOp unary_op) except + + + # This overload is ambiguos with the next one. We just let C++ disambiguate from the arguments + # OutputIt transform[ExecutionPolicy, InputIt, OutputIt, UnaryOp]( + # ExecutionPolicy&& policy, InputIt first1, InputIt last1, OutputIt d_first, UnaryOp unary_op) except + + + OutputIt transform[InputIt1, InputIt2, OutputIt, BinaryOp]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt d_first, BinaryOp binary_op) except + + + OutputIt transform[ExecutionPolicy, InputIt1, InputIt2, OutputIt, BinaryOp]( + ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt d_first, BinaryOp binary_op) except + + + void generate[Iter, Generator](Iter first, Iter last, Generator g) except + + void generate[ExecutionPolicy, Iter, Generator](ExecutionPolicy&& policy, Iter first, Iter last, Generator g) except + + void generate_n[Iter, Size, Generator](Iter first, Size count, Generator g) except + + void generate_n[ExecutionPolicy, Iter, Size, Generator](ExecutionPolicy&& policy, Iter first, Size count, Generator g) except + + + Iter remove[Iter, T](Iter first, Iter last, const T& value) except + + Iter remove[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter remove_if[Iter, UnaryPred](Iter first, Iter last, UnaryPred pred) except + + Iter remove_if[ExecutionPolicy, Iter, UnaryPred](ExecutionPolicy&& policy, Iter first, Iter last, UnaryPred pred) except + + OutputIt remove_copy[InputIt, OutputIt, T](InputIt first, InputIt last, OutputIt d_first, const T& value) except + + OutputIt remove_copy[ExecutionPolicy, InputIt, OutputIt, T](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, const T& value) except + + OutputIt remove_copy_if[InputIt, OutputIt, UnaryPred]( + InputIt first, InputIt last, OutputIt d_first, UnaryPred pred) except + + OutputIt remove_copy_if[ExecutionPolicy, InputIt, OutputIt, UnaryPred]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, UnaryPred pred) except + + + void replace[Iter, T](Iter first, Iter last, const T& old_value, const T& new_value) except + + void replace[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& old_value, const T& new_value) except + + void replace_if[Iter, UnaryPred, T](Iter first, Iter last, UnaryPred pred, const T& new_value) except + + OutputIt replace_copy[InputIt, OutputIt, T]( + InputIt first, InputIt last, OutputIt d_first, const T& old_value, const T& new_value) except + + void replace_if[ExecutionPolicy, Iter, UnaryPred, T](ExecutionPolicy&& policy, Iter first, Iter last, UnaryPred pred, const T& new_value) except + + + OutputIt replace_copy[ExecutionPolicy, InputIt, OutputIt, T]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, const T& old_value, const T& new_value) except + + OutputIt replace_copy_if[InputIt, OutputIt, UnaryPred, T]( + InputIt first, InputIt last, OutputIt d_first, UnaryPred pred, const T& new_value) except + + OutputIt replace_copy_if[ExecutionPolicy, InputIt, OutputIt, UnaryPred, T]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, UnaryPred pred, const T& new_value) except + + + void swap[T](T& a, T& b) except + # array overload also works + Iter2 swap_ranges[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2) except + + void iter_swap[Iter](Iter a, Iter b) except + + + void reverse[Iter](Iter first, Iter last) except + + void reverse[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + OutputIt reverse_copy[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt reverse_copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + + Iter rotate[Iter](Iter first, Iter n_first, Iter last) except + + Iter rotate[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter n_first, Iter last) except + + OutputIt rotate_copy[InputIt, OutputIt](InputIt first, InputIt n_first, InputIt last, OutputIt d_first) except + + OutputIt rotate_copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt n_first, InputIt last, OutputIt d_first) except + + + Iter unique[Iter](Iter first, Iter last) except + + Iter unique[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter unique[Iter, BinaryPred](Iter first, Iter last, BinaryPred p) except + + Iter unique[ExecutionPolicy, Iter, BinaryPred](ExecutionPolicy&& policy, Iter first, Iter last, BinaryPred p) except + + OutputIt unique_copy[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt unique_copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + OutputIt unique_copy[InputIt, OutputIt, BinaryPred]( + InputIt first, InputIt last, OutputIt d_first, BinaryPred pred) except + + OutputIt unique_copy[ExecutionPolicy, InputIt, OutputIt, BinaryPred]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, BinaryPred pred) except + + + SampleIt sample[PopulationIt, SampleIt, Distance, URBG](PopulationIt first, PopulationIt last, SampleIt out, Distance n, URBG&& g) except + + + # Partitioning operations + bool is_partitioned[Iter, Pred](Iter first, Iter last, Pred p) except + + bool is_partitioned[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + Iter partition[Iter, Pred](Iter first, Iter last, Pred p) except + + Iter partition[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + pair[OutputIt1, OutputIt2] partition_copy[InputIt, OutputIt1, OutputIt2, Pred]( + InputIt first, InputIt last, OutputIt1 d_first_true, OutputIt2 d_first_false, Pred p) except + + pair[OutputIt1, OutputIt2] partition_copy[ExecutionPolicy, InputIt, OutputIt1, OutputIt2, Pred]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt1 d_first_true, OutputIt2 d_first_false, Pred p) except + + + Iter stable_partition[Iter, Pred](Iter first, Iter last, Pred p) except + + Iter stable_partition[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + Iter partition_point[Iter, Pred](Iter first, Iter last, Pred p) except + + Iter partition_point[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + + # Sorting operations + bool is_sorted[Iter](Iter first, Iter last) except + + bool is_sorted[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + bool is_sorted[Iter, Compare](Iter first, Iter last, Compare comp) except + + bool is_sorted[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + Iter is_sorted_until[Iter](Iter first, Iter last) except + + Iter is_sorted_until[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter is_sorted_until[Iter, Compare](Iter first, Iter last, Compare comp) except + + Iter is_sorted_until[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + void sort[Iter](Iter first, Iter last) except + + void sort[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + void sort[Iter, Compare](Iter first, Iter last, Compare comp) except + + void sort[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + void partial_sort[Iter](Iter first, Iter middle, Iter last) except + + void partial_sort[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter middle, Iter last) except + + void partial_sort[Iter, Compare](Iter first, Iter middle, Iter last, Compare comp) except + + void partial_sort[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter middle, Iter last, Compare comp) except + + + OutputIt partial_sort_copy[InputIt, OutputIt]( + InputIt first, InputIt last, OutputIt d_first, OutputIt d_last) except + + OutputIt partial_sort_copy[ExecutionPolicy, InputIt, OutputIt]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, OutputIt d_last) except + + OutputIt partial_sort_copy[InputIt, OutputIt, Compare]( + InputIt first, InputIt last, OutputIt d_first, OutputIt d_last, Compare comp) except + + OutputIt partial_sort_copy[ExecutionPolicy, InputIt, OutputIt, Compare]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, OutputIt d_last, Compare comp) except + + + void stable_sort[Iter](Iter first, Iter last) except + + void stable_sort[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + void stable_sort[Iter, Compare](Iter first, Iter last, Compare comp) except + + void stable_sort[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + void nth_element[Iter](Iter first, Iter nth, Iter last) except + + void nth_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter nth, Iter last) except + + void nth_element[Iter, Compare](Iter first, Iter nth, Iter last, Compare comp) except + + void nth_element[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter nth, Iter last, Compare comp) except + + + # Binary search operations (on sorted ranges) + Iter lower_bound[Iter, T](Iter first, Iter last, const T& value) except + + Iter lower_bound[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter lower_bound[Iter, T, Compare](Iter first, Iter last, const T& value, Compare comp) except + + Iter lower_bound[ExecutionPolicy, Iter, T, Compare](ExecutionPolicy&& policy, Iter first, Iter last, const T& value, Compare comp) except + + + Iter upper_bound[Iter, T](Iter first, Iter last, const T& value) except + + Iter upper_bound[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter upper_bound[Iter, T, Compare](Iter first, Iter last, const T& value, Compare comp) except + + Iter upper_bound[ExecutionPolicy, Iter, T, Compare](ExecutionPolicy&& policy, Iter first, Iter last, const T& value, Compare comp) except + + + bool binary_search[Iter, T](Iter first, Iter last, const T& value) except + + bool binary_search[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + bool binary_search[Iter, T, Compare](Iter first, Iter last, const T& value, Compare comp) except + + bool binary_search[ExecutionPolicy, Iter, T, Compare](ExecutionPolicy&& policy, Iter first, Iter last, const T& value, Compare comp) except + + + # Other operations on sorted ranges + OutputIt merge[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + OutputIt merge[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + void inplace_merge[BidirIt](BidirIt first, BidirIt middle, BidirIt last) except + + void inplace_merge[BidirIt, Compare](BidirIt first, BidirIt middle, BidirIt last, Compare comp) except + + + # Set operations (on sorted ranges) + bool includes[InputIt1, InputIt2]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + + bool includes[InputIt1, InputIt2, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) except + + + OutputIt set_difference[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_difference[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, + OutputIt out, Compare comp) except + + + OutputIt set_intersection[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_intersection[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + OutputIt set_symmetric_difference[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_symmetric_difference[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + OutputIt set_union[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_union[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + # Heap operations + void make_heap[Iter](Iter first, Iter last) except + + void make_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + void push_heap[Iter](Iter first, Iter last) except + + void push_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + void pop_heap[Iter](Iter first, Iter last) except + + void pop_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + void sort_heap[Iter](Iter first, Iter last) except + + void sort_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + # Minimum/maximum operations + Iter min_element[Iter](Iter first, Iter last) except + + Iter min_element[Iter, Compare](Iter first, Iter last, Compare comp) except + + Iter min_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter max_element[Iter](Iter first, Iter last) except + + Iter max_element[Iter, Compare](Iter first, Iter last, Compare comp) except + + Iter max_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + pair[T, T] minmax[T](const T& a, const T& b) except + + pair[T, T] minmax[T, Compare](const T& a, const T& b, Compare comp) except + + pair[Iter, Iter] minmax_element[Iter](Iter first, Iter last) except + + pair[Iter, Iter] minmax_element[Iter, Compare](Iter first, Iter last, Compare comp) except + + pair[Iter, Iter] minmax_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + const T& clamp[T](const T& v, const T& lo, const T& hi) except + + const T& clamp[T, Compare](const T& v, const T& lo, const T& hi, Compare comp) except + + + # Comparison operations + bool equal[InputIt1, InputIt2](InputIt1 first1, InputIt1 last1, InputIt2 first2) except + + bool equal[InputIt1, InputIt2, BinPred](InputIt1 first1, InputIt1 last1, InputIt2 first2, BinPred pred) except + + # ambiguous with previous overload + #bool equal[InputIt1, InputIt2](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + bool equal[InputIt1, InputIt2, BinPred](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinPred pred) except + + + bool lexicographical_compare[InputIt1, InputIt2](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + # ambiguous with next overload + #bool lexicographical_compare[InputIt1, InputIt2, ExecutionPolicy](ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + bool lexicographical_compare[InputIt1, InputIt2, Compare](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) except + + + # Permutation operations + bool is_permutation[ForwardIt1, ForwardIt2](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2) except + + bool is_permutation[ForwardIt1, ForwardIt2, BinaryPred](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPred p) except + + # ambiguous with previous overload + #bool is_permutation[ForwardIt1, ForwardIt2](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2) except + + bool is_permutation[ForwardIt1, ForwardIt2, BinaryPred](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2, BinaryPred p) except + + bool next_permutation[BidirIt](BidirIt first, BidirIt last) except + + bool next_permutation[BidirIt, Compare](BidirIt first, BidirIt last, Compare comp) except + + bool prev_permutation[BidirIt](BidirIt first, BidirIt last) except + + bool prev_permutation[BidirIt, Compare](BidirIt first, BidirIt last, Compare comp) except + diff --git a/Cython/Includes/libcpp/any.pxd b/Cython/Includes/libcpp/any.pxd new file mode 100644 index 000000000..7c0d000cd --- /dev/null +++ b/Cython/Includes/libcpp/any.pxd @@ -0,0 +1,16 @@ +from libcpp cimport bool +from libcpp.typeinfo cimport type_info + +cdef extern from "<any>" namespace "std" nogil: + cdef cppclass any: + any() + any(any&) except + + void reset() + bool has_value() + type_info& type() + T& emplace[T](...) except + + void swap(any&) + any& operator=(any&) except + + any& operator=[U](U&) except + + + cdef T any_cast[T](any&) except + diff --git a/Cython/Includes/libcpp/atomic.pxd b/Cython/Includes/libcpp/atomic.pxd new file mode 100644 index 000000000..89a8e6ffc --- /dev/null +++ b/Cython/Includes/libcpp/atomic.pxd @@ -0,0 +1,59 @@ + +cdef extern from "<atomic>" namespace "std" nogil: + + cdef enum memory_order: + memory_order_relaxed + memory_order_consume + memory_order_acquire + memory_order_release + memory_order_acq_rel + memory_order_seq_cst + + cdef cppclass atomic[T]: + atomic() + atomic(T) + + bint is_lock_free() + void store(T) + void store(T, memory_order) + T load() + T load(memory_order) + T exchange(T) + T exchange(T, memory_order) + + bint compare_exchange_weak(T&, T, memory_order, memory_order) + bint compare_exchange_weak(T&, T, memory_order) + bint compare_exchange_weak(T&, T) + bint compare_exchange_strong(T&, T, memory_order, memory_order) + bint compare_exchange_strong(T&, T, memory_order) + bint compare_exchange_strong(T&, T) + + T fetch_add(T, memory_order) + T fetch_add(T) + T fetch_sub(T, memory_order) + T fetch_sub(T) + T fetch_and(T, memory_order) + T fetch_and(T) + T fetch_or(T, memory_order) + T fetch_or(T) + T fetch_xor(T, memory_order) + T fetch_xor(T) + + T operator++() + T operator++(int) + T operator--() + T operator--(int) + + # modify-in-place operators not yet supported by Cython: + # T operator+=(T) + # T operator-=(T) + # T operator&=(T) + # T operator|=(T) + # T operator^=(T) + + bint operator==(atomic[T]&, atomic[T]&) + bint operator==(atomic[T]&, T&) + bint operator==(T&, atomic[T]&) + bint operator!=(atomic[T]&, atomic[T]&) + bint operator!=(atomic[T]&, T&) + bint operator!=(T&, atomic[T]&) diff --git a/Cython/Includes/libcpp/bit.pxd b/Cython/Includes/libcpp/bit.pxd new file mode 100644 index 000000000..3b6ffed05 --- /dev/null +++ b/Cython/Includes/libcpp/bit.pxd @@ -0,0 +1,29 @@ +cdef extern from "<bit>" namespace "std" nogil: + # bit_cast (gcc >= 11.0, clang >= 14.0) + cdef To bit_cast[To, From](From&) + + # byteswap (C++23) + #cdef T byteswap[T](T) + + # integral powers of 2 (gcc >= 10.0, clang >= 12.0) + cdef bint has_single_bit[T](T) + cdef T bit_ceil[T](T) + cdef T bit_floor[T](T) + cdef int bit_width[T](T) + + # rotating (gcc >= 9.0, clang >= 9.0) + cdef T rotl[T](T, int shift) + cdef T rotr[T](T, int shift) + + # counting (gcc >= 9.0, clang >= 9.0) + cdef int countl_zero[T](T) + cdef int countl_one[T](T) + cdef int countr_zero[T](T) + cdef int countr_one[T](T) + cdef int popcount[T](T) + + # endian + cpdef enum class endian(int): + little, + big, + native diff --git a/Cython/Includes/libcpp/cmath.pxd b/Cython/Includes/libcpp/cmath.pxd new file mode 100644 index 000000000..edc198383 --- /dev/null +++ b/Cython/Includes/libcpp/cmath.pxd @@ -0,0 +1,518 @@ + +cdef extern from "<cmath>" namespace "std" nogil: + # all C99 functions + float acos(float x) except + + double acos(double x) except + + long double acos(long double x) except + + float acosf(float x) except + + long double acosl(long double x) except + + + float asin(float x) except + + double asin(double x) except + + long double asin(long double x) except + + float asinf(float x) except + + long double asinl(long double x) except + + + float atan(float x) except + + double atan(double x) except + + long double atan(long double x) except + + float atanf(float x) except + + long double atanl(long double x) except + + + float atan2(float y, float x) except + + double atan2(double y, double x) except + + long double atan2(long double y, long double x) except + + float atan2f(float y, float x) except + + long double atan2l(long double y, long double x) except + + + float cos(float x) except + + double cos(double x) except + + long double cos(long double x) except + + float cosf(float x) except + + long double cosl(long double x) except + + + float sin(float x) except + + double sin(double x) except + + long double sin(long double x) except + + float sinf(float x) except + + long double sinl(long double x) except + + + float tan(float x) except + + double tan(double x) except + + long double tan(long double x) except + + float tanf(float x) except + + long double tanl(long double x) except + + + float acosh(float x) except + + double acosh(double x) except + + long double acosh(long double x) except + + float acoshf(float x) except + + long double acoshl(long double x) except + + + float asinh(float x) except + + double asinh(double x) except + + long double asinh(long double x) except + + float asinhf(float x) except + + long double asinhl(long double x) except + + + float atanh(float x) except + + double atanh(double x) except + + long double atanh(long double x) except + + float atanhf(float x) except + + long double atanhl(long double x) except + + + float cosh(float x) except + + double cosh(double x) except + + long double cosh(long double x) except + + float coshf(float x) except + + long double coshl(long double x) except + + + float sinh(float x) except + + double sinh(double x) except + + long double sinh(long double x) except + + float sinhf(float x) except + + long double sinhl(long double x) except + + + float tanh(float x) except + + double tanh(double x) except + + long double tanh(long double x) except + + float tanhf(float x) except + + long double tanhl(long double x) except + + + float exp(float x) except + + double exp(double x) except + + long double exp(long double x) except + + float expf(float x) except + + long double expl(long double x) except + + + float exp2(float x) except + + double exp2(double x) except + + long double exp2(long double x) except + + float exp2f(float x) except + + long double exp2l(long double x) except + + + float expm1(float x) except + + double expm1(double x) except + + long double expm1(long double x) except + + float expm1f(float x) except + + long double expm1l(long double x) except + + + float frexp(float value, int* exp) except + + double frexp(double value, int* exp) except + + long double frexp(long double value, int* exp) except + + float frexpf(float value, int* exp) except + + long double frexpl(long double value, int* exp) except + + + int ilogb(float x) except + + int ilogb(double x) except + + int ilogb(long double x) except + + int ilogbf(float x) except + + int ilogbl(long double x) except + + + float ldexp(float x, int exp) except + + double ldexp(double x, int exp) except + + long double ldexp(long double x, int exp) except + + float ldexpf(float x, int exp) except + + long double ldexpl(long double x, int exp) except + + + float log(float x) except + + double log(double x) except + + long double log(long double x) except + + float logf(float x) except + + long double logl(long double x) except + + + float log10(float x) except + + double log10(double x) except + + long double log10(long double x) except + + float log10f(float x) except + + long double log10l(long double x) except + + + float log1p(float x) except + + double log1p(double x) except + + long double log1p(long double x) except + + float log1pf(float x) except + + long double log1pl(long double x) except + + + float log2(float x) except + + double log2(double x) except + + long double log2(long double x) except + + float log2f(float x) except + + long double log2l(long double x) except + + + float logb(float x) except + + double logb(double x) except + + long double logb(long double x) except + + float logbf(float x) except + + long double logbl(long double x) except + + + float modf(float value, float* iptr) except + + double modf(double value, double* iptr) except + + long double modf(long double value, long double* iptr) except + + float modff(float value, float* iptr) except + + long double modfl(long double value, long double* iptr) except + + + float scalbn(float x, int n) except + + double scalbn(double x, int n) except + + long double scalbn(long double x, int n) except + + float scalbnf(float x, int n) except + + long double scalbnl(long double x, int n) except + + + float scalbln(float x, long int n) except + + double scalbln(double x, long int n) except + + long double scalbln(long double x, long int n) except + + float scalblnf(float x, long int n) except + + long double scalblnl(long double x, long int n) except + + + float cbrt(float x) except + + double cbrt(double x) except + + long double cbrt(long double x) except + + float cbrtf(float x) except + + long double cbrtl(long double x) except + + + # absolute values + int abs(int j) except + + long int abs(long int j) except + + long long int abs(long long int j) except + + float abs(float j) except + + double abs(double j) except + + long double abs(long double j) except + + + float fabs(float x) except + + double fabs(double x) except + + long double fabs(long double x) except + + float fabsf(float x) except + + long double fabsl(long double x) except + + + float hypot(float x, float y) except + + double hypot(double x, double y) except + + long double hypot(long double x, long double y) except + + float hypotf(float x, float y) except + + long double hypotl(long double x, long double y) except + + + # C++17 three-dimensional hypotenuse + float hypot(float x, float y, float z) except + + double hypot(double x, double y, double z) except + + long double hypot(long double x, long double y, long double z) except + + + float pow(float x, float y) except + + double pow(double x, double y) except + + long double pow(long double x, long double y) except + + float powf(float x, float y) except + + long double powl(long double x, long double y) except + + + float sqrt(float x) except + + double sqrt(double x) except + + long double sqrt(long double x) except + + float sqrtf(float x) except + + long double sqrtl(long double x) except + + + float erf(float x) except + + double erf(double x) except + + long double erf(long double x) except + + float erff(float x) except + + long double erfl(long double x) except + + + float erfc(float x) except + + double erfc(double x) except + + long double erfc(long double x) except + + float erfcf(float x) except + + long double erfcl(long double x) except + + + float lgamma(float x) except + + double lgamma(double x) except + + long double lgamma(long double x) except + + float lgammaf(float x) except + + long double lgammal(long double x) except + + + float tgamma(float x) except + + double tgamma(double x) except + + long double tgamma(long double x) except + + float tgammaf(float x) except + + long double tgammal(long double x) except + + + float ceil(float x) except + + double ceil(double x) except + + long double ceil(long double x) except + + float ceilf(float x) except + + long double ceill(long double x) except + + + float floor(float x) except + + double floor(double x) except + + long double floor(long double x) except + + float floorf(float x) except + + long double floorl(long double x) except + + + float nearbyint(float x) except + + double nearbyint(double x) except + + long double nearbyint(long double x) except + + float nearbyintf(float x) except + + long double nearbyintl(long double x) except + + + float rint(float x) except + + double rint(double x) except + + long double rint(long double x) except + + float rintf(float x) except + + long double rintl(long double x) except + + + long int lrint(float x) except + + long int lrint(double x) except + + long int lrint(long double x) except + + long int lrintf(float x) except + + long int lrintl(long double x) except + + + long long int llrint(float x) except + + long long int llrint(double x) except + + long long int llrint(long double x) except + + long long int llrintf(float x) except + + long long int llrintl(long double x) except + + + float round(float x) except + + double round(double x) except + + long double round(long double x) except + + float roundf(float x) except + + long double roundl(long double x) except + + + long int lround(float x) except + + long int lround(double x) except + + long int lround(long double x) except + + long int lroundf(float x) except + + long int lroundl(long double x) except + + + long long int llround(float x) except + + long long int llround(double x) except + + long long int llround(long double x) except + + long long int llroundf(float x) except + + long long int llroundl(long double x) except + + + float trunc(float x) except + + double trunc(double x) except + + long double trunc(long double x) except + + float truncf(float x) except + + long double truncl(long double x) except + + + float fmod(float x, float y) except + + double fmod(double x, double y) except + + long double fmod(long double x, long double y) except + + float fmodf(float x, float y) except + + long double fmodl(long double x, long double y) except + + + float remainder(float x, float y) except + + double remainder(double x, double y) except + + long double remainder(long double x, long double y) except + + float remainderf(float x, float y) except + + long double remainderl(long double x, long double y) except + + + float remquo(float x, float y, int* quo) except + + double remquo(double x, double y, int* quo) except + + long double remquo(long double x, long double y, int* quo) except + + float remquof(float x, float y, int* quo) except + + long double remquol(long double x, long double y, int* quo) except + + + float copysign(float x, float y) except + + double copysign(double x, double y) except + + long double copysign(long double x, long double y) except + + float copysignf(float x, float y) except + + long double copysignl(long double x, long double y) except + + + double nan(const char* tagp) except + + float nanf(const char* tagp) except + + long double nanl(const char* tagp) except + + + float nextafter(float x, float y) except + + double nextafter(double x, double y) except + + long double nextafter(long double x, long double y) except + + float nextafterf(float x, float y) except + + long double nextafterl(long double x, long double y) except + + + float nexttoward(float x, long double y) except + + double nexttoward(double x, long double y) except + + long double nexttoward(long double x, long double y) except + + float nexttowardf(float x, long double y) except + + long double nexttowardl(long double x, long double y) except + + + float fdim(float x, float y) except + + double fdim(double x, double y) except + + long double fdim(long double x, long double y) except + + float fdimf(float x, float y) except + + long double fdiml(long double x, long double y) except + + + float fmax(float x, float y) except + + double fmax(double x, double y) except + + long double fmax(long double x, long double y) except + + float fmaxf(float x, float y) except + + long double fmaxl(long double x, long double y) except + + + float fmin(float x, float y) except + + double fmin(double x, double y) except + + long double fmin(long double x, long double y) except + + float fminf(float x, float y) except + + long double fminl(long double x, long double y) except + + + float fma(float x, float y, float z) except + + double fma(double x, double y, double z) except + + long double fma(long double x, long double y, long double z) except + + float fmaf(float x, float y, float z) except + + long double fmal(long double x, long double y, long double z) except + + + # C++20 linear interpolation + float lerp(float a, float b, float t) + double lerp(double a, double b, double t) + long double lerp(long double a, long double b, long double t) + + # classification / comparison functions + int fpclassify(float x) except + + int fpclassify(double x) except + + int fpclassify(long double x) except + + + bint isfinite(float x) except + + bint isfinite(double x) except + + bint isfinite(long double x) except + + + bint isinf(float x) except + + bint isinf(double x) except + + bint isinf(long double x) except + + + bint isnan(float x) except + + bint isnan(double x) except + + bint isnan(long double x) except + + + bint isnormal(float x) except + + bint isnormal(double x) except + + bint isnormal(long double x) except + + + bint signbit(float x) except + + bint signbit(double x) except + + bint signbit(long double x) except + + + bint isgreater(float x, float y) except + + bint isgreater(double x, double y) except + + bint isgreater(long double x, long double y) except + + + bint isgreaterequal(float x, float y) except + + bint isgreaterequal(double x, double y) except + + bint isgreaterequal(long double x, long double y) except + + + bint isless(float x, float y) except + + bint isless(double x, double y) except + + bint isless(long double x, long double y) except + + + bint islessequal(float x, float y) except + + bint islessequal(double x, double y) except + + bint islessequal(long double x, long double y) except + + + bint islessgreater(float x, float y) except + + bint islessgreater(double x, double y) except + + bint islessgreater(long double x, long double y) except + + + bint isunordered(float x, float y) except + + bint isunordered(double x, double y) except + + bint isunordered(long double x, long double y) except + + + # C++17 mathematical special functions + + # associated Laguerre polynomials + double assoc_laguerre(unsigned int n, unsigned int m, double x) except + + float assoc_laguerref(unsigned int n, unsigned int m, float x) except + + long double assoc_laguerrel(unsigned int n, unsigned int m, long double x) except + + + # associated Legendre functions + double assoc_legendre(unsigned int l, unsigned int m, double x) except + + float assoc_legendref(unsigned int l, unsigned int m, float x) except + + long double assoc_legendrel(unsigned int l, unsigned int m, long double x) except + + + # beta function + double beta(double x, double y) except + + float betaf(float x, float y) except + + long double betal(long double x, long double y) except + + + # complete elliptic integral of the first kind + double comp_ellint_1(double k) except + + float comp_ellint_1f(float k) except + + long double comp_ellint_1l(long double k) except + + + # complete elliptic integral of the second kind + double comp_ellint_2(double k) except + + float comp_ellint_2f(float k) except + + long double comp_ellint_2l(long double k) except + + + # complete elliptic integral of the third kind + double comp_ellint_3(double k, double nu) except + + float comp_ellint_3f(float k, float nu) except + + long double comp_ellint_3l(long double k, long double nu) except + + + # regular modified cylindrical Bessel functions + double cyl_bessel_i(double nu, double x) except + + float cyl_bessel_if(float nu, float x) except + + long double cyl_bessel_il(long double nu, long double x) except + + + # cylindrical Bessel functions of the first kind + double cyl_bessel_j(double nu, double x) except + + float cyl_bessel_jf(float nu, float x) except + + long double cyl_bessel_jl(long double nu, long double x) except + + + # irregular modified cylindrical Bessel functions + double cyl_bessel_k(double nu, double x) except + + float cyl_bessel_kf(float nu, float x) except + + long double cyl_bessel_kl(long double nu, long double x) except + + + # cylindrical Neumann functions + # cylindrical Bessel functions of the second kind + double cyl_neumann(double nu, double x) except + + float cyl_neumannf(float nu, float x) except + + long double cyl_neumannl(long double nu, long double x) except + + + # incomplete elliptic integral of the first kind + double ellint_1(double k, double phi) except + + float ellint_1f(float k, float phi) except + + long double ellint_1l(long double k, long double phi) except + + + # incomplete elliptic integral of the second kind + double ellint_2(double k, double phi) except + + float ellint_2f(float k, float phi) except + + long double ellint_2l(long double k, long double phi) except + + + # incomplete elliptic integral of the third kind + double ellint_3(double k, double nu, double phi) except + + float ellint_3f(float k, float nu, float phi) except + + long double ellint_3l(long double k, long double nu, long double phi) except + + + # exponential integral + double expint(double x) except + + float expintf(float x) except + + long double expintl(long double x) except + + + # Hermite polynomials + double hermite(unsigned int n, double x) except + + float hermitef(unsigned int n, float x) except + + long double hermitel(unsigned int n, long double x) except + + + # Laguerre polynomials + double laguerre(unsigned int n, double x) except + + float laguerref(unsigned int n, float x) except + + long double laguerrel(unsigned int n, long double x) except + + + # Legendre polynomials + double legendre(unsigned int l, double x) except + + float legendref(unsigned int l, float x) except + + long double legendrel(unsigned int l, long double x) except + + + # Riemann zeta function + double riemann_zeta(double x) except + + float riemann_zetaf(float x) except + + long double riemann_zetal(long double x) except + + + # spherical Bessel functions of the first kind + double sph_bessel(unsigned int n, double x) except + + float sph_besself(unsigned int n, float x) except + + long double sph_bessell(unsigned int n, long double x) except + + + # spherical associated Legendre functions + double sph_legendre(unsigned int l, unsigned int m, double theta) except + + float sph_legendref(unsigned int l, unsigned int m, float theta) except + + long double sph_legendrel(unsigned int l, unsigned int m, long double theta) except + + + # spherical Neumann functions + # spherical Bessel functions of the second kind + double sph_neumann(unsigned int n, double x) except + + float sph_neumannf(unsigned int n, float x) except + + long double sph_neumannl(unsigned int n, long double x) except + diff --git a/Cython/Includes/libcpp/deque.pxd b/Cython/Includes/libcpp/deque.pxd index 9e2b2291d..5f189ffd1 100644 --- a/Cython/Includes/libcpp/deque.pxd +++ b/Cython/Includes/libcpp/deque.pxd @@ -9,41 +9,114 @@ cdef extern from "<deque>" namespace "std" nogil: ctypedef size_t size_type ctypedef ptrdiff_t difference_type + cppclass const_iterator cppclass iterator: - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) iterator operator+(size_type) iterator operator-(size_type) difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) bint operator<(iterator) + bint operator<(const_iterator) bint operator>(iterator) + bint operator>(const_iterator) bint operator<=(iterator) + bint operator<=(const_iterator) bint operator>=(iterator) + bint operator>=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + const_iterator operator+(size_type) + const_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - T& operator*() + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() reverse_iterator operator++() reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) reverse_iterator operator+(size_type) reverse_iterator operator-(size_type) - difference_type operator-(reverse_iterator) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) bint operator>=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator>=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + const_reverse_iterator operator+(size_type) + const_reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) + bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) + bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) + bint operator>=(reverse_iterator) + bint operator>=(const_reverse_iterator) + deque() except + deque(deque&) except + deque(size_t) except + deque(size_t, T&) except + - #deque[input_iterator](input_iterator, input_iterator) + #deque[InputIt](InputIt, InputIt) T& operator[](size_t) #deque& operator=(deque&) bint operator==(deque&, deque&) @@ -52,35 +125,39 @@ cdef extern from "<deque>" namespace "std" nogil: 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) + void assign(size_t, T&) except + + void assign[InputIt](InputIt, InputIt) except + + T& at(size_t) except + T& back() iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() bint empty() iterator end() const_iterator const_end "end"() - iterator erase(iterator) - iterator erase(iterator, iterator) + const_iterator cend() + iterator erase(iterator) except + + iterator erase(iterator, iterator) except + T& front() - iterator insert(iterator, T&) - void insert(iterator, size_t, T&) - void insert(iterator, input_iterator, input_iterator) + iterator insert(iterator, T&) except + + void insert(iterator, size_t, T&) except + + void insert[InputIt](iterator, InputIt, InputIt) except + size_t max_size() void pop_back() void pop_front() - void push_back(T&) - void push_front(T&) + void push_back(T&) except + + void push_front(T&) except + reverse_iterator rbegin() #const_reverse_iterator rbegin() + const_reverse_iterator crbegin() reverse_iterator rend() #const_reverse_iterator rend() - void resize(size_t) - void resize(size_t, T&) + const_reverse_iterator crend() + void resize(size_t) except + + void resize(size_t, T&) except + size_t size() void swap(deque&) # C++11 methods - void shrink_to_fit() + void shrink_to_fit() except + diff --git a/Cython/Includes/libcpp/execution.pxd b/Cython/Includes/libcpp/execution.pxd new file mode 100644 index 000000000..eb92e3404 --- /dev/null +++ b/Cython/Includes/libcpp/execution.pxd @@ -0,0 +1,15 @@ + +cdef extern from "<execution>" namespace "std::execution" nogil: + cdef cppclass sequenced_policy: + pass + cdef cppclass parallel_policy: + pass + cdef cppclass parallel_unsequenced_policy: + pass + cdef cppclass unsequenced_policy: + pass + + const sequenced_policy seq "std::execution::seq" + const parallel_policy par "std::execution::par" + const parallel_unsequenced_policy par_unseq "std::execution::par_unseq" + const unsequenced_policy unseq "std::execution::unseq" diff --git a/Cython/Includes/libcpp/forward_list.pxd b/Cython/Includes/libcpp/forward_list.pxd index 8c3b240d0..3e04ce875 100644 --- a/Cython/Includes/libcpp/forward_list.pxd +++ b/Cython/Includes/libcpp/forward_list.pxd @@ -14,6 +14,7 @@ cdef extern from "<forward_list>" namespace "std" nogil: iterator(iterator &) T& operator*() iterator operator++() + iterator operator++(int) bint operator==(iterator) bint operator!=(iterator) cppclass const_iterator(iterator): diff --git a/Cython/Includes/libcpp/functional.pxd b/Cython/Includes/libcpp/functional.pxd index 94cbd9e1d..4786d39eb 100644 --- a/Cython/Includes/libcpp/functional.pxd +++ b/Cython/Includes/libcpp/functional.pxd @@ -1,3 +1,5 @@ +from libcpp cimport bool + cdef extern from "<functional>" namespace "std" nogil: cdef cppclass function[T]: function() except + @@ -10,4 +12,10 @@ cdef extern from "<functional>" namespace "std" nogil: function operator=(void*) function operator=[U](U) - bint operator bool() + bool operator bool() + + # Comparisons + cdef cppclass greater[T=*]: + # https://github.com/cython/cython/issues/3193 + greater() except + + bool operator()(const T& lhs, const T& rhs) except + diff --git a/Cython/Includes/libcpp/iterator.pxd b/Cython/Includes/libcpp/iterator.pxd index e0f8bd8d6..0b50c586d 100644 --- a/Cython/Includes/libcpp/iterator.pxd +++ b/Cython/Includes/libcpp/iterator.pxd @@ -1,6 +1,8 @@ #Basic reference: http://www.cplusplus.com/reference/iterator/ #Most of these classes are in fact empty structs +from libc.stddef import ptrdiff_t + cdef extern from "<iterator>" namespace "std" nogil: cdef cppclass iterator[Category,T,Distance,Pointer,Reference]: pass @@ -29,4 +31,4 @@ cdef extern from "<iterator>" namespace "std" nogil: ##insert_iterator<Container> inserter (Container& x, typename Container::iterator it) insert_iterator[CONTAINER] inserter[CONTAINER,ITERATOR](CONTAINER &, ITERATOR) - + ptrdiff_t distance[It](It first, It last) diff --git a/Cython/Includes/libcpp/limits.pxd b/Cython/Includes/libcpp/limits.pxd index c325263b7..11f5e23ea 100644 --- a/Cython/Includes/libcpp/limits.pxd +++ b/Cython/Includes/libcpp/limits.pxd @@ -1,61 +1,61 @@ cdef extern from "<limits>" namespace "std" nogil: - enum float_round_style: + 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: + 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() + #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 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 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 is_iec559 + const bint is_bounded + const bint is_modulo - const bint traps - const bint tinyness_before - const float_round_style round_style + const bint traps + const bint tinyness_before + const float_round_style round_style diff --git a/Cython/Includes/libcpp/list.pxd b/Cython/Includes/libcpp/list.pxd index b5b0410ad..b69cd573e 100644 --- a/Cython/Includes/libcpp/list.pxd +++ b/Cython/Includes/libcpp/list.pxd @@ -9,26 +9,61 @@ cdef extern from "<list>" namespace "std" nogil: ctypedef size_t size_type ctypedef ptrdiff_t difference_type + cppclass const_iterator cppclass iterator: - iterator() - iterator(iterator &) - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - reverse_iterator() - reverse_iterator(iterator &) - T& operator*() + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() reverse_iterator operator++() reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + list() except + list(list&) except + list(size_t, T&) except + @@ -39,36 +74,40 @@ cdef extern from "<list>" namespace "std" nogil: bint operator>(list&, list&) bint operator<=(list&, list&) bint operator>=(list&, list&) - void assign(size_t, T&) + void assign(size_t, T&) except + T& back() iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() bint empty() iterator end() const_iterator const_end "end"() + const_iterator cend() 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&) except + #void merge(list&, BinPred) void pop_back() void pop_front() - void push_back(T&) - void push_front(T&) + void push_back(T&) except + + void push_front(T&) except + reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() - void remove(T&) + const_reverse_iterator crbegin() + void remove(T&) except + #void remove_if(UnPred) reverse_iterator rend() const_reverse_iterator const_rend "rend"() - void resize(size_t, T&) + const_reverse_iterator crend() + void resize(size_t, T&) except + void reverse() size_t size() - void sort() + void sort() except + #void sort(BinPred) void splice(iterator, list&) void splice(iterator, list&, iterator) diff --git a/Cython/Includes/libcpp/map.pxd b/Cython/Includes/libcpp/map.pxd index 624a7ac02..d81af66e0 100644 --- a/Cython/Includes/libcpp/map.pxd +++ b/Cython/Includes/libcpp/map.pxd @@ -7,26 +7,76 @@ cdef extern from "<map>" namespace "std" nogil: ctypedef pair[const T, U] value_type ctypedef COMPARE key_compare 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 const_iterator cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen pair[T, U]& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - pair[T, U]& operator*() - iterator operator++() - iterator operator--() + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_reverse_iterator) + map() except + map(map&) except + #map(key_compare&) - U& operator[](T&) + U& operator[](const T&) #map& operator=(map&) bint operator==(map&, map&) bint operator!=(map&, map&) @@ -38,31 +88,157 @@ cdef extern from "<map>" namespace "std" nogil: const U& const_at "at"(const T&) except + iterator begin() const_iterator const_begin "begin" () + const_iterator cbegin() void clear() size_t count(const T&) bint empty() iterator end() const_iterator const_end "end" () + const_iterator cend() pair[iterator, iterator] equal_range(const T&) - #pair[const_iterator, const_iterator] equal_range(key_type&) - void erase(iterator) - void erase(iterator, iterator) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_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) + pair[iterator, bint] insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + #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"() + const_reverse_iterator crbegin() reverse_iterator rend() const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() size_t size() void swap(map&) iterator upper_bound(const T&) const_iterator const_upper_bound "upper_bound"(const T&) #value_compare value_comp() + # C++20 + bint contains(const T&) + + cdef cppclass multimap[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 + + # 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 const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen + pair[T, U]& operator*() + iterator operator++() + iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator + cppclass reverse_iterator: + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + + multimap() except + + multimap(const multimap&) except + + #multimap(key_compare&) + #multimap& operator=(multimap&) + bint operator==(const multimap&, const multimap&) + bint operator!=(const multimap&, const multimap&) + bint operator<(const multimap&, const multimap&) + bint operator>(const multimap&, const multimap&) + bint operator<=(const multimap&, const multimap&) + bint operator>=(const multimap&, const multimap&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + + #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"() + const_reverse_iterator crbegin() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() + size_t size() + void swap(multimap&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + #value_compare value_comp() + bint contains(const T&) diff --git a/Cython/Includes/libcpp/memory.pxd b/Cython/Includes/libcpp/memory.pxd index 2151c1ec7..c477c93fe 100644 --- a/Cython/Includes/libcpp/memory.pxd +++ b/Cython/Includes/libcpp/memory.pxd @@ -59,6 +59,7 @@ cdef extern from "<memory>" namespace "std" nogil: shared_ptr(shared_ptr[T]&, T*) shared_ptr(unique_ptr[T]&) #shared_ptr(weak_ptr[T]&) # Not Supported + shared_ptr[T]& operator=[Y](const shared_ptr[Y]& ptr) # Modifiers void reset() diff --git a/Cython/Includes/libcpp/numbers.pxd b/Cython/Includes/libcpp/numbers.pxd new file mode 100644 index 000000000..abd3069a1 --- /dev/null +++ b/Cython/Includes/libcpp/numbers.pxd @@ -0,0 +1,15 @@ +cdef extern from "<numbers>" namespace "std::numbers" nogil: + # C++20 mathematical constants + const double e + const double log2e + const double log10e + const double pi + const double inv_pi + const double inv_sqrtpi + const double ln2 + const double ln10 + const double sqrt2 + const double sqrt3 + const double inv_sqrt3 + const double egamma + const double phi diff --git a/Cython/Includes/libcpp/numeric.pxd b/Cython/Includes/libcpp/numeric.pxd new file mode 100644 index 000000000..a9fb37205 --- /dev/null +++ b/Cython/Includes/libcpp/numeric.pxd @@ -0,0 +1,131 @@ +cdef extern from "<numeric>" namespace "std" nogil: + T inner_product[InputIt1, InputIt2, T](InputIt1 first1, InputIt1 last1, InputIt2 first2, T init) + + T inner_product[InputIt1, InputIt2, T, BinaryOperation1, BinaryOperation2](InputIt1 first1, InputIt1 last1, + InputIt2 first2, T init, + BinaryOperation1 op1, + BinaryOperation2 op2) + + void iota[ForwardIt, T](ForwardIt first, ForwardIt last, T value) + + T accumulate[InputIt, T](InputIt first, InputIt last, T init) + + T accumulate[InputIt, T, BinaryOperation](InputIt first, InputIt last, T init, BinaryOperation op) + + void adjacent_difference[InputIt, OutputIt](InputIt in_first, InputIt in_last, OutputIt out_first) + + void adjacent_difference[InputIt, OutputIt, BinaryOperation](InputIt in_first, InputIt in_last, OutputIt out_first, + BinaryOperation op) + + void partial_sum[InputIt, OutputIt](InputIt in_first, OutputIt in_last, OutputIt out_first) + + void partial_sum[InputIt, OutputIt, BinaryOperation](InputIt in_first, InputIt in_last, OutputIt out_first, + BinaryOperation op) + + + T reduce[InputIt, T](InputIt first, InputIt last, T init) + + # ambiguous with next overload + #T reduce[ExecutionPolicy, ForwardIt, T](ExecutionPolicy&& policy, + # ForwardIt first, ForwardIt last, T init) + + T reduce[InputIt, T, BinaryOp](InputIt first, InputIt last, T init, BinaryOp binary_op) + + T reduce[ExecutionPolicy, ForwardIt, T, BinaryOp](ExecutionPolicy&& policy, + ForwardIt first, ForwardIt last, T init, BinaryOp binary_op) + + T transform_reduce[InputIt1, InputIt2, T](InputIt1 first1, InputIt1 last1, + InputIt2 first2, T init) + + T transform_reduce[InputIt1, InputIt2, T, BinaryReductionOp, BinaryTransformOp]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, T init, + BinaryReductionOp reduce, BinaryTransformOp transform) + + T transform_reduce[InputIt, T, BinaryReductionOp, UnaryTransformOp]( + InputIt first, InputIt last, T init, BinaryReductionOp reduce, + UnaryTransformOp transform) + + # ambiguous with previous overload + #T transform_reduce[ExecutionPolicy, ForwardIt1, ForwardIt2, T]( + # ExecutionPolicy&& policy, ForwardIt1 first1, ForwardIt1 last1, + # ForwardIt2 first2, T init) + + T transform_reduce[ExecutionPolicy, ForwardIt1, ForwardIt2, T, BinaryReductionOp, BinaryTransformOp]( + ExecutionPolicy&& policy, ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, T init, + BinaryReductionOp reduce, BinaryTransformOp transform) + + # ambiguous with second overload + #T transform_reduce[ExecutionPolicy, ForwardIt, T, BinaryReductionOp, UnaryTransformOp]( + # ExecutionPolicy&& policy, ForwardIt first, ForwardIt last, T init, BinaryReductionOp reduce, + # UnaryTransformOp transform) + + OutputIt inclusive_scan[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) + + # ambiguous with next overload + # ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, + # ForwardIt2 d_first) + + OutputIt inclusive_scan[InputIt, OutputIt, BinaryOperation]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op) + + # ambiguous with next overload + # ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + # BinaryOperation binary_op) + + OutputIt inclusive_scan[InputIt, OutputIt, BinaryOperation, T]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op, + T init) + + # + # ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation, T]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + # BinaryOperation binary_op, T init) + + OutputIt exclusive_scan[InputIt, OutputIt, T](InputIt first, InputIt last, + OutputIt d_first, T init) + + # ambiguous with next overload + #ForwardIt2 exclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, T]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, + # ForwardIt2 d_first, T init) + + OutputIt exclusive_scan[InputIt, OutputIt, T, BinaryOperation]( + InputIt first, InputIt last, OutputIt d_first, T init, BinaryOperation binary_op) + + ForwardIt2 exclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, T, BinaryOperation]( + ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + T init, BinaryOperation binary_op) + + OutputIt transform_inclusive_scan[InputIt, OutputIt, BinaryOperation, UnaryOperation]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op, + UnaryOperation unary_op) + + # ambiguous with next overload + # ForwardIt2 transform_inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation, UnaryOperation]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + # BinaryOperation binary_op, UnaryOperation unary_op) + + OutputIt transform_inclusive_scan[InputIt, OutputIt, BinaryOperation, UnaryOperation, T]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op, + UnaryOperation unary_op, T init) + + ForwardIt2 transform_inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation, UnaryOperation, T]( + ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + BinaryOperation binary_op, UnaryOperation unary_op, T init) + + OutputIt transform_exclusive_scan[InputIt, OutputIt, T, BinaryOperation, UnaryOperation]( + InputIt first, InputIt last, OutputIt d_first, T init, BinaryOperation binary_op, + UnaryOperation unary_op) + + ForwardIt2 transform_exclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, T, BinaryOperation, UnaryOperation]( + ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + T init, BinaryOperation binary_op, UnaryOperation unary_op) + + # C++17 + T gcd[T](T a, T b) + T lcm[T](T a, T b) + + # C++20 + T midpoint[T](T a, T b) except + diff --git a/Cython/Includes/libcpp/optional.pxd b/Cython/Includes/libcpp/optional.pxd new file mode 100644 index 000000000..284dfcd6e --- /dev/null +++ b/Cython/Includes/libcpp/optional.pxd @@ -0,0 +1,34 @@ +from libcpp cimport bool + +cdef extern from "<optional>" namespace "std" nogil: + cdef cppclass nullopt_t: + nullopt_t() + + cdef nullopt_t nullopt + + cdef cppclass optional[T]: + ctypedef T value_type + optional() + optional(nullopt_t) + optional(optional&) except + + optional(T&) except + + bool has_value() + T& value() + T& value_or[U](U& default_value) + void swap(optional&) + void reset() + T& emplace(...) + T& operator*() + #T* operator->() # Not Supported + optional& operator=(optional&) + optional& operator=[U](U&) + bool operator bool() + bool operator!() + bool operator==[U](optional&, U&) + bool operator!=[U](optional&, U&) + bool operator<[U](optional&, U&) + bool operator>[U](optional&, U&) + bool operator<=[U](optional&, U&) + bool operator>=[U](optional&, U&) + + optional[T] make_optional[T](...) except + diff --git a/Cython/Includes/libcpp/random.pxd b/Cython/Includes/libcpp/random.pxd new file mode 100644 index 000000000..9e48bb27f --- /dev/null +++ b/Cython/Includes/libcpp/random.pxd @@ -0,0 +1,166 @@ +from libc.stdint cimport uint_fast32_t, uint_fast64_t + + +cdef extern from "<random>" namespace "std" nogil: + cdef cppclass random_device: + ctypedef uint_fast32_t result_type + random_device() except + + result_type operator()() except + + + cdef cppclass mt19937: + ctypedef uint_fast32_t result_type + mt19937() except + + mt19937(result_type seed) except + + result_type operator()() except + + result_type min() except + + result_type max() except + + void discard(size_t z) except + + void seed(result_type seed) except + + + cdef cppclass mt19937_64: + ctypedef uint_fast64_t result_type + + mt19937_64() except + + mt19937_64(result_type seed) except + + result_type operator()() except + + result_type min() except + + result_type max() except + + void discard(size_t z) except + + void seed(result_type seed) except + + + cdef cppclass uniform_int_distribution[T]: + ctypedef T result_type + uniform_int_distribution() except + + uniform_int_distribution(T, T) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass uniform_real_distribution[T]: + ctypedef T result_type + uniform_real_distribution() except + + uniform_real_distribution(T, T) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass bernoulli_distribution: + ctypedef bint result_type + bernoulli_distribution() except + + bernoulli_distribution(double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass binomial_distribution[T]: + ctypedef T result_type + binomial_distribution() except + + binomial_distribution(T, double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass geometric_distribution[T]: + ctypedef T result_type + geometric_distribution() except + + geometric_distribution(double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + + cdef cppclass negative_binomial_distribution[T]: + ctypedef T result_type + negative_binomial_distribution() except + + negative_binomial_distribution(T, double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass poisson_distribution[T]: + ctypedef T result_type + poisson_distribution() except + + poisson_distribution(double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass exponential_distribution[T]: + ctypedef T result_type + exponential_distribution() except + + exponential_distribution(result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass gamma_distribution[T]: + ctypedef T result_type + gamma_distribution() except + + gamma_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass weibull_distribution[T]: + ctypedef T result_type + weibull_distribution() except + + weibull_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass extreme_value_distribution[T]: + ctypedef T result_type + extreme_value_distribution() except + + extreme_value_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass normal_distribution[T]: + ctypedef T result_type + normal_distribution() except + + normal_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass lognormal_distribution[T]: + ctypedef T result_type + lognormal_distribution() except + + lognormal_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass chi_squared_distribution[T]: + ctypedef T result_type + chi_squared_distribution() except + + chi_squared_distribution(result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass cauchy_distribution[T]: + ctypedef T result_type + cauchy_distribution() except + + cauchy_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass fisher_f_distribution[T]: + ctypedef T result_type + fisher_f_distribution() except + + fisher_f_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass student_t_distribution[T]: + ctypedef T result_type + student_t_distribution() except + + student_t_distribution(result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + diff --git a/Cython/Includes/libcpp/set.pxd b/Cython/Includes/libcpp/set.pxd index 1069be746..444b1ce9f 100644 --- a/Cython/Includes/libcpp/set.pxd +++ b/Cython/Includes/libcpp/set.pxd @@ -3,22 +3,68 @@ from .utility cimport pair cdef extern from "<set>" namespace "std" nogil: cdef cppclass set[T]: ctypedef T value_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 const_iterator cppclass iterator: - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - T& operator*() - iterator operator++() - iterator operator--() + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_reverse_iterator) + set() except + set(set&) except + #set(key_compare&) @@ -31,31 +77,152 @@ cdef extern from "<set>" namespace "std" nogil: bint operator>=(set&, set&) iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() size_t count(const T&) bint empty() iterator end() const_iterator const_end "end"() + const_iterator cend() pair[iterator, iterator] equal_range(const T&) - #pair[const_iterator, const_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&) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) pair[iterator, bint] insert(const T&) except + iterator insert(iterator, const T&) except + - void insert(iterator, iterator) except + + iterator insert(const_iterator, const T&) except + + iterator const_insert "insert"(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + #key_compare key_comp() - iterator lower_bound(T&) - const_iterator const_lower_bound "lower_bound"(T&) + 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"() + const_reverse_iterator crbegin() reverse_iterator rend() const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() size_t size() void swap(set&) iterator upper_bound(const T&) const_iterator const_upper_bound "upper_bound"(const T&) #value_compare value_comp() + # C++20 + bint contains(const T&) + + cdef cppclass multiset[T]: + ctypedef T value_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 const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + value_type& operator*() + iterator operator++() + iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator + cppclass reverse_iterator: + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + + multiset() except + + multiset(multiset&) except + + #multiset(key_compare&) + #multiset& operator=(multiset&) + bint operator==(multiset&, multiset&) + bint operator!=(multiset&, multiset&) + bint operator<(multiset&, multiset&) + bint operator>(multiset&, multiset&) + bint operator<=(multiset&, multiset&) + bint operator>=(multiset&, multiset&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const T&) except + + iterator insert(iterator, const T&) except + + iterator const_insert "insert"(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + + #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"() + const_reverse_iterator crbegin() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() + size_t size() + void swap(multiset&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + # C++20 + bint contains(const T&) diff --git a/Cython/Includes/libcpp/stack.pxd b/Cython/Includes/libcpp/stack.pxd index 2dc80992b..f92240f66 100644 --- a/Cython/Includes/libcpp/stack.pxd +++ b/Cython/Includes/libcpp/stack.pxd @@ -6,6 +6,6 @@ cdef extern from "<stack>" namespace "std" nogil: #stack(Container&) bint empty() void pop() - void push(T&) + void push(T&) except + size_t size() T& top() diff --git a/Cython/Includes/libcpp/string.pxd b/Cython/Includes/libcpp/string.pxd index a894144f1..23518806a 100644 --- a/Cython/Includes/libcpp/string.pxd +++ b/Cython/Includes/libcpp/string.pxd @@ -7,34 +7,116 @@ cdef extern from "<string>" namespace "std::string" nogil: cdef extern from "<string>" namespace "std" nogil: cdef cppclass string: + ctypedef char value_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 const_iterator cppclass iterator: - iterator() - char& operator*() - iterator(iterator&) + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) + iterator operator+(size_type) + iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) - + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + const_iterator operator+(size_type) + const_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - char& operator*() - iterator operator++() - iterator operator--() - iterator operator+(size_t) - iterator operator-(size_t) + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + reverse_iterator operator+(size_type) + reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) bint operator>=(reverse_iterator) - - cppclass const_iterator(iterator): - pass - - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator>=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + const_reverse_iterator operator+(size_type) + const_reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) + bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) + bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) + bint operator>=(reverse_iterator) + bint operator>=(const_reverse_iterator) string() except + string(const string& s) except + @@ -47,12 +129,16 @@ cdef extern from "<string>" namespace "std" nogil: iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() iterator end() const_iterator const_end "end"() + const_iterator cend() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() reverse_iterator rend() const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() const char* c_str() const char* data() @@ -62,6 +148,7 @@ cdef extern from "<string>" namespace "std" nogil: void resize(size_t) except + void resize(size_t, char) except + void shrink_to_fit() except + + void swap(string& other) size_t capacity() void reserve(size_t) except + void clear() @@ -164,6 +251,15 @@ cdef extern from "<string>" namespace "std" nogil: string substr(size_t pos) except + string substr() + # C++20 + bint starts_with(char c) except + + bint starts_with(const char* s) + bint ends_with(char c) except + + bint ends_with(const char* s) + # C++23 + bint contains(char c) except + + bint contains(const char* s) + #string& operator= (const string&) #string& operator= (const char*) #string& operator= (char) diff --git a/Cython/Includes/libcpp/unordered_map.pxd b/Cython/Includes/libcpp/unordered_map.pxd index a00fbbed2..90f5a2d06 100644 --- a/Cython/Includes/libcpp/unordered_map.pxd +++ b/Cython/Includes/libcpp/unordered_map.pxd @@ -5,26 +5,49 @@ cdef extern from "<unordered_map>" namespace "std" nogil: ctypedef T key_type ctypedef U mapped_type ctypedef pair[const T, U] 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 cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen pair[T, U]& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) bint operator==(iterator) + bint operator==(const_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 + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + unordered_map() except + unordered_map(unordered_map&) except + #unordered_map(key_compare&) - U& operator[](T&) + U& operator[](const T&) #unordered_map& operator=(unordered_map&) bint operator==(unordered_map&, unordered_map&) bint operator!=(unordered_map&, unordered_map&) @@ -32,43 +55,139 @@ cdef extern from "<unordered_map>" namespace "std" nogil: 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&) + U& at(const T&) except + + const U& const_at "at"(const T&) except + iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() - size_t count(T&) + size_t count(const T&) bint empty() iterator end() const_iterator const_end "end"() - pair[iterator, iterator] equal_range(T&) + const_iterator cend() + pair[iterator, iterator] equal_range(const 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) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + pair[iterator, bint] insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + #key_compare key_comp() - iterator lower_bound(T&) - const_iterator const_lower_bound "lower_bound"(T&) + 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(unordered_map&) - iterator upper_bound(T&) - const_iterator const_upper_bound "upper_bound"(T&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + #value_compare value_comp() + void max_load_factor(float) + float max_load_factor() + float 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&) + # C++20 + bint contains(const T&) + + cdef cppclass unordered_multimap[T, U, HASH=*, PRED=*, ALLOCATOR=*]: + ctypedef T key_type + ctypedef U mapped_type + ctypedef pair[const T, U] 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 const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen + pair[T, U]& operator*() + iterator operator++() + iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + unordered_multimap() except + + unordered_multimap(const unordered_multimap&) except + + #unordered_multimap(key_compare&) + #unordered_map& operator=(unordered_multimap&) + bint operator==(const unordered_multimap&, const unordered_multimap&) + bint operator!=(const unordered_multimap&, const unordered_multimap&) + bint operator<(const unordered_multimap&, const unordered_multimap&) + bint operator>(const unordered_multimap&, const unordered_multimap&) + bint operator<=(const unordered_multimap&, const unordered_multimap&) + bint operator>=(const unordered_multimap&, const unordered_multimap&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + #local_iterator begin(size_t) + #const_local_iterator const_begin "begin"(size_t) + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + #local_iterator end(size_t) + #const_local_iterator const_end "end"(size_t) + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + + #key_compare key_comp() + iterator lower_bound(const T&) + const_iterator const_lower_bound "lower_bound"(const T&) + size_t max_size() + size_t size() + void swap(unordered_multimap&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) #value_compare value_comp() void max_load_factor(float) float max_load_factor() + float 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&) + # C++20 + bint contains(const T&) diff --git a/Cython/Includes/libcpp/unordered_set.pxd b/Cython/Includes/libcpp/unordered_set.pxd index 5aa241752..6aae890d9 100644 --- a/Cython/Includes/libcpp/unordered_set.pxd +++ b/Cython/Includes/libcpp/unordered_set.pxd @@ -3,67 +3,150 @@ from .utility cimport pair cdef extern from "<unordered_set>" namespace "std" nogil: cdef cppclass unordered_set[T,HASH=*,PRED=*,ALLOCATOR=*]: ctypedef T value_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 const_iterator cppclass iterator: - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) bint operator==(iterator) + bint operator==(const_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 + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + 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"() + const_iterator cbegin() void clear() - size_t count(T&) + size_t count(const 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&) + const_iterator cend() + pair[iterator, iterator] equal_range(const 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(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&) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + pair[iterator, bint] insert(const T&) except + + iterator insert(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + 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() + float 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&) + # C++20 + bint contains(const T&) + + cdef cppclass unordered_multiset[T,HASH=*,PRED=*,ALLOCATOR=*]: + ctypedef T value_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 const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + value_type& operator*() + iterator operator++() + iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + unordered_multiset() except + + unordered_multiset(unordered_multiset&) except + + #unordered_multiset& operator=(unordered_multiset&) + bint operator==(unordered_multiset&, unordered_multiset&) + bint operator!=(unordered_multiset&, unordered_multiset&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const T&) except + + iterator insert(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + + size_t max_size() + size_t size() + void swap(unordered_multiset&) + #value_compare value_comp() + void max_load_factor(float) + float max_load_factor() + float 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&) + # C++20 + bint contains(const T&) diff --git a/Cython/Includes/libcpp/vector.pxd b/Cython/Includes/libcpp/vector.pxd index 9b007dd0c..3def8a568 100644 --- a/Cython/Includes/libcpp/vector.pxd +++ b/Cython/Includes/libcpp/vector.pxd @@ -9,41 +9,114 @@ cdef extern from "<vector>" namespace "std" nogil: ctypedef size_t size_type ctypedef ptrdiff_t difference_type + cppclass const_iterator cppclass iterator: + iterator() except + + iterator(iterator&) except + T& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) iterator operator+(size_type) iterator operator-(size_type) difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) bint operator<(iterator) + bint operator<(const_iterator) bint operator>(iterator) + bint operator>(const_iterator) bint operator<=(iterator) + bint operator<=(const_iterator) bint operator>=(iterator) + bint operator>=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const T& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + const_iterator operator+(size_type) + const_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + T& operator*() reverse_iterator operator++() reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) reverse_iterator operator+(size_type) reverse_iterator operator-(size_type) - difference_type operator-(reverse_iterator) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) bint operator>=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator>=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const T& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + const_reverse_iterator operator+(size_type) + const_reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) + bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) + bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) + bint operator>=(reverse_iterator) + bint operator>=(const_reverse_iterator) + vector() except + vector(vector&) except + vector(size_type) except + vector(size_type, T&) except + - #vector[input_iterator](input_iterator, input_iterator) + #vector[InputIt](InputIt, InputIt) T& operator[](size_type) #vector& operator=(vector&) bint operator==(vector&, vector&) @@ -53,30 +126,34 @@ cdef extern from "<vector>" namespace "std" nogil: bint operator<=(vector&, vector&) bint operator>=(vector&, vector&) void assign(size_type, const T&) - void assign[input_iterator](input_iterator, input_iterator) except + + void assign[InputIt](InputIt, InputIt) except + T& at(size_type) except + T& back() iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() size_type capacity() void clear() bint empty() iterator end() const_iterator const_end "end"() + const_iterator cend() 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 + + iterator insert[InputIt](iterator, InputIt, InputIt) except + size_type max_size() void pop_back() void push_back(T&) except + reverse_iterator rbegin() - const_reverse_iterator const_rbegin "crbegin"() + const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() reverse_iterator rend() - const_reverse_iterator const_rend "crend"() - void reserve(size_type) + const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() + void reserve(size_type) except + void resize(size_type) except + void resize(size_type, T&) except + size_type size() @@ -85,4 +162,6 @@ cdef extern from "<vector>" namespace "std" nogil: # C++11 methods T* data() const T* const_data "data"() - void shrink_to_fit() + void shrink_to_fit() except + + iterator emplace(const_iterator, ...) except + + T& emplace_back(...) except + |