| 
            Last change
 on this file since 567a75f was             594671a, checked in by Andrew Beach <ajbeach@…>, 8 months ago           | 
        
        
          | 
             
Erase dtype types when they are encountered. Waiting to a use means that you may mutate your parent node and the changes are lost. Fixes 304. 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            678 bytes
           | 
        
      
      
| Rev | Line |   | 
|---|
| [594671a] | 1 | // Make sure that self references in polymorphic types do not cause issues.
 | 
|---|
 | 2 | 
 | 
|---|
 | 3 | forall(T)
 | 
|---|
 | 4 | struct TreeNodeO {
 | 
|---|
 | 5 |         T data;
 | 
|---|
 | 6 |         TreeNodeO(T) * left;
 | 
|---|
 | 7 |         TreeNodeO(T) * right;
 | 
|---|
 | 8 | };
 | 
|---|
 | 9 | 
 | 
|---|
 | 10 | forall(T &)
 | 
|---|
 | 11 | struct TreeNodeD {
 | 
|---|
 | 12 |         T * data;
 | 
|---|
 | 13 |         TreeNodeD(T) * left;
 | 
|---|
 | 14 |         TreeNodeD(T) * right;
 | 
|---|
 | 15 | };
 | 
|---|
 | 16 | 
 | 
|---|
 | 17 | // Instantiate the two types in different ways.
 | 
|---|
 | 18 | forall(U)
 | 
|---|
 | 19 | void tree_node(TreeNodeO(U) & this) {
 | 
|---|
 | 20 |         TreeNodeO(U) local;
 | 
|---|
 | 21 |         local.left = &this;
 | 
|---|
 | 22 | }
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 | forall(U)
 | 
|---|
 | 25 | void tree_node(TreeNodeD(U) & this) {
 | 
|---|
 | 26 |         TreeNodeD(U) local;
 | 
|---|
 | 27 |         local.left = &this;
 | 
|---|
 | 28 | }
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | int main() {
 | 
|---|
 | 31 |         TreeNodeO(int) node0;
 | 
|---|
 | 32 |         tree_node(node0);
 | 
|---|
 | 33 |         TreeNodeD(int) node1;
 | 
|---|
 | 34 |         tree_node(node1);
 | 
|---|
 | 35 | 
 | 
|---|
 | 36 |         // There is nothing interesting to print, so just print some noise.
 | 
|---|
 | 37 |         printf("done!\n");
 | 
|---|
 | 38 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.