Ignore:
Timestamp:
May 26, 2017, 6:37:49 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
01b9928
Parents:
ff03f5c
git-author:
Rob Schluntz <rschlunt@…> (05/26/17 18:34:50)
git-committer:
Rob Schluntz <rschlunt@…> (05/26/17 18:37:49)
Message:

implement default type arguments for generic types [closes #13]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/vector

    rff03f5c r67cf18c  
    2222
    2323//------------------------------------------------------------------------------
     24//Allocator
     25forall(otype T)
     26struct heap_allocator
     27{
     28        T* storage;
     29        size_t capacity;
     30};
     31
     32forall(otype T)
     33void ?{}(heap_allocator(T)* this);
     34
     35forall(otype T)
     36void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
     37
     38forall(otype T)
     39heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
     40
     41forall(otype T)
     42void ^?{}(heap_allocator(T)* this);
     43
     44forall(otype T)
     45void realloc_storage(heap_allocator(T)* this, size_t size);
     46
     47forall(otype T)
     48static inline T* data(heap_allocator(T)* this)
     49{
     50        return this->storage;
     51}
     52
     53//------------------------------------------------------------------------------
    2454//Declaration
    2555trait allocator_c(otype T, otype allocator_t)
     
    2959};
    3060
    31 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     61forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t))
    3262struct vector;
    3363
     
    4676void ^?{}(vector(T, allocator_t)* this);
    4777
    48 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     78forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t))
    4979struct vector
    5080{
     
    136166// }
    137167
    138 //------------------------------------------------------------------------------
    139 //Allocator
    140 forall(otype T)
    141 struct heap_allocator
    142 {
    143         T* storage;
    144         size_t capacity;
    145 };
    146 
    147 forall(otype T)
    148 void ?{}(heap_allocator(T)* this);
    149 
    150 forall(otype T)
    151 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
    152 
    153 forall(otype T)
    154 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
    155 
    156 forall(otype T)
    157 void ^?{}(heap_allocator(T)* this);
    158 
    159 forall(otype T)
    160 void realloc_storage(heap_allocator(T)* this, size_t size);
    161 
    162 forall(otype T)
    163 static inline T* data(heap_allocator(T)* this)
    164 {
    165         return this->storage;
    166 }
    167 
    168168#endif // VECTOR_H
    169169
Note: See TracChangeset for help on using the changeset viewer.