Checking if UFCS function exists for a specific type

Rory McGuire rjmcguire at gmail.com
Thu Aug 29 14:06:03 PDT 2013


Hi all,

I've got this little ctfe template function that checks if a 
function called member with first argument T exists. Its for 
checking if a type has a custom encoder.

bool hasUFCSmember(T, string member)() {
	T v;
	// would be nice if we could use ParameterTypeTuple to get the 
first arg and check for exact type match
	
	return __traits(compiles, mixin(member ~"(v)"));
}


More information about the Digitalmars-d-learn mailing list