Changes in src/AST/Node.hpp [3648d98:54e41b3]
- File:
-
- 1 edited
-
src/AST/Node.hpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Node.hpp
r3648d98 r54e41b3 9 9 // Author : Thierry Delisle 10 10 // Created On : Wed May 8 10:27:04 2019 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Wed May 8 11:00:00 201913 // Update Count : 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 15 16:02:00 2019 13 // Update Count : 3 14 14 // 15 15 … … 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.