source: translator/examples/iterator.c @ 51b7345

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 51b7345 was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 724 bytes
Line 
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
17forall( type elt_type | writeable( elt_type ),
18        type iterator_type | iterator( iterator_type, elt_type ),
19        dtype os_type | ostream( os_type ) )
20void
21write_all( iterator_type begin, iterator_type end, os_type *os )
22{
23  iterator_type i;
24  for( i = begin; i != end; ++i ) {
25    os << *i << ' ';
26  }
27}
28
Note: See TracBrowser for help on using the repository browser.