【发布时间】:2019-12-13 13:54:12
【问题描述】:
我正在尝试将 Howard Hinnant 的 stack_alloc 与 boost rtrees 一起使用,如下例所示:
#include "stack_alloc.h"
#include <boost/geometry/index/rtree.hpp>
using NodePoint = boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>;
using Linear = boost::geometry::index::linear<8, 2>;
using RTree =
boost::geometry::index::rtree<NodePoint, Linear, boost::geometry::index::indexable<NodePoint>,
boost::geometry::index::equal_to<NodePoint>,
stack_alloc<NodePoint, 100>>;
int main()
{
RTree my_tree{};
return 0;
}
由于相当大的模板错误堆栈无法编译。我认为问题的核心是:
/usr/local/include/boost/geometry/index/detail/rtree/node/variant_static.hpp:26:7:错误:无效使用不完整类型'class boost::geometry::index::detail: :rtree::allocators, 100>, boost::geometry::model::point, boost::geometry::index::linear, boost::geometry::model::box >, boost: :geometry::index::detail::rtree::node_variant_static_tag>'
这是coliru 上的完整示例,其中包含完整错误。
这里有什么问题?
我尝试将stack_alloc 与各种提升集合一起使用,例如boost::container::static_vector 和boost::container::map,并且效果很好。
我还尝试使用来自this SO reply 的另一个stack_allocator 实现并得到同样的错误。
此外,我知道 Howard Hinnant 有一个更新的实现,即short_alloc。我试过使用它,但是这个实现没有默认的ctor,需要我们在构建时提供存储。由于boost 将分配器作为模板参数并在内部对其进行实例化,因此我找不到使其工作的方法,但如果有方法,我会很乐意使用它。 stack_alloc 和/vs short_alloc 的更多信息:1、2、3
【问题讨论】:
-
Boost 树有一个构造函数,它接受用户提供的分配器对象:boost.org/doc/libs/1_70_0/libs/geometry/doc/html/geometry/…
标签: c++ c++11 boost memory-management allocator