From: Braden M. <br...@en...> - 2007-06-19 03:41:19
|
How does one set the value of a closure member in a semantic action? I have the following semantic action: template <typename NodeType> struct get_node_type_t { get_node_type_t(NodeType & node_type, const scope_stack_t & scope_stack): node_type_(node_type), scope_stack_(scope_stack) {} template <typename IteratorT> void operator()(const IteratorT & first, const IteratorT & last) const { const std::string node_type_id(first, last); const node_type_decls::value_type * const node_type = find_node_type(this->scope_stack_, node_type_id); if (!node_type) { throw_(first, unknown_node_type_id); } std::cerr << "node_type = " << ptrdiff_t(node_type) << std::endl; this->node_type_ = node_type; std::cerr << "this->node_type_() = " << ptrdiff_t(this->node_type_()) << std::endl; } private: NodeType & node_type_; const scope_stack_t & scope_stack_; }; The member node_type_ is a closure member whose underlying type is "const node_type_decls::value_type *". When executed, the following is output: node_type = 8127744 this->node_type_() = 0 How come? I thought the statement, "this->node_type_ = node_type;" would assign the value to the closure member. -- Braden McDaniel e-mail: <br...@en...> <http://endoframe.com> Jabber: <br...@ja...> |