python - Cython: std::sort on C++ vector -


i'm having trouble compiling using libcpp.algorithm.sort (std::sort) on libcpp.vector. short code below:

from libcpp.algorithm cimport sort stdsort libcpp.vector cimport vector  cdef sort_something(mylist):     myvec = vector[int]()     num in mylist: myvec.push_back(num)     stdsort(myvec.begin(), myvec.end()) 

this using standard syntax using std::sort on c++ vector. angry compiler messages. reference, setup.py file:

from distutils.core import setup cython.build import cythonize  setup(     ext_modules=cythonize("*.pyx", language="c++") ) 

this compiler output. (warning: it's long, , can't comprehend it.)

python setup.py build_ext --inplace running build_ext building 'sample' extension cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -os -pipe -fno-common -fno-strict-aliasing -fwrapv -denable_dtrace -dmacosx -dndebug -wall -wstrict-prototypes -wshorten-64-to-32 -dndebug -g -fwrapv -os -wall -wstrict-prototypes -denable_dtrace -arch x86_64 -arch i386 -pipe -i/system/library/frameworks/python.framework/versions/2.7/extras/lib/python/numpy/core/include -i/system/library/frameworks/python.framework/versions/2.7/include/python2.7 -c sample.cpp -o build/temp.macosx-10.10-intel-2.7/sample.o in file included sample.cpp:257: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:702:71: error: invalid operands binary expression ('const _object' , 'const _object')     bool operator()(const _t1& __x, const _t1& __y) const {return __x < __y;}                                                                   ~~~ ^ ~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3862:17: note: in instantiation of member function 'std::__1::__less<_object, _object>::operator()' requested here             if (__comp(*--__last, *__first))                 ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4048:5: note: in instantiation of function template specialization 'std::__1::__sort<std::__1::__less<_object, _object> &, _object *>' requested here     __sort<_comp_ref>(__first, __last, __comp);     ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4057:12: note: in instantiation of function template specialization 'std::__1::sort<_object *, std::__1::__less<_object, _object> >' requested here     _vstd::sort(__first, __last, __less<typename iterator_traits<_randomaccessiterator>::value_type>());            ^ sample.cpp:855:8: note: in instantiation of function template specialization 'std::__1::sort<_object *>' requested here   std::sort<pyobject *>(__pyx_t_2, __pyx_t_5);        ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/utility:424:1: note: candidate template ignored: not match 'pair<type-parameter-0-0, type-parameter-0-1>' against 'const _object' operator< (const pair<_t1,_t2>& __x, const pair<_t1,_t2>& __y) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/iterator:592:1: note: candidate template ignored: not match 'reverse_iterator<type-parameter-0-0>' against 'const _object' operator<(const reverse_iterator<_iter1>& __x, const reverse_iterator<_iter2>& __y) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/iterator:996:1: note: candidate template ignored: not match 'move_iterator<type-parameter-0-0>' against 'const _object' operator<(const move_iterator<_iter1>& __x, const move_iterator<_iter2>& __y) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/iterator:1312:1: note: candidate template ignored: not match '__wrap_iter<type-parameter-0-0>' against 'const _object' operator<(const __wrap_iter<_iter1>& __x, const __wrap_iter<_iter2>& __y) _noexcept ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/memory:2917:1: note: candidate template ignored: not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'const _object' operator< (const unique_ptr<_t1, _d1>& __x, const unique_ptr<_t2, _d2>& __y) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/memory:2975:1: note: candidate template ignored: not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'const _object' operator<(const unique_ptr<_t1, _d1>& __x, nullptr_t) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/memory:2984:1: note: candidate template ignored: not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'const _object' operator<(nullptr_t, const unique_ptr<_t1, _d1>& __x) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/memory:4774:1: note: candidate template ignored: not match 'shared_ptr<type-parameter-0-0>' against 'const _object' operator<(const shared_ptr<_tp>& __x, const shared_ptr<_up>& __y) _noexcept ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/memory:4839:1: note: candidate template ignored: not match 'shared_ptr<type-parameter-0-0>' against 'const _object' operator<(const shared_ptr<_tp>& __x, nullptr_t) _noexcept ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/memory:4847:1: note: candidate template ignored: not match 'shared_ptr<type-parameter-0-0>' against 'const _object' operator<(nullptr_t, const shared_ptr<_tp>& __x) _noexcept ^ in file included sample.cpp:257: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3649:20: error: no matching function call '__sort3'     unsigned __r = __sort3<_compare>(__x1, __x2, __x3, __c);                    ^~~~~~~~~~~~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3869:20: note: in instantiation of function template specialization 'std::__1::__sort4<std::__1::__less<_object, _object> &, _object *>' requested here             _vstd::__sort4<_compare>(__first, __first+1, __first+2, --__last, __comp);                    ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4048:5: note: in instantiation of function template specialization 'std::__1::__sort<std::__1::__less<_object, _object> &, _object *>' requested here     __sort<_comp_ref>(__first, __last, __comp);     ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4057:12: note: in instantiation of function template specialization 'std::__1::sort<_object *, std::__1::__less<_object, _object> >' requested here     _vstd::sort(__first, __last, __less<typename iterator_traits<_randomaccessiterator>::value_type>());            ^ sample.cpp:855:8: note: in instantiation of function template specialization 'std::__1::sort<_object *>' requested here   std::sort<pyobject *>(__pyx_t_2, __pyx_t_5);        ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3609:1: note: candidate template ignored: substitution failure [with _compare = std::__1::__less<_object, _object> &, _forwarditerator = _object *] __sort3(_forwarditerator __x, _forwarditerator __y, _forwarditerator __z, _compare __c) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3675:20: error: no matching function call '__sort4'     unsigned __r = __sort4<_compare>(__x1, __x2, __x3, __x4, __c);                    ^~~~~~~~~~~~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3872:20: note: in instantiation of function template specialization 'std::__1::__sort5<std::__1::__less<_object, _object> &, _object *>' requested here             _vstd::__sort5<_compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);                    ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4048:5: note: in instantiation of function template specialization 'std::__1::__sort<std::__1::__less<_object, _object> &, _object *>' requested here     __sort<_comp_ref>(__first, __last, __comp);     ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4057:12: note: in instantiation of function template specialization 'std::__1::sort<_object *, std::__1::__less<_object, _object> >' requested here     _vstd::sort(__first, __last, __less<typename iterator_traits<_randomaccessiterator>::value_type>());            ^ sample.cpp:855:8: note: in instantiation of function template specialization 'std::__1::sort<_object *>' requested here   std::sort<pyobject *>(__pyx_t_2, __pyx_t_5);        ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3646:1: note: candidate template ignored: substitution failure [with _compare = std::__1::__less<_object, _object> &, _forwarditerator = _object *] __sort4(_forwarditerator __x1, _forwarditerator __x2, _forwarditerator __x3, ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3740:5: error: no matching function call '__sort3'     __sort3<_compare>(__first, __first+1, __j, __comp);     ^~~~~~~~~~~~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3877:20: note: in instantiation of function template specialization 'std::__1::__insertion_sort_3<std::__1::__less<_object, _object> &, _object *>' requested       here             _vstd::__insertion_sort_3<_compare>(__first, __last, __comp);                    ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4048:5: note: in instantiation of function template specialization 'std::__1::__sort<std::__1::__less<_object, _object> &, _object *>' requested here     __sort<_comp_ref>(__first, __last, __comp);     ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4057:12: note: in instantiation of function template specialization 'std::__1::sort<_object *, std::__1::__less<_object, _object> >' requested here     _vstd::sort(__first, __last, __less<typename iterator_traits<_randomaccessiterator>::value_type>());            ^ sample.cpp:855:8: note: in instantiation of function template specialization 'std::__1::sort<_object *>' requested here   std::sort<pyobject *>(__pyx_t_2, __pyx_t_5);        ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3609:1: note: candidate template ignored: substitution failure [with _compare = std::__1::__less<_object, _object> &, _forwarditerator = _object *] __sort3(_forwarditerator __x, _forwarditerator __y, _forwarditerator __z, _compare __c) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3773:9: error: no matching function call '__sort3'         _vstd::__sort3<_compare>(__first, __first+1, --__last, __comp);         ^~~~~~~~~~~~~~~~~~~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/__config:366:15: note: expanded macro '_vstd' #define _vstd std::_libcpp_namespace               ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4003:32: note: in instantiation of function template specialization 'std::__1::__insertion_sort_incomplete<std::__1::__less<_object, _object> &, _object *>'       requested here             bool __fs = _vstd::__insertion_sort_incomplete<_compare>(__first, __i, __comp);                                ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4048:5: note: in instantiation of function template specialization 'std::__1::__sort<std::__1::__less<_object, _object> &, _object *>' requested here     __sort<_comp_ref>(__first, __last, __comp);     ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:4057:12: note: in instantiation of function template specialization 'std::__1::sort<_object *, std::__1::__less<_object, _object> >' requested here     _vstd::sort(__first, __last, __less<typename iterator_traits<_randomaccessiterator>::value_type>());            ^ sample.cpp:855:8: note: in instantiation of function template specialization 'std::__1::sort<_object *>' requested here   std::sort<pyobject *>(__pyx_t_2, __pyx_t_5);        ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3609:1: note: candidate template ignored: substitution failure [with _compare = std::__1::__less<_object, _object> &, _forwarditerator = _object *] __sort3(_forwarditerator __x, _forwarditerator __y, _forwarditerator __z, _compare __c) ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3776:9: error: no matching function call '__sort4'         _vstd::__sort4<_compare>(__first, __first+1, __first+2, --__last, __comp);         ^~~~~~~~~~~~~~~~~~~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/__config:366:15: note: expanded macro '_vstd' #define _vstd std::_libcpp_namespace               ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3646:1: note: candidate template ignored: substitution failure [with _compare = std::__1::__less<_object, _object> &, _forwarditerator = _object *] __sort4(_forwarditerator __x1, _forwarditerator __x2, _forwarditerator __x3, ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3779:9: error: no matching function call '__sort5'         _vstd::__sort5<_compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);         ^~~~~~~~~~~~~~~~~~~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/__config:366:15: note: expanded macro '_vstd' #define _vstd std::_libcpp_namespace               ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3672:1: note: candidate template ignored: substitution failure [with _compare = std::__1::__less<_object, _object> &, _forwarditerator = _object *] __sort5(_forwarditerator __x1, _forwarditerator __x2, _forwarditerator __x3, ^ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3784:5: error: no matching function call '__sort3'     __sort3<_compare>(__first, __first+1, __j, __comp);     ^~~~~~~~~~~~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3609:1: note: candidate template ignored: substitution failure [with _compare = std::__1::__less<_object, _object> &, _forwarditerator = _object *] __sort3(_forwarditerator __x, _forwarditerator __y, _forwarditerator __z, _compare __c) ^ 8 errors generated. error: command 'cc' failed exit status 1 make: *** [all] error 1 

what not doing right sort vector?

look @ first error message: "invalid operands binary expression ('const _object' , 'const _object')" , line quotes indirectly std::less, default comparison function when using std::sort. reason error c++ sequence being sorted seems made of _object instances, not of integers seem assume, , type less-than comparison not defined.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

Fatal error: Call to undefined function menu_execute_active_handler() in drupal 7.9 -

python - RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK -