Opened 7 years ago

Closed 7 years ago

#13 closed enhancement (fixed)

Default type arguments for generic types

Reported by: Rob Schluntz Owned by: Rob Schluntz
Priority: minor Component: cfa-cc
Version: 1.0 Keywords: default type arguments generic types
Cc: Thierry Delisle


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;

Change History (1)

comment:1 Changed 7 years ago by Rob Schluntz <rschlunt@…>

Resolution: fixed
Status: assignedclosed

In 67cf18c:

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

Note: See TracTickets for help on using tickets.