0
votes

Hi so i have two Problems:

  1. cannot convert from 'std::vector<_Ty>' to 'std::vector<_Ty> &

    void CMapObjectPropertyPageAmbience::OnUpdateUI(CProperty* pProperty)
    {
        prt::PropertyAmbienceStringToData(pProperty, &m_propertyAmbience);
    
        std::vector<CFilename>& rSoundFileNameVector = m_propertyAmbience.AmbienceSoundVector;
        for (DWORD dwIndex = 0; dwIndex < rSoundFileNameVector.size(); ++dwIndex)
        {
            m_ctrlSoundFileList.InsertString(dwIndex, rSoundFileNameVector[dwIndex].c_str());
        }
    
        m_ctrlPlayType.SelectString(-1, m_propertyAmbience.strPlayType.c_str());
    
        SetDialogFloatText(GetSafeHwnd(), IDC_MAP_OBJECT_PROPERTY_AMBIENCE_INTERVAL, m_propertyAmbience.fPlayInterval);
        SetDialogFloatText(GetSafeHwnd(), IDC_MAP_OBJECT_PROPERTY_AMBIENCE_INTERVAL_VARIATION, m_propertyAmbience.fPlayIntervalVariation);
        SetDialogFloatText(GetSafeHwnd(), IDC_MAP_OBJECT_PROPERTY_AMBIENCE_MAX_VOLUME_AREA_PERCENTAGE, m_propertyAmbience.fMaxVolumeAreaPercentage * 100.0f);
    
        OnUpdatePropertyData(m_propertyAmbience.strName.c_str());
        OnChangePlayType();
    }
    

    The Error appears at:

    std::vector<CFilename>& rSoundFileNameVector = m_propertyAmbience.AmbienceSoundVector;
    
  2. None of the 2 overloads could convert all the argument types:

    void CMapObjectPropertyPageAmbience::OnDeleteSoundFile()
    {
        DWORD dwCurSel = DWORD(m_ctrlSoundFileList.GetCurSel());
        if (dwCurSel >= m_propertyAmbience.AmbienceSoundVector.size())
            return;
    
        DeleteVectorItem < CFilename > ( & m_propertyAmbience.AmbienceSoundVector, dwCurSel);
        m_ctrlSoundFileList.DeleteString(dwCurSel);
    }
    

    at DeleteVectorItem<CFilename>(&m_propertyAmbience.AmbienceSoundVector, dwCurSel);

Full Errors

1>Dialog\MapObjectPropertyPageAmbience.cpp(78): error C2440: 'initializing' : cannot convert from 'std::vector<_Ty>' to 'std::vector<_Ty> &'
1>          with
1>          [
1>              _Ty=std::string
1>          ]
1>          and
1>          [
1>              _Ty=CFilename
1>          ]
1>Dialog\MapObjectPropertyPageAmbience.cpp(205): error C2665: 'DeleteVectorItem' : none of the 2 overloads could convert all the argument types
1>          d:\dev\kraizy\novaline\srcs\client\eterpack\../eterBase/Stl.h(146): could be 'void DeleteVectorItem<CFilename>(std::vector<_Ty> *,unsigned long)'
1>          with
1>          [
1>              _Ty=CFilename
1>          ]
1>          d:\dev\kraizy\novaline\srcs\client\eterpack\../eterBase/Stl.h(191): or       'void DeleteVectorItem<CFilename>(std::vector<_Ty> *,T)'
1>          with
1>          [
1>              _Ty=CFilename,
1>              T=CFilename
1>          ]
1>          while trying to match the argument list '(std::vector<_Ty> *, DWORD)'
1>          with
1>          [
1>              _Ty=std::string
1>          ]
1
What type is m_propertyAmbience.AmbienceSoundVector? Show the exact and complete text of the error messaged - it will tell you what types the compiler thinks _Ty stands for, and what functions the compiler considered and rejected when looking for a suitable overload. - Igor Tandetnik
There are usually follow-up lines that explain what _Ty is. Look at the Output window. - Igor Tandetnik
&m_propertyAmbience.AmbienceSoundVector that is taking address of this vector, remove & - marcinj
That looks horrible in the comments. Can you add it to your question with <pre>...</pre>? - leemes
Please add the errors as an edit to the original question and remove those comments afterwards. This will increase the readibilty greatly! - nietonfir

1 Answers

1
votes

You are trying to use vector<string> in places where vector<CFilename> is expected. Those are completely unrelated types.