0
데이터 (두 번째 필드)를 기준으로 std::map
을 정렬하려고합니다. 그러나 두 번째 필드 자체는 구조체이며 해당 요소 중 하나를 기반으로 정렬하려고합니다. here과 reference이 무엇인지에 따라지도를 벡터에 복사 한 다음 std::sort
을 사용하기로 결정했습니다. 여기에 나는데이터를 기준으로 std :: map 정렬 (map-> vector-> sort)
error C2275: illegal use of this type as an expression
error C2059: syntax error : ')'
내가 무엇을 놓친 않은이 오류, 클래스 implementtion 정렬 기능의 라인에서
#include <iostream>
#include <vector>
#include <map>
#include <utility>
class foo() {
foo() {}
void bar()
{
aDeltaMap theDeltaMap;
// insert some elements to theDeltaMap
aDeltaVector theDeltaVec(theDeltaMap.begin(), theDeltaMap.end());
std::sort(theDeltaVec.begin(), theDeltaVec.end(), descend_rep<deltaPair>()); //ERROR
}
private:
typedef struct entry {
entry(int r, int mc) : rep(r), missCounter(mc) {}
int rep;
int missCounter;
} aDeltaEntry;
typedef std::map< int, aDeltaEntry > aDeltaMap;
typedef std::pair< int, aDeltaEntry > deltaPair;
typedef std::vector<deltaPair> aDeltaVector;
struct descend_rep
: std::binary_function<deltaPair,deltaPair,bool>
{
inline bool operator()(const deltaPair& lhs, const deltaPair& rhs) { return lhs.second.rep > rhs.second.rep; };
};
};
입니까?
대단히 감사합니다. 하나의 데이터 유형 만 있기 때문에 템플릿을 작성할 필요가 없다고 생각했습니다. 그런 다음 템플릿을 삭제하는 것을 잊었습니다. – mahmood