gpt4 book ai didi

c++ - 提示在 boost 中的行为与在标准库中的行为不同?

转载 作者:行者123 更新时间:2023-12-02 18:40:59 25 4
gpt4 key购买 nike

我正在尝试使用提示插入 boost::flat_map , 但明显的语法不会编译,即使当我使用提示来放置 std::map 时它确实编译了.我是否遗漏了一些明显的东西?

#include <boost/container/flat_map.hpp>
#include <map>

int main() {
std::map<int, int> map;
map.emplace_hint(map.begin(), 0, 0); // compiles fine

boost::container::flat_map<int, int> flat_map;
flat_map.insert_or_assign(flat_map.begin(), 0, 0); // does not compile fine

return 0;
}

编译错误是:

g++   -I.  -I../boost_1_65_1 -Wall -O3  -Wsign-compare -Wno-strict-aliasing -Wno-parentheses -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -std=c++14 -g -ggdb   -c -o main.o main.cpp
In file included from main.cpp:1:0:
../boost_1_65_1/boost/container/flat_map.hpp: In instantiation of ‘boost::container::flat_map<Key, T, Compare, Allocator>::iterator boost::container::flat_map<Key, T, Compare, Allocator>::insert_or_assign(boost::container::flat_map<Key, T, Compare, Allocator>::const_iterator, boost::container::flat_map<Key, T, Compare, Allocator>::key_type&&, M&&) [with M = int; Key = int; T = int; Compare = std::less<int>; Allocator = boost::container::new_allocator<std::pair<int, int> >; boost::container::flat_map<Key, T, Compare, Allocator>::iterator = boost::container::container_detail::vec_iterator<std::pair<int, int>*, false>; boost::container::flat_map<Key, T, Compare, Allocator>::const_iterator = boost::container::container_detail::vec_iterator<std::pair<int, int>*, true>; boost::container::flat_map<Key, T, Compare, Allocator>::key_type = int]’:
main.cpp:9:53: required from here
../boost_1_65_1/boost/container/flat_map.hpp:771:10: error: could not convert ‘boost::container::container_detail::force_copy(const S&) [with D = std::pair<boost::container::container_detail::vec_iterator<std::pair<int, int>*, false>, bool>; S = std::pair<boost::container::container_detail::vec_iterator<boost::container::container_detail::pair<int, int>*, false>, bool>]()’ from ‘std::pair<boost::container::container_detail::vec_iterator<std::pair<int, int>*, false>, bool>’ to ‘boost::container::flat_map<int, int>::iterator {aka boost::container::container_detail::vec_iterator<std::pair<int, int>*, false>}’
);
^
<builtin>: recipe for target 'main.o' failed
make: *** [main.o] Error 1

最佳答案

这是一个 known bug这已在 1.70 release 中修复.

关于c++ - 提示在 boost 中的行为与在标准库中的行为不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68029973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com