Writing UFCS function for any instance of a templated struct

Rene Zwanenburg renezwanenburg at gmail.com
Thu Sep 13 02:46:47 PDT 2012


Hi,

I'd like to write a function for a vector template which 
basically looks like

struct Vec(T, size_t size) {
   T[size] e;
}

This template has a few properties with very common names like x, 
y, z, etc. To avoid mistakes I'd like to write a template 
constraint for UFCS functions so it accepts any instance of the 
Vec template, but nothing else. Something in the gist of

auto innerProduct(T)(const T v1, const T v2) if(is(T == Vec)) {

}

How can I do this?


More information about the Digitalmars-d-learn mailing list