admin管理员组文章数量:1434921
MSVC warned me about this code inside point_concept.hpp
inside the class boost::geometry::concepts::Point
:
template <typename P, std::size_t Dimension, std::size_t DimensionCount>
struct dimension_checker
{
static void apply()
{
P* p = 0;
geometry::set<Dimension>(*p, geometry::get<Dimension>(*p));
dimension_checker<P, Dimension+1, DimensionCount>::apply();
}
};
The code initializes p
to 0 (meaning null) and then dereferences it. This seems blatant enough that I assume it's intentional; but I can't figure out the motivation for it. Does anyone know what it might be?
(One theory I came up with: Maybe they are using *p
as a dummy value like std::declval
? You don't need to go through constructors when declaring a pointer, so you can kind of cheat by then dereferencing the pointer and getting an (albeit garbage) value.)
本文标签: cBlatant null dereference inside boostgeometryStack Overflow
版权声明:本文标题:c++ - Blatant null dereference inside boost::geometry - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745643750a2668012.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论