我使用boost::geometry::index::rtree
和Eigen::Vector
给出的点类型。为此我宣布
namespace boost
{
namespace geometry
{
namespace traits
{
template<typename T, std::size_t D> struct tag<Eigen::Vector<T, D>> { using type = point_tag; };
template<typename T, std::size_t D> struct dimension<Eigen::Vector<T, D>> : boost::mpl::int_<D> {};
template<typename T, std::size_t D> struct coordinate_type<Eigen::Vector<T, D>> { using type = T; };
template<typename T, std::size_t D> struct coordinate_system<Eigen::Vector<T, D>> { using type = boost::geometry::cs::cartesian; };
template<typename T, std::size_t D, std::size_t Index>
struct access<Eigen::Vector<T, D>, Index>
{
static_assert(Index < D, "out of range");
using Point = Eigen::Vector<T, D>;
using CoordinateType = typename coordinate_type<Point>::type;
static inline CoordinateType get(Point const& p) { return p[Index]; }
static inline void set(Point& p, CoordinateType const& value) { p[Index] = value; }
};
} // namespace traits
} // namespace geometry
} // namespace boost
那么我宣布
template<class PointType>
using rtree = boost::geometry::index::rtree<PointType, boost::geometry::index::rstar<16>>;
rtree<std::pair<Eigen::Vector<double, 2>, std::size_t>> foo;
。虽然这完美地使用MSVC编译,我收到的错误
错误:静态Assert失败:std::pair的第一个类型必须是Indexable。24| static_assert(boost::geometry::detail::static_assert_check<(CHECK),VA_ARGS>::value,MESSAGE)
在Linux/GCC下编译时。这里出了什么问题,我该如何解决?
1条答案
按热度按时间toe950271#
不知何故,GCC不匹配部分模板专门化,除非您使
std::size_t D
模板参数int
。这可能与缩小限制的内部解释有关,但我觉得这可能是一个错误(在GCC的某些版本中)。)。Clang 15接受它就像你报告MSVC一样。
在我的GCC版本上也可以修改它:
Live On Compiler Explorer