[英]Error: no matching function for call C++
我是C ++的新手。 我已经实现了一个B +树,它在Macbook(带有CLion)上可以正常工作,但是当我在ubuntu服务器上运行它时,下面给出了编译错误。 有人可以帮忙吗?
error: no matching function for call to
‘std::vector<std::__cxx11::basic_string<char>
>::vector(__gnu_cxx::__normal_iterator<const
std::__cxx11::basic_string<char>*,
std::vector<std::__cxx11::basic_string<char> > >,
std::vector<std::__cxx11::basic_string<char> >::iterator)’
在Mac上g ++ -v的结果:
配置为:--prefix = / Library / Developer / CommandLineTools / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1 Apple LLVM版本9.0.0(clang-900.0.38)目标: x86_64-apple-darwin16.7.0线程模型:posix InstalledDir:/ Library / Developer / CommandLineTools / usr / bin
g ++ -v在ubuntu服务器上的结果:
gcc版本5.4.0 20160609(Ubuntu 5.4.0-6ubuntu1〜16.04.5)
引发错误的代码段:
std::pair<InternalNode *, Node *> split(int order) {
std::vector<float>::const_iterator old_dn_keys_end = keys.begin() + ceil(float(order) / 2) - 2;
std::vector<std::string>::const_iterator old_dn_values_end = values.begin() + ceil(float(order) / 2) - 2;
new_dn->keys = std::vector<float>(old_dn_keys_end + 1, keys.end());
//**--- error here ---**
new_dn->values = std::vector<std::string>(old_dn_values_end + 1,
values.end());
//rest of the code...
}
使用迭代器构造std::vector
要求它们具有相同的类型。 看起来您正在使用vector<>::const_iterator
和vector<>::iterator
(通过.end()
)构造它。
将old_dn_values_end
非常量迭代器,或使用.cend()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.