Changeset d41280e for src/examples


Ignore:
Timestamp:
Feb 8, 2016, 10:07:42 AM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
c44e622
Parents:
00ede9e (diff), bd85400 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into gc_noraii

Location:
src/examples
Files:
3 added
2 deleted
16 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/examples/Makefile.am

    r00ede9e rd41280e  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Fri Nov 20 16:03:46 2015
    14 ## Update Count     : 24
     13## Last Modified On : Mon Jan 25 22:31:42 2016
     14## Update Count     : 25
    1515###############################################################################
    1616
     
    2020
    2121noinst_PROGRAMS = fstream_test vector_test # build but do not install
    22 fstream_test_SOURCES = iostream.c fstream.c fstream_test.c iterator.c
    23 vector_test_SOURCES = vector_int.c fstream.c iostream.c array.c iterator.c vector_test.c
     22fstream_test_SOURCES = fstream_test.c
     23vector_test_SOURCES = vector_int.c array.c vector_test.c
  • src/examples/Makefile.in

    r00ede9e rd41280e  
    4848CONFIG_CLEAN_VPATH_FILES =
    4949PROGRAMS = $(noinst_PROGRAMS)
    50 am_fstream_test_OBJECTS = iostream.$(OBJEXT) fstream.$(OBJEXT) \
    51         fstream_test.$(OBJEXT) iterator.$(OBJEXT)
     50am_fstream_test_OBJECTS = fstream_test.$(OBJEXT)
    5251fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)
    5352fstream_test_LDADD = $(LDADD)
    54 am_vector_test_OBJECTS = vector_int.$(OBJEXT) fstream.$(OBJEXT) \
    55         iostream.$(OBJEXT) array.$(OBJEXT) iterator.$(OBJEXT) \
     53am_vector_test_OBJECTS = vector_int.$(OBJEXT) array.$(OBJEXT) \
    5654        vector_test.$(OBJEXT)
    5755vector_test_OBJECTS = $(am_vector_test_OBJECTS)
     
    176174top_builddir = @top_builddir@
    177175top_srcdir = @top_srcdir@
    178 fstream_test_SOURCES = iostream.c fstream.c fstream_test.c iterator.c
    179 vector_test_SOURCES = vector_int.c fstream.c iostream.c array.c iterator.c vector_test.c
     176fstream_test_SOURCES = fstream_test.c
     177vector_test_SOURCES = vector_int.c array.c vector_test.c
    180178all: all-am
    181179
     
    191189          esac; \
    192190        done; \
    193         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/Makefile'; \
     191        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/examples/Makefile'; \
    194192        $(am__cd) $(top_srcdir) && \
    195           $(AUTOMAKE) --foreign src/examples/Makefile
     193          $(AUTOMAKE) --gnu src/examples/Makefile
    196194.PRECIOUS: Makefile
    197195Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
     
    229227
    230228@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
    231 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream.Po@am__quote@
    232229@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@
    233 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iostream.Po@am__quote@
    234 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iterator.Po@am__quote@
    235230@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_int.Po@am__quote@
    236231@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_test.Po@am__quote@
  • src/examples/alloc.c

    r00ede9e rd41280e  
     1//                               -*- Mode: C -*-
     2//
     3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     4//
     5// The contents of this file are covered under the licence agreement in the
     6// file "LICENCE" distributed with Cforall.
     7//
     8// alloc.c --
     9//
     10// Author           : Peter A. Buhr
     11// Created On       : Wed Feb  3 07:56:22 2016
     12// Last Modified By : Peter A. Buhr
     13// Last Modified On : Wed Feb  3 16:32:04 2016
     14// Update Count     : 38
     15//
     16
     17#include <fstream>
     18#include <stdlib>
    119extern "C" {
    2     typedef long unsigned int size_t;
    3     void *malloc( size_t size );
    4     void *calloc( size_t nmemb, size_t size );
    5     void *realloc( void *ptr, size_t size );
    6     void *memset( void *s, int c, size_t n );
    7     void free( void * ptr );
    8     int printf( const char *, ... );
    9 }
     20#include <stdlib.h>                                                                             // access C malloc, realloc
     21#include <stdio.h>
     22} // exten "C"
    1023
    11 forall( type T ) T * malloc( void ) {
    12     return (T *)malloc( sizeof(T) );
    13 }
    14 forall( type T ) T * calloc( size_t size ) {
    15     return (T *)calloc( size, sizeof(T) );
    16 }
    17 forall( type T ) T * realloc( T *ptr, size_t n ) {
    18     return (T *)(void *)realloc( ptr, sizeof(T) );
    19 }
    20 forall( type T ) T * realloc( T *ptr, size_t n, T c ) {
    21     return (T *)realloc( ptr, n );
    22 }
    23 
    24 int *foo( int *p, int c );
    25 int *bar( int *p, int c );
    26 int *baz( int *p, int c );
     24int * foo( int * p, int c ) { return p; }
     25int * bar( int * p, int c ) { return p; }
     26int * baz( int * p, int c ) { return p; }
    2727
    2828int main( void ) {
     29    ofstream * sout = ofstream_stdout();
     30
    2931    size_t size = 10;
    30     int * x = malloc();
    31     x = malloc();
    32     x = calloc( 10 );                                   // calloc: array set to 0
    33     x = realloc( x, 10 );
    34     x = realloc( x, 10, '\0' );
    35     x = malloc( 5 );
    36     float *fp = malloc() + 1;
     32    int * p;
     33    struct S { int x; double y; } * s;
    3734
    38     struct St1 { int x; double y; };
    39     struct St1 * st1;
     35    p = malloc( sizeof(*p) );                                                   // C malloc, type unsafe
     36        printf( "here1\n" );
     37    free( p );
     38    p = malloc();                                                                               // CFA malloc, type safe
     39        printf( "here2\n" );
     40    free( p );
     41    p = malloc( (char)'\0' );                                                                   // CFA malloc, type safe
     42        printf( "here3\n" );
     43    p = malloc( p, 1000 );                                                              // CFA remalloc, type safe
     44        printf( "here4\n" );
     45    free( p );
     46    p = calloc( size, sizeof(*p) );                                             // C calloc, type unsafe
     47        printf( "here5\n" );
     48    free( p );
     49    p = calloc( size );                                                                 // CFA calloc, type safe
     50        printf( "here6\n" );
     51    free( p );
     52    p = calloc( size );                                                                 // CFA calloc, type safe
     53    p = realloc( p, 1000 );                                                             // C realloc, type unsafe
     54    p = realloc( p, 1000, '\0' );                                               // CFA realloc, type unsafe
     55    p = memset( p );                                                                    // CFA memset, type unsafe
     56        printf( "here7\n" );
     57    free( p );
     58    p = memalign( 16 );
     59        printf( "here8\n" );
     60    free( p );
     61    posix_memalign( &p, 16 );
     62        printf( "here9\n" );
     63    free( p );
     64#if 0
     65    float * fp = malloc() + 1;
     66    fprintf( stderr, "%p %p\n", fp, fp - 1 );
     67    free( fp - 1 );
     68    p = realloc( st1, size, '\0' );                                             // C realloc, type unsafe
     69
    4070    double *y;
    41     x = realloc( st1, 10 );                             // SHOULD FAIL!!
    42 #if 0
     71    x = memset( st1, '\0' );                                                    // SHOULD FAIL!!
     72
    4373    int *p;
    4474    p = foo( bar( baz( malloc(), 0 ), 0 ), 0 );
     
    70100    free( x );
    71101#endif
     102    free( sout );
    72103}
     104
     105// Local Variables: //
     106// tab-width: 4 //
     107// compile-command: "cfa alloc.c" //
     108// End: //
  • src/examples/array.h

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:10:32 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Jan 26 17:09:29 2016
     13// Update Count     : 3
    1414//
    1515
     
    1717#define ARRAY_H
    1818
    19 //#include "iterator.h"
     19//#include <iterator>
    2020
    2121// An array has contiguous elements accessible in any order using integer indicies. The first
  • src/examples/constants.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 20:44:48 2015
    13 // Update Count     : 75
     12// Last Modified On : Mon Jan 25 23:44:12 2016
     13// Update Count     : 76
    1414//
    1515
     
    5454        L_"\x_ff_ee";
    5555        L"a_b\r\Qyc\u_00_40  x_y_z\xff_AA";
    56         L_"a_b\r\Qyc\u_00_40\   
     56        L_"a_b\r\Qyc\u_00_40\
    5757  x_y_z\xff_AA";
    5858        "abc" "def" "ghi";
  • src/examples/fstream_test.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 11:30:39 2016
    13 // Update Count     : 41
     12// Last Modified On : Tue Jan 26 17:11:33 2016
     13// Update Count     : 42
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818int main( void ) {
  • src/examples/hello.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Nov 22 17:40:37 2015
    13 // Update Count     : 5
     12// Last Modified On : Tue Jan 26 17:11:49 2016
     13// Update Count     : 7
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818int main() {
     
    2424// Local Variables: //
    2525// tab-width: 4 //
    26 // compile-command: "cfa hello.c fstream.o iostream.o iterator.o" //
     26// compile-command: "cfa hello.c" //
    2727// End: //
  • src/examples/identity.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 23:38:05 2016
    13 // Update Count     : 6
     12// Last Modified On : Tue Jan 26 17:11:58 2016
     13// Update Count     : 8
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818forall( type T )
     
    3737// Local Variables: //
    3838// tab-width: 4 //
    39 // compile-command: "cfa identity.c fstream.o iostream.o iterator.o" //
     39// compile-command: "cfa identity.c" //
    4040// End: //
  • src/examples/minmax.c

    r00ede9e rd41280e  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // min.c --
     7// minmax.c --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 11:40:51 2016
    13 // Update Count     : 26
     12// Last Modified On : Wed Feb  3 11:14:49 2016
     13// Update Count     : 46
    1414//
    1515
    16 #include "fstream.h"
    17 
    18 forall( type T | { int ?<?( T, T ); } )
    19 T min( const T t1, const T t2 ) {
    20         return t1 < t2 ? t1 : t2;
    21 } // min
     16#include <fstream>
     17#include <stdlib>                                                                               // min, max
    2218
    2319int main( void ) {
    2420        ofstream *sout = ofstream_stdout();
    25         // char does not have less than.
     21        // char does not have less or greater than.
    2622        int ?<?( char op1, char op2 ) { return (int)op1 < (int)op2; }
     23        int ?>?( char op1, char op2 ) { return (int)op1 > (int)op2; }
    2724
    2825        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ) | endl;
     
    3633        sout | "double\t\t\t"                           | 4.0 | ' ' | 3.1 | "\tmin " | min( 4.0, 3.1 ) | endl;
    3734        sout | "long double\t\t"                        | 4.0l | ' ' | 3.1l | "\tmin " | min( 4.0l, 3.1l ) | endl;
     35
     36        sout | endl;
     37
     38        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' ) | endl;
     39        sout | "signed int\t\t"                         | 4 | ' ' | 3 | "\tmax " | max( 4, 3 ) | endl;
     40        sout | "unsigned int\t\t"                       | 4u | ' ' | 3u | "\tmax " | max( 4u, 3u ) | endl;
     41        sout | "signed long int\t\t"            | 4l | ' ' | 3l | "\tmax " | max( 4l, 3l ) | endl;
     42        sout | "unsigned long int\t"            | 4ul | ' ' | 3ul | "\tmax " | max( 4ul, 3ul ) | endl;
     43        sout | "signed long long int\t"         | 4ll | ' ' | 3ll | "\tmax " | max( 4ll, 3ll ) | endl;
     44        sout | "unsigned long long int\t"       | 4ull | ' ' | 3ull | "\tmax " | max( 4ull, 3ull ) | endl;
     45        sout | "float\t\t\t"                            | 4.0f | ' ' | 3.1f | "\tmax " | max( 4.0f, 3.1f ) | endl;
     46        sout | "double\t\t\t"                           | 4.0 | ' ' | 3.1 | "\tmax " | max( 4.0, 3.1 ) | endl;
     47        sout | "long double\t\t"                        | 4.0l | ' ' | 3.1l | "\tmax " | max( 4.0l, 3.1l ) | endl;
    3848} // main
    3949
    4050// Local Variables: //
    4151// tab-width: 4 //
    42 // compile-command: "cfa min.c fstream.o iostream.o iterator.o" //
     52// compile-command: "cfa minmax.c" //
    4353// End: //
  • src/examples/new.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:23:55 2015
    13 // Update Count     : 1
     12// Last Modified On : Mon Jan 25 23:33:55 2016
     13// Update Count     : 2
    1414//
    1515
     
    2525        t - 4;
    2626        t[7];
    27         7[t];
    2827}
    2928
  • src/examples/quad.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:26:36 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Jan 26 17:13:48 2016
     13// Update Count     : 5
    1414//
    1515
    16 extern "C" {
    17 #include <stdio.h>
    18 }
     16#include <fstream>
    1917
    2018forall( type T | { T ?*?( T, T ); } )
     
    2927
    3028int main() {
     29        ofstream *sout = ofstream_stdout();
    3130        int N = 2;
    32         printf( "result of quad of %d is %d\n", N, quad( N ) );
     31        sout | "result of quad of " | N | " is " | quad( N ) | endl;
    3332}
    3433
  • src/examples/quoted_keyword.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  3 22:46:28 2016
    13 // Update Count     : 7
     12// Last Modified On : Tue Jan 26 17:13:58 2016
     13// Update Count     : 8
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818// test quoted keyword usage
  • src/examples/square.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan  5 18:08:20 2016
    13 // Update Count     : 21
     12// Last Modified On : Tue Jan 26 17:14:16 2016
     13// Update Count     : 25
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818forall( type T | { T ?*?( T, T ); } )
     
    3535        sout | square( s ) | endl;
    3636#endif
    37         short int s = 9;
     37        short s = 9;
    3838        square( s );
    3939#if 0
     
    6969// Local Variables: //
    7070// tab-width: 4 //
    71 // compile-command: "cfa square.c fstream.o iostream.o iterator.o" //
     71// compile-command: "cfa square.c" //
    7272// End: //
  • src/examples/sum.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 07:40:24 2016
    13 // Update Count     : 126
     12// Last Modified On : Fri Feb  5 16:47:44 2016
     13// Update Count     : 139
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818context sumable( type T ) {
     
    2222        T ++?( T * );
    2323        T ?++( T * );
    24 };
     24}; // sumable
    2525
    2626forall( type T | sumable( T ) )
     
    3030                total += a[i];                                                                  // select +
    3131        return total;
    32 }
     32} // sum
    3333
    3434// Required to satisfy sumable as char does not have addition.
    35 const char 0;
    36 char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion
    37 char ++?( char *op ) { *op += 1; return *op; }
    38 char ?++( char *op ) { char temp = *op; *op += 1; return temp; }
     35// const char 0;
     36// char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion
     37// char ++?( char *op ) { *op += 1; return *op; }
     38// char ?++( char *op ) { char temp = *op; *op += 1; return temp; }
    3939
    4040int main( void ) {
    4141        const int low = 5, High = 15, size = High - low;
    42 
    4342        ofstream *sout = ofstream_stdout();
     43#if 0
    4444
    4545        char s = 0, a[size];
     
    6161                 | sum( size, (int *)a ) | ", check " | (int)s | endl;
    6262
    63         double s = 0.0, a[size];
    64         double v = low / 10.0;
    65         for ( int i = 0; i < size; i += 1, v += 0.1 ) {
    66                 s += (double)v;
    67                 a[i] = (double)v;
    68         }
    69         sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is "
    70                  | sum( size, (double *)a ) | ", check " | (double)s | endl;
    71 
    7263        float s = 0.0, a[size];
    7364        float v = low / 10.0;
     
    7869        sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is "
    7970                 | sum( size, (float *)a ) | ", check " | (float)s | endl;
    80 }
     71#endif
     72        double s = 0, a[size];
     73        double v = low / 10.0;
     74
     75        for ( int i = 0; i < size; i += 1, v += 0.1 ) {
     76                s += (double)v;
     77                a[i] = (double)v;
     78        }
     79        sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is "
     80                 | sum( size, (double *)a ) | ", check " | (double)s | endl;
     81
     82        // struct S { int i, j; } sarr[size];
     83        // struct S 0 = { 0, 0 };
     84        // struct S 1 = { 1, 1 };
     85        // S ?+?( S t1, S t2 ) { S s = { t1.i + t1.j, t2.i + t2.j }; return s; }
     86        // S ?+=?( S *t1, S t2 ) { *t1 = *t1 + t2; return *t1; }
     87        // S ++?( S *t ) { *t += 1; return *t; }
     88        // S ?++( S *t ) { S temp = *t; *t += 1; return temp; }
     89        // sum( size, sarr );
     90} // main
    8191
    8292// Local Variables: //
    8393// tab-width: 4 //
    84 // compile-command: "cfa sum.c fstream.o iostream.o iterator.o" //
     94// compile-command: "cfa sum.c" //
    8595// End: //
  • src/examples/swap.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 11:32:25 2016
    13 // Update Count     : 5
     12// Last Modified On : Wed Feb  3 11:14:04 2016
     13// Update Count     : 63
    1414//
    1515
    16 #include "fstream.h"
    17 
    18 forall( type T )
    19 void swap( T *left, T *right ) {
    20         T temp = *left;
    21         *left = *right;
    22         *right = temp;
    23 }
     16#include <fstream>
     17#include <stdlib>                                                                               // swap
    2418
    2519int main( void ) {
    26         int x = 1, y = 2;
    2720        ofstream *sout = ofstream_stdout();
    28         sout | x | ' ' | y | endl;
    29         swap( &x, &y );
    30         sout | x | ' ' | y | endl;
    31 }
     21
     22        char c1 = 'a', c2 = 'b';
     23        sout | "char\t\t\t" | c1 | ' ' | c2 | "\t\t\tswap ";
     24        swap( &c1, &c2 );
     25        sout | '\t' | c1 | ' ' | c2 | endl;
     26
     27        signed int i1 = -1, i2 = -2;
     28        sout | "signed int\t\t" | i1 | ' ' | i2 | "\t\t\tswap ";
     29        swap( &i1, &i2 );
     30        sout | '\t' | i1 | ' ' | i2 | endl;
     31
     32        unsigned int ui1 = 1, ui2 = 2;
     33        sout | "unsigned int\t\t" | ui1 | ' ' | ui2 | "\t\t\tswap ";
     34        swap( &ui1, &ui2 );
     35        sout | '\t' | ui1 | ' ' | ui2 | endl;
     36
     37        signed long int li1 = -1, li2 = -2;
     38        sout | "signed long int\t\t" | li1 | ' ' | li2 | "\t\t\tswap ";
     39        swap( &li1, &li2 );
     40        sout | '\t' | li1 | ' ' | li2 | endl;
     41
     42        unsigned long int uli1 = 1, uli2 = 2;
     43        sout | "unsigned long int\t" | uli1 | ' ' | uli2 | "\t\t\tswap ";
     44        swap( &uli1, &uli2 );
     45        sout | '\t' | uli1 | ' ' | uli2 | endl;
     46
     47        signed long long int lli1 = -1, lli2 = -2;
     48        sout | "signed long long int\t" | lli1 | ' ' | lli2 | "\t\t\tswap ";
     49        swap( &lli1, &lli2 );
     50        sout | '\t' | lli1 | ' ' | lli2 | endl;
     51
     52        unsigned long long int ulli1 = 1, ulli2 = 2;
     53        sout | "unsigned long long int\t" | ulli1 | ' ' | ulli2 | "\t\t\tswap ";
     54        swap( &ulli1, &ulli2 );
     55        sout | '\t' | ulli1 | ' ' | ulli2 | endl;
     56
     57        float f1 = 1.5, f2 = 2.5;
     58        sout | "float\t\t\t" | f1 | ' ' | f2 | "\t\t\tswap ";
     59        swap( &f1, &f2 );
     60        sout | '\t' | f1 | ' ' | f2 | endl;
     61
     62        double d1 = 1.5, d2 = 2.5;
     63        sout | "double\t\t\t" | d1 | ' ' | d2 | "\t\t\tswap ";
     64        swap( &d1, &d2 );
     65        sout | '\t' | d1 | ' ' | d2 | endl;
     66
     67        long double ld1 = 1.5, ld2 = 2.5;
     68        sout | "long double\t\t" | ld1 | ' ' | ld2 | "\t\t\tswap ";
     69        swap( &ld1, &ld2 );
     70        sout | '\t' | ld1 | ' ' | ld2 | endl;
     71
     72        float _Complex fc1 = 1.5f+1.5if, fc2 = 2.5f+2.5if;
     73        sout | "float _Complex\t\t" | fc1 | ' ' | fc2 | "\tswap ";
     74        swap( &fc1, &fc2 );
     75        sout | '\t' | fc1 | ' ' | fc2 | endl;
     76
     77        double _Complex dc1 = 1.5d+1.5id, dc2 = 2.5d+2.5id;
     78        sout | "double _Complex\t\t" | dc1 | ' ' | dc2 | "\tswap ";
     79        swap( &dc1, &dc2 );
     80        sout | '\t' | dc1 | ' ' | dc2 | endl;
     81
     82        long double _Complex ldc1 = 1.5d+1.5il, ldc2 = 2.5d+2.5il;
     83        sout | "long double _Complex\t" | ldc1 | ' ' | ldc2 | "\tswap ";
     84        swap( &ldc1, &ldc2 );
     85        sout | '\t' | ldc1 | ' ' | ldc2 | endl;
     86
     87        struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 };
     88        ofstream * ?|?( ofstream * os, S s ) { return os | s.i | ' ' | s.j; }
     89        sout | "struct S\t\t" | s1 | "  " | s2 | "\t\tswap ";
     90        swap( &s1, &s2 );
     91        sout | '\t' | s1 | "  " | s2 | endl;
     92} // main
    3293
    3394// Local Variables: //
    3495// tab-width: 4 //
    35 // compile-command: "cfa swap.c fstream.o iostream.o iterator.o" //
     96// compile-command: "cfa swap.c" //
    3697// End: //
  • src/examples/twice.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 11:32:04 2016
    13 // Update Count     : 10
     12// Last Modified On : Tue Jan 26 17:14:44 2016
     13// Update Count     : 12
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818forall( type T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )
     
    3333// Local Variables: //
    3434// tab-width: 4 //
    35 // compile-command: "cfa twice.c fstream.o iostream.o iterator.o" //
     35// compile-command: "cfa twice.c" //
    3636// End: //
  • src/examples/vector_test.c

    r00ede9e rd41280e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 11:31:56 2016
    13 // Update Count     : 14
     12// Last Modified On : Tue Jan 26 17:14:52 2016
     13// Update Count     : 17
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
     17#include <iterator>
    1718#include "vector_int.h"
    1819#include "array.h"
    19 #include "iterator.h"
    2020
    2121int main( void ) {
     
    4646// Local Variables: //
    4747// tab-width: 4 //
    48 // compile-command: "cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o" //
     48// compile-command: "cfa vector_test.c vector_int.o array.o" //
    4949// End: //
Note: See TracChangeset for help on using the changeset viewer.