나는 clang 3.4-1ubuntu3를 사용하고 있습니다. 내가 std::vector::emplace(const_iterator pos, Args&&... args)
를 호출 할 때, 나는 오류emplace가 const_iterator 대신 iterator를 사용하는 이유는 무엇입니까?
my_file.hpp:86:9: error: no matching member function for call to 'emplace'
store.emplace(pos, args...);
~~~~~~^~~~~~~
...
/usr/include//c++/4.8/bits/stl_vector.h:958:9: note: candidate function ... not viable: no known
conversion from '__normal_iterator<const_pointer, [...]>' to '__normal_iterator<pointer, [...]>' for 1st argument
emplace(iterator __position, _Args&&... __args);
^
을 얻을 그러나 cppreference, std::vector::emplace
takes a const_iterator에 따라. 무슨 일 이니?
나는 cppreference가 잘못되었다고 생각합니다. 'emplace'에'const_iterator'를 사용하는 것은 엄청난 의미가없는 것처럼 보입니다. – Cubic
@Cubic 표준에 따르면'std :: vector :: emplace'는 실제로'const_iterator'를 취합니다. (어떤 의미가 있고, 다른 변이하는 멤버 함수도'const_iterator'를 사용합니다. 결국, 벡터가 아닌 const 컨텍스트에서 반복자 * 자체를 사용하지 않고 있습니다.) – Sneftel
@Sneftel Huh, interesting. 나는 그것이 어떻게 작동하는지 오해했다. 감사. – Cubic