Ignore:
Timestamp:
Apr 21, 2016, 10:27:55 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
8c8b614
Parents:
3365b37
Message:

all implemented files compile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/src/tools.h

    r3365b37 rdf4aea7  
    33#include "tools/checks.h"
    44#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
     14trait has_equal(otype T)
     15{
     16        signed int ?==?(T a, T b);
     17};
     18
     19trait 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
     28forall(otype T | has_equal(T), otype InputIterator | InputIterator_t(T, InputIterator))
     29inline 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 TracChangeset for help on using the changeset viewer.