在使用push_back of std::vector时,我可以推送向量本身的元素,而不必担心由于重新分配而使参数无效:
std::vector<std::string> v = { "a", "b"但是,在使用emplace_back时,std::vector将参数转发给std::string的构造函数,以便在向量中进行复制构造
如果我使用vector<int>::iterator来跟踪int's向量中的某个位置,然后使用vector<int>::push_back(),迭代器就变得毫无价值。当我按以下含义打印一些对象的地址时,直接原因就有意义了:
vector<int>::iterator it = my_vec.begin对于数组来说,my_array是