我正在使用clang 3.4-1ubuntu3。当我尝试拨打std::vector::emplace(const_iterator pos, Args&&... args)
时,我收到了错误
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。这是怎么回事?
答案 0 :(得分:2)
这对我来说就像是编译器中的错误(或者更准确地说,是标准库)。根据标准(§23.3.6.1),签名应为:
template <class... Args> iterator emplace(const_iterator position, Args&&... args);