Custom Query (145 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (10 - 12 of 145)

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Ticket Owner Reporter Resolution Summary
#6 ajbeach fixed Vector as Field of Generic Type Fails to Compile
Description

I tried to make a generic container (a stack) that used a vector as a base. However it would not compile, even when I stripped it down to the most simple member function.

forall(otype T)
struct stack {
    vector(T, heap_allocator(T)) data;
};

bool empty(stack(int) * this) {
    return empty(&this->data);
}

Error message I received:

CFA Version 1.0.0 (debug)
implicit-handlers.c:45 error: No reasonable alternatives for expression Applying untyped: 
  Name: empty
...to: 
  Address of:
      Untyped Member Expression, with field: 
        Name: data
        from aggregate: 
          Applying untyped: 
            Name: *?
          ...to: 
            Name: this
#12 Rob Schluntz <rschlunt@…> a3moss fixed Excess elements in struct initializer
Description

If I try to default-construct a struct with no elements using an empty initializer, the generated code inserts a zero into the initializer, making a warning -- GCC finishes silently on the same code:

struct tag {};

int main() {
    struct tag t = {};
}

Error:

CFA Version 1.0.0 (debug)
tag_struct.c: In function ‘__main__Fi___1’:
tag_struct.c:5:33: warning: excess elements in struct initializer
 }
                                 ^
tag_struct.c:5:33: note: (near initialization for ‘__t__4stag_2’)
#13 Rob Schluntz Rob Schluntz fixed Default type arguments for generic types
Description

The current definition of vector contains two type parameters:

trait allocator_c(otype T, otype allocator_t)
{
	void realloc_storage(allocator_t*, size_t);
	T* data(allocator_t*);
};

forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
struct vector;

Instances of vector, awkwardly require specifying both type parameters:

vector( int, heap_allocator(int) ) iv;

Most of the time, the second parameter will be heap_allocator(T), so we want to allow specifying a default value for type parameters, e.g.,

forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t))
struct vector;
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Note: See TracQuery for help on using queries.