STL Map copntaining vector of structs.
I'm having a problem with
Itr = MMIDCache.insert(Itr, MMIDList::value_type(NMKey, MMIDStructs));
where MMIDStructs is a typedef of my vector. I've tried using the long form(non typedef) std::vector<MMIData> and I still get the error C2275: 'MMIDStructs' : illegal use of this type as an expression.
Is this even possible to do or am I just lost in the syntax?
Thanks,
Doug
Re: STL Map copntaining vector of structs.
Quote:
Originally Posted by doug760
I'm having a problem with
Itr = MMIDCache.insert(Itr, MMIDList::value_type(NMKey, MMIDStructs));
where MMIDStructs is a typedef of my vector. I've tried using the long form(non typedef) std::vector<MMIData> and I still get the error C2275: 'MMIDStructs' : illegal use of this type as an expression.
Is this even possible to do or am I just lost in the syntax?
Thanks,
Doug
Please post a complete example that duplicates the error. Explanations in English are not as effective as seeing your actual code.
Regards,
Paul McKenzie
Re: STL Map copntaining vector of structs.
Code:
Itr = MMIDCache.insert(Itr, MMIDList::value_type(NMKey, MMIDStructs));
Is MMIDList a map<>?
If yes, value_type is a typedef:
Code:
typedef pair<const Key, T> value_type;
so you want to use of of the pair's constructors:
Code:
pair();
pair(const T& x, const U& y);
template<class V, class W>
pair(const pair<V, W>& pr);
You can see that all constructors require values, not types, as parameters.
Re: STL Map copntaining vector of structs.
Maybe you'll have to use make_pair.
The declaration of make_pair is:
Code:
template<class T, class U>
pair<T, U> make_pair(const T& x, const U& y);
so you can use make_pair<NMKey, MMIDStructs>(__ the value of the NMKey__, __ the value of MMIDStructs __)