dereferencing null

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Mar 8 07:40:01 PST 2012


On Thu, Mar 08, 2012 at 02:57:00PM +0100, Andrej Mitrovic wrote:
[...]
> I don't know why we don't have __traits(allFunction). We have
> 'getVirtualFunctions' but it requires a function name, but using
> allMembers to filter out function names is damn difficult if you ask
> me.

	foreach (name; __traits(allMembers, typeof(obj))) {
		static if (__traits(compiles, &__traits(getMember, obj,
				name)))
		{
			alias typeof(__traits(getMember, obj, name))
				type;
			static if (is(type==function)) {
				// name refers to a function of type
				// 'type' here
			}
		}
	}

> I've never had an easy time interacting with __traits.

Me too. I'm guessing that __traits is the way it is due to ease of
implementation in the compiler. It's certainly not very friendly to use.


T

-- 
Маленькие детки - маленькие бедки.


More information about the Digitalmars-d mailing list