내가이 맵에 삽입하려고 :이있어C++ 부울 표준 : 운영자 키 표준지도와 <오류 :: unordered_set <INT, 표준 : 해시 <int>>
std::map<std::unordered_set<int >, std::pair<float, std::pair<float, float >> >
오류
내 데이터로 정의오류 C2784 : '부울 표준 : 운영자 < (const를 표준 : _ 트리 < _Traits> &, const를 표준 : _ 트리 < _Traits> &가) : CONST 표준 : _ _Traits> & '에서'const를 표준 : unordered_set, 표준 : equal_to < _Kty>, 표준 : : 할당 < _Kty >> '
트리 <을' 에 대한 템플릿 인수를 추론 할 수 없었다 '
은 다음 :
struct Trans {
int Item;
float Prob;
float W;
};
bool operator<(const Trans &a, const Trans &b)
{
return a.Item < b.Item;
}
bool operator==(Trans c, Trans d) { return c.Item == d.Item; }
struct MyHash {
size_t operator()(const Trans& x) const { return std::hash<int>()(x.Item); }
};
std::vector<std::vector<Trans>> data;
std::map<std::unordered_set<int>, float> S1;
std::map<std::unordered_set<int >, std::pair<float, std::pair<float, float >> > S2;
std::map<std::unordered_set<int >, std::pair<float, std::pair<float, float >> > S3;
문제가 부분 :
를do
{
std::unordered_set<Trans, MyHash> KS(data[i].begin(), data[i].begin() + k);
std::unordered_set<int > elem;
float esupp = 1;
float Weight = 0;
float Wesupp = 1;
for (auto const &iter : KS)
{
elem.insert(iter.Item);
esupp *= iter.Prob;
Weight += iter.W;
}
Weight = Weight/k;
/*
some code, and until here I didn't get any problem
*/
**// This the area that has the problem**
S1[elem] = std::move(S1[elem] + esupp);
Wesupp = Weight * S1[elem];
S2[elem].first = std::move(S2[elem].first + esupp);
S2[elem].second = std::make_pair(elem, Wesupp);
} while (next_combination(data[i].begin(), data[i].begin() + k, data[i].end()));
오류가있는 실제 행은 무엇입니까? –
나머지 부분을 제외하고,이 줄은 옳지 않습니다 :'S2 [elem] .second = std :: make_pair (elem, Wesupp); ' –
데이터 구조 디자인 ...'unordered_set'을 키로서 심각하게 재검토하겠습니까? 'std :: pair>'? '[elem] = std :: move (S1 [elem] + esupp)''에서'S2 [elem] (적어도'std :: tuple' 또는'std :: array ') –