ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        with_gc
      
      
        
          | 
            Last change
 on this file since d4afaac was             09687aa, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago           | 
        
        
          | 
             
complete conversion of iostream/fstream to use references 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            974 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | // 
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | // 
 | 
|---|
| 7 | // div.c -- 
 | 
|---|
| 8 | // 
 | 
|---|
| 9 | // Author           : Peter A. Buhr
 | 
|---|
| 10 | // Created On       : Tue Aug  8 16:28:43 2017
 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| 12 | // Last Modified On : Thu Dec  7 09:06:52 2017
 | 
|---|
| 13 | // Update Count     : 18
 | 
|---|
| 14 | // 
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include <fstream>
 | 
|---|
| 17 | #include <stdlib>                                                                               // div
 | 
|---|
| 18 | 
 | 
|---|
| 19 | struct T { int i; };
 | 
|---|
| 20 | T ?/?( T t1, T t2 ) { return t1.i / t2.i; }
 | 
|---|
| 21 | T ?%?( T t1, T t2 ) { return t1.i % t2.i; }
 | 
|---|
| 22 | ofstream & ?|?( ofstream & os, T t ) { return os | t.i; }
 | 
|---|
| 23 | 
 | 
|---|
| 24 | int main( void ) {
 | 
|---|
| 25 |         sout | "div" | div( 13, 5 ) | div( 13L, 5L ) | div( 13LL, 5LL ) | endl;
 | 
|---|
| 26 |         short s1 = 13, s2 = 5;
 | 
|---|
| 27 |         sout | "div" | div( s1, s2 ) | endl;
 | 
|---|
| 28 |         T t1 = { 13 }, t2 = { 5 };
 | 
|---|
| 29 |         sout | "div" | div( t1, t2 ) | endl;                            // polymorphic div
 | 
|---|
| 30 | } // main
 | 
|---|
| 31 | 
 | 
|---|
| 32 | // Local Variables: //
 | 
|---|
| 33 | // tab-width: 4 //
 | 
|---|
| 34 | // compile-command: "cfa div.c" //
 | 
|---|
| 35 | // End: //
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.