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

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationresolv-newstringwith_gc
Last change on this file since 51b7345 was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#ifndef ITERATOR_H
2#define ITERATOR_H
3
4#include "iostream.h"
5
6context iterator( type iterator_type, type elt_type )
7{
8  iterator_type ?++( iterator_type* );
9  iterator_type ++?( iterator_type* );
10  int ?==?( iterator_type, iterator_type );
11  int ?!=?( iterator_type, iterator_type );
12  lvalue elt_type *?( iterator_type );
13};
14
15context iterator_for( type iterator_type, type collection_type, type elt_type | iterator( iterator_type, elt_type ) )
16{
17///   [ iterator_type begin, iterator_type end ] get_iterators( collection_type );
18  iterator_type get_begin( collection_type );
19  iterator_type get_end( collection_type );
20};
21
22forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) )
23void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
24
25forall( type elt_type | writeable( elt_type ),
26        type iterator_type | iterator( iterator_type, elt_type ),
27        dtype os_type | ostream( os_type ) )
28void write_all( iterator_type begin, iterator_type end, os_type *os );
29
30#endif /* #ifndef ITERATOR_H */
Note: See TracBrowser for help on using the repository browser.