
On 12/10/09 22:11, Zachary Turner wrote:
I'm using boost 1.41. I use a variant to store a symbolic representation of an algebraic expression, wrapped inside of a master "node" class. Like this:
struct expr_node { friend class constant; friend class variable; friend class arithmetic_op; friend class exponent; friend class special_func; friend class negative; public: template<class T> expr_node(const T& expr) : expr_(expr) { }
expr_node& operator=(const expr_node& rhs) { expr_ = rhs; return *this; }
private: typedef boost::variant<constant, variable, arithmetic_op, exponent, special_func, negative> node_type;
I think some of these variant args should have recursive_wrapper wrapping them. See the link in following Dec 3 post to this list: http://sourceforge.net/mailarchive/message.php?msg_name=loom.20091203T005648... However, in that code, I don't think there needs to be a recursive_wrapper<Node> in the variant's components.
node_type expr_; };
Of course, this is a recursive definition, because exponent, arithmetic_op, etc also contain expr_node members.
[snip] HTH. -regards, Larry