Ignore:
Timestamp:
Apr 21, 2016, 10:27:55 AM (10 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/vector.h

    r3365b37 rdf4aea7  
     1#pragma once
     2
    13#include <assert.h>
    24#include <stdbool.h>
     
    810//------------------------------------------------------------------------------
    911//Declaration
    10 trait allocator_c(otype T, otype allocator_t) {
    11         void ctor(allocator_t*);
    12         void dtor(allocator_t*);
    13         void realloc(allocator_t*, size_t);
    14         T* data(allocator_t*);
     12trait allocator_c(otype T, otype allocator_t)
     13{
     14        void ctor(allocator_t* const);
     15        void dtor(allocator_t* const);
     16        void realloc(allocator_t* const, size_t);
     17        T* data(allocator_t* const);
    1518};
    1619
     
    2528//Initialization
    2629forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    27 void vector_ctor(vector(T, allocator_t) *const this);
     30void ctor(vector(T, allocator_t) *const this);
    2831
    2932forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     
    7275
    7376forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    74 inline T back(vector(T, allocator_t) *const this, size_t index)
     77inline T back(vector(T, allocator_t) *const this)
    7578{
    7679        return data(&this->storage)[this->size - 1];
     
    8790forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    8891void clear(vector(T, allocator_t) *const this);
     92
     93//------------------------------------------------------------------------------
     94//Iterators
     95forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     96inline T* begin(vector(T, allocator_t) *const this)
     97{
     98        return data(&this->storage);
     99}
     100
     101forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     102inline const T* cbegin(const vector(T, allocator_t) *const this)
     103{
     104        return data(&this->storage);
     105}
     106
     107forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     108inline T* end(vector(T, allocator_t) *const this)
     109{
     110        return data(&this->storage) + this->size;
     111}
     112
     113forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     114inline const T* cend(const vector(T, allocator_t) *const this)
     115{
     116        return data(&this->storage) + this->size;
     117}
    89118
    90119//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.