ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 00c32e9 was
16cfd8c,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
1 error left
|
-
Property mode set to
100644
|
File size:
785 bytes
|
Line | |
---|
1 | #pragma once |
---|
2 | |
---|
3 | #include "tools/checks.h" |
---|
4 | #include "tools/print.h" |
---|
5 | |
---|
6 | // forall(otype T) |
---|
7 | // inline void swap(T* const a, T* const b) |
---|
8 | // { |
---|
9 | // T* temp = a; |
---|
10 | // *a = *b; |
---|
11 | // *b = *temp; |
---|
12 | // } |
---|
13 | |
---|
14 | trait has_equal(otype T) |
---|
15 | { |
---|
16 | signed int ?==?(T a, T b); |
---|
17 | }; |
---|
18 | |
---|
19 | trait InputIterator_t(otype T, otype InputIterator) |
---|
20 | { |
---|
21 | signed int ?==?(InputIterator a, InputIterator b); |
---|
22 | signed int ?!=?(InputIterator a, InputIterator b); |
---|
23 | T *?(InputIterator a); |
---|
24 | InputIterator ++?(InputIterator* a); |
---|
25 | InputIterator ?++(InputIterator* a); |
---|
26 | }; |
---|
27 | |
---|
28 | forall(otype T | has_equal(T), otype InputIterator | InputIterator_t(T, InputIterator)) |
---|
29 | static inline InputIterator find( InputIterator first, const InputIterator* const last, T val) |
---|
30 | { |
---|
31 | while ( first != *last) |
---|
32 | { |
---|
33 | if(*first == val) return first; |
---|
34 | ++first; |
---|
35 | } |
---|
36 | return *last; |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.