Changeset df4aea7 for src/examples/gc_no_raii/src/vector.h
- Timestamp:
- Apr 21, 2016, 10:27:55 AM (10 years ago)
- 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
- File:
-
- 1 edited
-
src/examples/gc_no_raii/src/vector.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/vector.h
r3365b37 rdf4aea7 1 #pragma once 2 1 3 #include <assert.h> 2 4 #include <stdbool.h> … … 8 10 //------------------------------------------------------------------------------ 9 11 //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*); 12 trait 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); 15 18 }; 16 19 … … 25 28 //Initialization 26 29 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 27 void vector_ctor(vector(T, allocator_t) *const this);30 void ctor(vector(T, allocator_t) *const this); 28 31 29 32 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) … … 72 75 73 76 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 74 inline T back(vector(T, allocator_t) *const this , size_t index)77 inline T back(vector(T, allocator_t) *const this) 75 78 { 76 79 return data(&this->storage)[this->size - 1]; … … 87 90 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 88 91 void clear(vector(T, allocator_t) *const this); 92 93 //------------------------------------------------------------------------------ 94 //Iterators 95 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 96 inline T* begin(vector(T, allocator_t) *const this) 97 { 98 return data(&this->storage); 99 } 100 101 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 102 inline const T* cbegin(const vector(T, allocator_t) *const this) 103 { 104 return data(&this->storage); 105 } 106 107 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 108 inline T* end(vector(T, allocator_t) *const this) 109 { 110 return data(&this->storage) + this->size; 111 } 112 113 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 114 inline const T* cend(const vector(T, allocator_t) *const this) 115 { 116 return data(&this->storage) + this->size; 117 } 89 118 90 119 //------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.