std::sort kann nicht kompiliert werden
-
Hallo,
ich möchte gerne einen Vektor eines selbstgewählt struct sortieren. das sieht erst einmal wie folgt aus
struct poly { float a, b, c, fDistance, fDeltaFInvSquare; }; ... struct IsLessPredicate { bool operator () ( poly & elem1, poly & elem2 ) { return elem1.fDistance < elem2.fDistance; } }; ... bool method(...) { static vector<poly> polynomMap; ... std::sort(polynomMap.begin(),polynomMap.end(), IsLessPredicate()); }leider kann gcc 3.4.5 dies nicht kompilieren und bringt folgenden Fehler
no match for call to `(IsLessPredicate) (const poly&, const poly&)'
raytrace line 124, external location: C:\mingw\include\c++\3.4.5\bits\stl_algo.hWeiß jemand etwas damit anzufangen? Ich hatte das mal so programmiert und nun wollte ich das auf einem neueren GCC kompilieren lassen und es geht eben nicht mehr. Ich bin etwas ratlos.
Hier noch der Consolen-Auswurf
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h: In functionconst _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) [with _Tp = poly, _Compare = IsLessPredicate]':C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:2519: instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<poly*, std::vector<poly, std::allocator<poly> > >, _Size = int, _Compare = IsLessPredicate]'
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:2589: instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<poly*, std::vector<poly, std::allocator<poly> > >, _Compare = IsLessPredicate]'
..\src\Blob.cpp:184: instantiated from here
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:124: error: no match for call to `(IsLessPredicate) (const poly&, const poly&)'
..\src\Blob.cpp:90: note: candidates are: bool IsLessPredicate::operator()(poly&, poly&)
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:125: error: no match for call to `(IsLessPredicate) (const poly&, const poly&)'
..\src\Blob.cpp:90: note: candidates are: bool IsLessPredicate::operator()(poly&, poly&)
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:127: error: no match for call to `(IsLessPredicate) (const poly&, const poly&)'
..\src\Blob.cpp:90: note: candidates are: bool IsLessPredicate::operator()(poly&, poly&)
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:131: error: no match for call to `(IsLessPredicate) (const poly&, const poly&)'
..\src\Blob.cpp:90: note: candidates are: bool IsLessPredicate::operator()(poly&, poly&)
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:133: error: no match for call to `(IsLessPredicate) (const poly&, const poly&)'
..\src\Blob.cpp:90: note: candidates are: bool IsLessPredicate::operator()(poly&, poly&)
Build error occurred, build is stopped`
Ich würde mich freuen, wenn mir jemand helfen könnte?! Oder gibt es eine andere Lösung für diese Art der sortierung.. kenne nichts anderes.
Gruß lindner
-
struct IsLessPredicate { bool operator () ( const poly & elem1, const poly & elem2 ) const { return elem1.fDistance < elem2.fDistance; } };