source: translator/examples/iterator.h@ a0d9f94

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string stuck-waitfor-destruct with_gc
Last change on this file since a0d9f94 was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 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.