|
-
September 15th, 2004, 03:08 PM
#1
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
-
September 15th, 2004, 03:26 PM
#2
Re: STL Map copntaining vector of structs.
 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
-
September 15th, 2004, 04:21 PM
#3
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.
-
September 15th, 2004, 04:23 PM
#4
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 __)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|