2nd call to partial_sort gives 'no match...' error, but 1st is OK. Doesn't seem right.
#include <algorithm> #include <vector> template<typename vector_t> struct Sort_Func2 { vector_t const& mag; Sort_Func2 (vector_t const& _mag) : mag (_mag) {} bool operator() (int a, int b) const { return mag [a] < mag [b]; } }; template<typename vector_t> void F (vector_t const& v) { struct Sort_Func { vector_t const& mag; Sort_Func (vector_t const& _mag) : mag (_mag) {} bool operator() (int a, int b) const { return mag [a] < mag [b]; } }; std::vector<int> indexes (v.size()); std::partial_sort (indexes.begin(), indexes.begin()+2, indexes.end(), Sort_Func2<vector_t> (v)); std::partial_sort (indexes.begin(), indexes.begin()+2, indexes.end(), Sort_Func (v)); } int main() { std::vector<int> v; F (v); } -- Summary: local structure problem Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ndbecker2 at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31951