I defined a class with the name of wordMultiSet, inside there is
a private variable: multiset<string, CompareWords> wordset;
then in one of the member function I tried to create a temporary multiset to store the set of string after deleting the duplicates in wordset, like the following,
1 2
|
multiset<string,CompareWords> temp = wordset;
auto it = unique(temp.begin(), temp.end());
|
but I got the compiling error:
`1>------ Build started: Project: ConsoleApplication6, Configuration: Debug Win32 ------
1> WordMultiSet.cpp
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(1825): error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const std::basic_string<_Elem,_Traits,_Alloc>' (or there is no acceptable conversion)
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(912): could be 'std::basic_string<_Elem,_Traits,_Alloc> &std::basic_string<_Elem,_Traits,_Alloc>::operator =(std::basic_string<_Elem,_Traits,_Alloc> &&) throw()'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(969): or 'std::basic_string<_Elem,_Traits,_Alloc> &std::basic_string<_Elem,_Traits,_Alloc>::operator =(const std::basic_string<_Elem,_Traits,_Alloc> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(987): or 'std::basic_string<_Elem,_Traits,_Alloc> &std::basic_string<_Elem,_Traits,_Alloc>::operator =(const _Elem *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(992): or 'std::basic_string<_Elem,_Traits,_Alloc> &std::basic_string<_Elem,_Traits,_Alloc>::operator =(_Elem)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> while trying to match the argument list '(const std::basic_string<_Elem,_Traits,_Alloc>, const std::basic_string<_Elem,_Traits,_Alloc>)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(1836) : see reference to function template instantiation '_FwdIt std::_Unique<std::_Tree_unchecked_const_iterator<_Mytree>>(_FwdIt,_FwdIt)' being compiled
1> with
1> [
1> _FwdIt=std::_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>>,
1> _Mytree=std::_Tree_val<std::_Tree_simple_types<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>
1> ]
1> f:\cpp\consoleapplication6\wordmultiset.cpp(53) : see reference to function template instantiation '_FwdIt std::unique<std::_Tree_const_iterator<_Mytree>>(_FwdIt,_FwdIt)' being compiled
1> with
1> [
1> _FwdIt=std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>>,
1> _Mytree=std::_Tree_val<std::_Tree_simple_types<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
`
can anybody tell me what I did wrong ?
thanks