C++ STL deque of C structs

78 views
Skip to first unread message

Alex

unread,
Jun 6, 2024, 4:31:47 AMJun 6
to cython-users

Hello,

I am trying to put Sage’s bitset_ts in Cython’s libcpp pairs (and transitively, deques and unordered maps) in order to make a priority queue.

I was originally using Cython {,Frozen}Bitsets inside of Python data structures (lists, dicts), but I wanted to try using the raw underlying bitset_t ctypes inside C++ STL data structures, since I need my code to be as performant as possible, and wanted to experiment to see how much of a speedup I'd get in my current test suite without all of the Python fluff in the way.

The code compiles successfully on the Cython side into valid C++, but I am getting an error afterwards at the C++ compilation step. I certainly am not well-versed in C++ in the slightest, but I read a quick description of move semantics from the C++ documentation, so I can now put C++ as a known language on my résumé. Jokes aside, from what I am able to surmise, the problem is that C++ can't figure out how to implicitly move these bitset_ts.

To alleviate this problem, I tried for multiple days to write my own move semantics via inlined (cdef extern from *) C++. I first tried "exporting" the Cython ctype for bitset_ts via public declarations, but was having trouble accessing the type, let alone its struct members, via the inlined C++ in order to write the move semantics. bitset_ts seem to only be defined as bitset_s[1]s (I’m not quite sure why they’re defined that way instead of *bitset_s…), so I tried re-implementing bitset_ss in the inlined C++ temporarily, despite introducing decoupling from Sage's implementations, to proceed. I was able to get a crude version of my custom move semantics created, but was not able to get the Sage Cython bitset_t functions that I need to use to work with my C++ re-definition of them.

Does anyone have any idea how I can get past this frustrating roadblock? I can provide more details of the other attempts, but for brevity, here is the 1st attempt using Sage’s bitset_ts out of the box, and the associated error I was getting:

