構造体の値として別のマップ/ベクトルの組み合わせを持つマップをロードしようとしました。以下は、私は私ができる限り簡素化しようとした私のコードです:C++ <map、<map, vector>>のデータとして構造体を使用
//These are the structs
struct Order
{
std::string A;
std::string B;
};
struct Card
{
std::string C;
std::string D;
};
struct Item
{
std::string E;
std::string F;
};
//this is the method that will read and load the map
void LoadMap(ListofValues object)
{
std::map<Order, std::map<Item, std::vector<Card>>> records; //THIS is the data structure I'm trying to store into
//ListofValues is a list passed that holds all these values that will need to be put into my map
for(std::vector<ListofValues>::iterator vIter= object.begin(); vIter != object.end(); ++vIter)
{
std::string sReceiptRecord = (*vIter).getReceipt(m_StdOrderConfirmVer);
Order order = {(*vIter).getA,(*vIter).getB};
Item item = {(*vIter).getC,(*vIter).getD};
Card card = {wws::String((*vIter).getE), (*vIter).getF};
records[order][item].push_back(card); //load into my map
}
}
だから私はすべての値(ListofValues)のリストが含まれて渡されたオブジェクトを持つことになります。私はそのリストを繰り返し、getterメソッドを使用して、これらの値を構造体に格納します(getEはLongを返し、変換が必要です)。
error C2678: binary '<' : no operator found which takes a left-hand operand of type 'const Order' (or there is no acceptable conversion)
[mcve]を投稿してください。あなたはコンパイラのエラーがあります。もし私があなたのコードをそのまま使っていたら、私はそれらのトンを持っています。 – PaulMcKenzie
あなたのクラスOrderの演算子<()が必要だと思います。 –
彼は、彼が渡した変数のTYPEで.begin()と.end()を呼び出していると、彼が主張しているエラーをどのようにしているのかよくわかりません。本当にMCVEが必要です – xaxxon