how do I check if a member of a T has a member ?

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Sep 13 09:46:53 PDT 2015


can I check if a member of a T has a member without using a mixin?

hid_t createDataType(T)()
if (__traits(isSame, TemplateOf!(T), PriceBar))
{
	auto tid=H5T.create(H5TClass.Compound,T.sizeof);
	enum offsetof(alias type, string field) = mixin(type.stringof 
~"."~field~".offsetof");
	H5T.insert(tid, "date", offsetof!(T,"date"), 
createDataType!(KalDate));
	static if(hasMember!(T,"open"))
		H5T.insert(tid,"open",offsetof!(T,"open"),mapDtoHDF5Type("double"));
}

I would like to check if date has a member called second.

Thanks.


More information about the Digitalmars-d-learn mailing list