Is a default value of nullptr in a map of pointers defined behaviour?

后端 未结 2 764
别跟我提以往
别跟我提以往 2020-12-11 18:08

The following code seems to always follow the true branch.

#include 
#include 

class TestClass {
  // implementation 
}

int mai         


        
2条回答
  •  猫巷女王i
    2020-12-11 18:53

    Yes, that's defined behaviour. If an element isn't yet in a map when you access it via operator[], it gets default constructed.

提交回复
热议问题