0

In my Single Document Application I have this situation:

 class CObj
 {
 public:
      int m_nValue;
 // Rest of class implementation
 };
 typedef std::vector<CObj> CObjects;
 typedef std::unordered_map<double, CObjects> CObjects_2;
 typedef std::map<CString, CObjects_2> CObjects_3;

 class CMyDoc : public CDocument
 {
 protected:
      CObjects_3   m_Data;
 public:
      inline CObjects_3 & Data()
      {
           return m_Data;
      }
 }

 // Somewhere in the program:
 //...
 // Assuming that all keys exist:
 CObjects_3 & non_auto_data = pValidDocPointer->Data();
 non_auto_data[_T("Key")][3.0][0].m_nValue = 10;
 auto auto_data = m_pValidDocPointer->Data();
 auto_data[_T("Key")][3.0][0].m_nValue = 20;
 //...

Now, if I understood well how keyword auto works, I expect that

pValidDocPointer->m_Data[_T("Key")][3.0][0].m_nValue

will have a value of 20, but I see 10. Is that a Visual Studio bug or it is correct? If correct: what I misunderstood in auto keyword functioning?

IssamTP
  • 2,408
  • 1
  • 25
  • 48

0 Answers0