Minimum Viable Product fastqueue.pxd: from libcpp.pair cimport pair from libcpp.deque cimport deque from libcpp.unordered_map cimport unordered_map from sage.data_structures.bitset_base cimport bitset_t ctypedef pair[size_t, bitset_t] Node # vx_to_make_force, forced_metavx ctypedef pair[size_t, Node] NodePrio # prio, Node ctypedef deque[Node] QueueAtPrio ctypedef unordered_map[size_t, QueueAtPrio] Queue cdef class FastQueueForBFS: cdef: Queue queue list priority_heap void push(self, NodePrio) NodePrio pop_and_get_priority(self) fastqueue.pyx: from libcpp.utility cimport move # I get the same error with/without using move import heapq cdef class FastQueueForBFS: cdef void push(self, NodePrio new_item): if self.queue.count(new_item.first) == 0: self.queue[new_item.first] = QueueAtPrio() #self.queue[new_item.first].push_back(new_item.second) self.queue[new_item.first].push_back(move(new_item.second)) if self.queue[new_item.first].size() == 1: heapq.heappush(self.priority_heap, new_item.first) cdef NodePrio pop_and_get_priority(self): cdef size_t priority_to_return = self.priority_heap[0] cdef Node item_to_return = move(self.queue[priority_to_return].front()) #cdef Node item_to_return = self.queue[priority_to_return].front() self.queue[priority_to_return].pop_front() if self.queue[priority_to_return].size() == 0: heapq.heappop(self.priority_heap) return NodePrio(priority_to_return, item_to_return) Error: #8 [4/4] RUN : && sage --python3 setup.py build_ext --debug && sage --python3 -m pip install -r test/requirements.txt #8 0.900 Compiling the following extensions in debug mode: zeroforcing.fastqueue #8 0.900 Compiling zeroforcing/fastqueue.pyx because it changed. #8 0.900 [1/1] Cythonizing zeroforcing/fastqueue.pyx #8 1.384 zeroforcing/fastqueue.cpp: In function '__pyx_t_11zeroforcing_9fastqueue_NodePrio __pyx_f_11zeroforcing_9fastqueue_15FastQueueForBFS_pop_and_get_priority(__pyx_obj_11zeroforcing_9fastqueue_FastQueueForBFS*)ΓÇÖ: #8 1.384 zeroforcing/fastqueue.cpp:14123:143: error: use of deleted function 'std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>& std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>::operator=(const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&)ΓÇÖ #8 1.384 14123 | __pyx_v_item_to_return = cython_std::move<__pyx_t_11zeroforcing_9fastqueue_Node &>((__pyx_v_self->queue[__pyx_v_priority_to_return]).front()); #8 1.384 | ^ #8 1.384 In file included from /usr/include/c++/11/bits/stl_algobase.h:64, #8 1.384 from /usr/include/c++/11/bits/specfun.h:45, #8 1.384 from /usr/include/c++/11/cmath:1935, #8 1.384 from /usr/include/c++/11/math.h:36, #8 1.384 from /home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/pyport.h:218, #8 1.384 from /home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/Python.h:38, #8 1.384 from zeroforcing/fastqueue.cpp:52: #8 1.384 /usr/include/c++/11/bits/stl_pair.h:211:12: note: 'std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>& std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>::operator=(const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&)ΓÇÖ is implicitly declared as deleted because 'std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>ΓÇÖ declares a move constructor or move assignment operator #8 1.384 211 | struct pair #8 1.384 | ^~~~ #8 1.387 zeroforcing/fastqueue.cpp:14199:109: error: use of deleted function 'std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >& std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >::operator=(const std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >&)ΓÇÖ #8 1.387 14199 | __pyx_t_7 = __pyx_t_11zeroforcing_9fastqueue_NodePrio(__pyx_v_priority_to_return, __pyx_v_item_to_return); #8 1.387 | ^ #8 1.387 In file included from /usr/include/c++/11/bits/stl_algobase.h:64, #8 1.387 from /usr/include/c++/11/bits/specfun.h:45, #8 1.387 from /usr/include/c++/11/cmath:1935, #8 1.387 from /usr/include/c++/11/math.h:36, #8 1.387 from /home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/pyport.h:218, #8 1.387 from /home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/Python.h:38, #8 1.387 from zeroforcing/fastqueue.cpp:52: #8 1.387 /usr/include/c++/11/bits/stl_pair.h:211:12: note: 'std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >& std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >::operator=(const std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >&)ΓÇÖ is implicitly declared as deleted because 'std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >ΓÇÖ declares a move constructor or move assignment operator #8 1.387 211 | struct pair #8 1.387 | ^~~~ #8 1.387 zeroforcing/fastqueue.cpp:14204:13: error: use of deleted function 'std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >& std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >::operator=(const std::pair<long unsigned int, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >&)ΓÇÖ #8 1.387 14204 | __pyx_r = __pyx_t_7; #8 1.387 | ^~~~~~~~~ #8 1.490 In file included from /usr/include/c++/11/bits/specfun.h:45, #8 1.490 from /usr/include/c++/11/cmath:1935, #8 1.490 from /usr/include/c++/11/math.h:36, #8 1.490 from /home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/pyport.h:218, #8 1.490 from /home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/Python.h:38, #8 1.490 from zeroforcing/fastqueue.cpp:52: #8 1.490 /usr/include/c++/11/bits/stl_algobase.h: In instantiation of 'static _Tp* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(const _Tp*, const _Tp*, _Tp*) [with _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; bool _IsMove = false]ΓÇÖ: #8 1.490 /usr/include/c++/11/bits/stl_algobase.h:495:30: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OI = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*]ΓÇÖ #8 1.490 /usr/include/c++/11/bits/stl_algobase.h:522:42: required from '_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OI = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*]ΓÇÖ #8 1.490 /usr/include/c++/11/bits/deque.tcc:1060:32: required from 'typename __gnu_cxx::__enable_if<std::__is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type std::__copy_move_a1(_II, _II, std::_Deque_iterator<_Tp, _Tp&, _Tp*>) [with bool _IsMove = false; _II = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; typename __gnu_cxx::__enable_if<std::__is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type = __gnu_cxx::__enable_if<true, std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*> >::__type; typename std::iterator_traits<_II>::iterator_category = std::random_access_iterator_tag]ΓÇÖ #8 1.490 /usr/include/c++/11/bits/deque.tcc:1011:36: required from '_OI std::__copy_move_dit(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, _OI) [with bool _IsMove = false; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Ref = const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&; _Ptr = const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.490 /usr/include/c++/11/bits/deque.tcc:1043:38: required from 'std::_Deque_iterator<_OTp, _OTp&, _OTp*> std::__copy_move_a1(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_OTp, _OTp&, _OTp*>) [with bool _IsMove = false; _ITp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _IRef = const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&; _IPtr = const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OTp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>]ΓÇÖ #8 1.490 /usr/include/c++/11/bits/stl_algobase.h:530:31: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.490 /usr/include/c++/11/bits/stl_algobase.h:620:7: required from '_OI std::copy(_II, _II, _OI) [with _II = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.490 /usr/include/c++/11/bits/deque.tcc:119:31: required from 'std::deque<_Tp, _Alloc>& std::deque<_Tp, _Alloc>::operator=(const std::deque<_Tp, _Alloc>&) [with _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Alloc = std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >]ΓÇÖ #8 1.490 zeroforcing/fastqueue.cpp:13963:53: required from here #8 1.490 /usr/include/c++/11/bits/stl_algobase.h:427:46: error: static assertion failed: type is not assignable #8 1.490 427 | static_assert( __assignable::type::value, "type is not assignable" ); #8 1.490 | ^~~~~ #8 1.490 /usr/include/c++/11/bits/stl_algobase.h:427:46: note: 'std::integral_constant<bool, false>::valueΓÇÖ evaluates to false #8 1.492 /usr/include/c++/11/bits/stl_algobase.h: In instantiation of 'static _Tp* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(const _Tp*, const _Tp*, _Tp*) [with _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; bool _IsMove = true]ΓÇÖ: #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:495:30: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OI = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:522:42: required from '_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = true; _II = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OI = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:1060:32: required from 'typename __gnu_cxx::__enable_if<std::__is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type std::__copy_move_a1(_II, _II, std::_Deque_iterator<_Tp, _Tp&, _Tp*>) [with bool _IsMove = true; _II = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; typename __gnu_cxx::__enable_if<std::__is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type = __gnu_cxx::__enable_if<true, std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*> >::__type; typename std::iterator_traits<_II>::iterator_category = std::random_access_iterator_tag]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:1011:36: required from '_OI std::__copy_move_dit(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, _OI) [with bool _IsMove = true; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Ref = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&; _Ptr = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:1043:38: required from 'std::_Deque_iterator<_OTp, _OTp&, _OTp*> std::__copy_move_a1(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_OTp, _OTp&, _OTp*>) [with bool _IsMove = true; _ITp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _IRef = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&; _IPtr = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OTp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:530:31: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:652:38: required from '_OI std::move(_II, _II, _OI) [with _II = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:793:7: required from 'void std::deque<_Tp, _Alloc>::_M_insert_aux(std::deque<_Tp, _Alloc>::iterator, _ForwardIterator, _ForwardIterator, std::deque<_Tp, _Alloc>::size_type) [with _ForwardIterator = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Alloc = std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >; std::deque<_Tp, _Alloc>::iterator = std::_Deque_base<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> > >::iterator; std::deque<_Tp, _Alloc>::size_type = long unsigned int]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:638:17: required from 'void std::deque<_Tp, _Alloc>::_M_range_insert_aux(std::deque<_Tp, _Alloc>::iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Alloc = std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >; std::deque<_Tp, _Alloc>::iterator = std::_Deque_base<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> > >::iterator]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:125:27: required from 'std::deque<_Tp, _Alloc>& std::deque<_Tp, _Alloc>::operator=(const std::deque<_Tp, _Alloc>&) [with _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Alloc = std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >]ΓÇÖ #8 1.492 zeroforcing/fastqueue.cpp:13963:53: required from here #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:427:46: error: static assertion failed: type is not assignable #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:427:46: note: 'std::integral_constant<bool, false>::valueΓÇÖ evaluates to false #8 1.492 /usr/include/c++/11/bits/stl_algobase.h: In instantiation of 'static _Tp* std::__copy_move_backward<_IsMove, true, std::random_access_iterator_tag>::__copy_move_b(const _Tp*, const _Tp*, _Tp*) [with _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; bool _IsMove = true]ΓÇÖ: #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:760:37: required from '_BI2 std::__copy_move_backward_a2(_BI1, _BI1, _BI2) [with bool _IsMove = true; _BI1 = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _BI2 = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:769:51: required from '_BI2 std::__copy_move_backward_a1(_BI1, _BI1, _BI2) [with bool _IsMove = true; _BI1 = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _BI2 = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:1189:41: required from 'typename __gnu_cxx::__enable_if<std::__is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type std::__copy_move_backward_a1(_II, _II, std::_Deque_iterator<_Tp, _Tp&, _Tp*>) [with bool _IsMove = true; _II = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; typename __gnu_cxx::__enable_if<std::__is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type = __gnu_cxx::__enable_if<true, std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*> >::__type; typename std::iterator_traits<_II>::iterator_category = std::random_access_iterator_tag]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:1133:52: required from '_OI std::__copy_move_backward_dit(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, _OI) [with bool _IsMove = true; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Ref = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&; _Ptr = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:1165:47: required from 'std::_Deque_iterator<_OTp, _OTp&, _OTp*> std::__copy_move_backward_a1(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_OTp, _OTp&, _OTp*>) [with bool _IsMove = true; _ITp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _IRef = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&; _IPtr = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*; _OTp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:800:5: required from '_OI std::__copy_move_backward_a(_II, _II, _OI) [with bool _IsMove = true; _II = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _OI = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:894:47: required from '_BI2 std::move_backward(_BI1, _BI1, _BI2) [with _BI1 = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _BI2 = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:833:5: required from 'void std::deque<_Tp, _Alloc>::_M_insert_aux(std::deque<_Tp, _Alloc>::iterator, _ForwardIterator, _ForwardIterator, std::deque<_Tp, _Alloc>::size_type) [with _ForwardIterator = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Alloc = std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >; std::deque<_Tp, _Alloc>::iterator = std::_Deque_base<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> > >::iterator; std::deque<_Tp, _Alloc>::size_type = long unsigned int]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:638:17: required from 'void std::deque<_Tp, _Alloc>::_M_range_insert_aux(std::deque<_Tp, _Alloc>::iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = std::_Deque_iterator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>&, const std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>*>; _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Alloc = std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >; std::deque<_Tp, _Alloc>::iterator = std::_Deque_base<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>, std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> > >::iterator]ΓÇÖ #8 1.492 /usr/include/c++/11/bits/deque.tcc:125:27: required from 'std::deque<_Tp, _Alloc>& std::deque<_Tp, _Alloc>::operator=(const std::deque<_Tp, _Alloc>&) [with _Tp = std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]>; _Alloc = std::allocator<std::pair<long unsigned int, __pyx_t_4sage_15data_structures_11bitset_base_bitset_s [1]> >]ΓÇÖ #8 1.492 zeroforcing/fastqueue.cpp:13963:53: required from here #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:738:46: error: static assertion failed: type is not assignable #8 1.492 738 | static_assert( __assignable::type::value, "type is not assignable" ); #8 1.492 | ^~~~~ #8 1.492 /usr/include/c++/11/bits/stl_algobase.h:738:46: note: 'std::integral_constant<bool, false>::valueΓÇÖ evaluates to false #8 1.523 error: command '/usr/bin/gcc' failed with exit code 1 #8 ERROR: process "/bin/sh -c : && sage --python3 setup.py build_ext ${ZF_BUILD_ARGS} && sage --python3 -m pip install -r test/requirements.txt" did not complete successfully: exit code: 1
​

da-woods

unread,
Jun 13, 2024, 12:58:48 PMJun 13
to cython...@googlegroups.com
Hi Alex,

Not going to be very helpful here I'm afraid.

The essential problem you're running into is that C array types are pretty restricted in terms of copying/moving them - so I think your idea of storing bitset_s in the deque is the right one. Unfortunately it's difficult to get passed how to pass it to the sage functions.

One approach that might work is to write small wrapper functions for everything. Something like

cdef wrapper_func(bitset_s bitset):
    cdef bitset_t copied_bitset
    copied_bitset[0] = bitset
    return function_that_takes_a_bitset(copied_bitset)

It isn't great though.
--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/b17e681b-2c90-4a01-b5f2-2d6ac6f5f580n%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages