Template substitution for function parameters
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 1 03:15:09 PDT 2017
So I have the following types
struct DevicePointer(T) { T* ptr; }
struct Buffer(T)
{
void* driverObject;
T[] hostMemory;
}
and a function
auto enqueue(alias k)(HostArgsOf!k) { ... }
where k would be a function like
void foo( DevicePointer!float a, float b , int c) { ... }
How can I write HostArgsOf such that HostArgsOf!foo yields:
AliasSeq!(Buffer!float, float, int)
preferably in such a way that I can add additional
transformations to it later on?
i.e. it substitutes the template DevicePointer for the template
Buffer in Parameters!foo,
The templates can be assumed to not be nested templates, i.e.
DevicePointer!(DevicePointer!(float)) will never occur neither
will Buffer!(Buffer!(float) or any cross templates)
More information about the Digitalmars-d-learn
mailing list