Changeset 54e41b3 for src/AST/Node.hpp
- Timestamp:
- May 16, 2019, 1:46:28 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 24afc53
- Parents:
- 89c2f7c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Node.hpp
r89c2f7c9 r54e41b3 76 76 // problems and be able to use auto return 77 77 template<typename node_t> 78 auto mutate( const node_t * node) {78 auto mutate( const node_t * node ) { 79 79 assertf( 80 80 node->strong_count >= 1, … … 92 92 } 93 93 94 std::ostream& operator<< ( std::ostream& out, const Node * node );94 std::ostream& operator<< ( std::ostream& out, const Node * node ); 95 95 96 96 /// Base class for the smart pointer types … … 137 137 operator const node_t * () const { return node; } 138 138 139 /// wrapper for convenient access to dynamic_cast 139 140 template<typename o_node_t> 140 141 const o_node_t * as() const { return dynamic_cast<const o_node_t *>(node); } 142 143 /// Sets this pointer to a mutated version of a pointer (possibly) owned elsehere. 144 /// Returns a mutable version of the pointer in this node. 145 node_t * set_and_mutate( const node_t * n ) { 146 // ensure ownership of `n` by this node to avoid spurious single-owner mutates 147 assign( n ); 148 // get mutable version of `n` 149 auto r = mutate( node ); 150 // re-assign mutable version in case `mutate()` produced a new pointer 151 assign( r ); 152 return r; 153 } 141 154 142 155 using ptr = const node_t *;
Note: See TracChangeset
for help on using the changeset viewer.