Q: error C2664: cannot convert parameter 1 from 'const std::basic_string<_Elem,_Traits,_Ax>' to 'std::wstring & error C2664: 'CCertStoreHelper::DeleteCtl' : cannot convert parameter 1 from 'const std::basic_string<_Elem,_Traits,_Ax>' to 'std::wstring &error C2664: 'CCertStoreHelper::DeleteCtl' : cannot convert parameter 1 from 'const std::basic_string<_Elem,_Traits,_Ax>' to 'std::wstring &
with
      [
              _Elem=wchar_t,
              _Traits=std::char_traits<wchar_t>,
              _Ax=std::allocator<wchar_t>
      ]
      Conversion loses qualifiers

I have no idea regarding this. So kindly provide the solution.
Code:
CCertStoreHelper certCaStore;
std::set<std::wstring> ctlIdentifiersToRemove; // It populates data which I m not mentioning


std::set<std::wstring>::iterator iter1;
std::set<std::wstring>::iterator iter2;

for(iter1 = ctlIdentifiersToRemove.begin(); iter1 != ctlIdentifiersToRemove.end(); iter1++)
{
    iter2 = ctlIdentifiersReferenced.find((*iter1));
    if(iter2 == ctlIdentifiersReferenced.end()) 
    {
        if(certCaStore.DeleteCtl((*iter1))) // error line
        {
            // ...
        }
    }
}
// prototype for DeleteCtl fun is
bool CCertStoreHelper::DeleteCtl(std::wstring &ctlIdentifier)

Kindly correct me what i am doing wrong
Thanks

A: As twalberg points out, the most important bit of the compiler error message is the "loses qualifiers" bit. It also tells you that it can't convert from const std::wstring to std::wstring&, except that it expanded the first std::wstring into its full template instantiation form.
The issue is that your DeleteCtl takes the argument by non-const reference, as if it wants to modify the string there (bad idea), but it can't do that, because you're iterating over a set, and you cannot change the members of a set once they're in there (std::set doesn't make a difference between const_iterator and iterator, essentially). The reason is that std::set bases its internal structure on the values of its elements, and if you change those values, the internal structure becomes invalid, and horrible things happen.
