ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change
on this file since d0e8cfe4 was
134b86a,
checked in by Peter A. Buhr <pabuhr@…>, 10 years ago
|
add compiler flag to driver, update examples, fix unnamed bit fields
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[51b7345] | 1 | // "cfa iterator.c" |
---|
| 2 | // "cfa -CFA iterator.c > iterator_out.c" |
---|
| 3 | // "gcc31 iterator_out.c ../LibCfa/libcfa.a" |
---|
| 4 | |
---|
| 5 | #include "iterator.h" |
---|
| 6 | |
---|
| 7 | /// forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) ) |
---|
| 8 | /// void |
---|
| 9 | /// for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) |
---|
| 10 | /// { |
---|
| 11 | /// iterator_type i; |
---|
| 12 | /// for( i = begin; i != end; ++i ) { |
---|
| 13 | /// func( *i ); |
---|
| 14 | /// } |
---|
| 15 | /// } |
---|
| 16 | |
---|
| 17 | forall( type elt_type | writeable( elt_type ), |
---|
| 18 | type iterator_type | iterator( iterator_type, elt_type ), |
---|
| 19 | dtype os_type | ostream( os_type ) ) |
---|
[134b86a] | 20 | void write_all( iterator_type begin, iterator_type end, os_type *os ) { |
---|
| 21 | iterator_type i; |
---|
| 22 | for ( i = begin; i != end; ++i ) { |
---|
| 23 | os << *i << ' '; |
---|
| 24 | } |
---|
[51b7345] | 25 | } |
---|
| 26 | |
---|
[134b86a] | 27 | forall( type elt_type | writeable( elt_type ), |
---|
| 28 | type iterator_type | iterator( iterator_type, elt_type ), |
---|
| 29 | dtype os_type | ostream( os_type ) ) |
---|
| 30 | void write_reverse( iterator_type begin, iterator_type end, os_type *os ) { |
---|
| 31 | iterator_type i; /* = end; do not work */ |
---|
| 32 | i = end; |
---|
| 33 | do { |
---|
| 34 | --i; |
---|
| 35 | os << *i << ' '; |
---|
| 36 | } while ( i != begin ); |
---|
| 37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.