【发布时间】:2019-05-27 21:18:12
【问题描述】:
假设我有一个boost::variant 定义为boost::variant<Point, Line, Circle> shape。现在,如果我创建 Point 类的对象,Point p 并将其存储为shape = p,我在这里所做的是制作 p 的副本。我如何实际存储对 p 的引用,这样当我调用 boost::apply_visitior(visitor, shape) 时,访问者不仅会改变存储在变体中的 Point,还会改变 p 本身?
【问题讨论】:
-
你不能,或者改变你的形状以允许参考。
标签: c++ boost variant boost-variant