Hi Donovan,
Thank you for your answer. As I'm trying to use set<> on std::wstring (not
"int" in my actual case), I get a lot of error messages when compiling, like
this:
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\utility(41) :
error C2664: 'std::set<_Kty>::set(const std::set<_Kty>::key_compare &)' :
cannot convert parameter 1 from 'const std::allocator<_Ty>::value_type' to
'const std::set<_Kty>::key_compare &'
with
[
_Kty=std::wstring
]
and
[
_Ty=std::wstring
]
and
[
_Kty=std::wstring
]
Reason: cannot convert from 'const std::allocator<_Ty>::value_type'
to 'const std::set<_Kty>::key_compare'
with
[
_Ty=std::wstring
]
and
[
_Kty=std::wstring
]
No constructor could take the source type, or constructor overload
resolution was ambiguous
f:\-= Projects =-\-= Programming
=-\MediaMan\MediaMan\Framework\System\RegKeyEx.h(93) : see reference to
function template instantiation
'std::pair<_Ty1,_Ty2>::pair<std::wstring,std::allo cator<_Ty>::value_type>(const
std::pair<std::wstring,std::allocator<_Ty>::value_ type> &)' being compiled
with
[
_Ty1=const std::wstring,
_Ty2=std::set<std::wstring>,
_Ty=std::wstring
]
I'm wondering, as I'm not familiar with std::set, can it be used with
std::wstring, std::string or other objects?
Thanks,
--
He Shiming
"Donovan Hawkins" <ha*****@uci.edu> wrote in message
news:it******************@twister.socal.rr.com...
"He Shiming" <mailbill(NOSPAM)@21cn.com.nospam> wrote in message
news:33*************@individual.net... Happy holidays! I have a question regarding STL multimap. Basically, the
current multimap<int,int> look like this:
key=>value
1=>10,
1=>20,
1=>30,
When I'm inserting new key value pairs, I need to ensure that those pairs
already in the multimap can't be inserted again. Say that 1=>40 is okay,
but 1=>10 is not okay. So that I get unique key->value pairs in the multimap.
How about using a map< int, set<int> > instead?
std::map< int, std::set<int> > m;
m[1].insert(10);
m[1].insert(20);
m[1].insert(30);
m[1].insert(40);
m[1].insert(10);
assert( m[1].size() == 4 );
Donovan Hawkins