digitalmars.D.learn - Unqual for safe system and trusted
- Johannes Pfau (15/15) Dec 11 2010 Is there something like Unqual that can remove the safety attributes fro...
- bearophile (4/6) Dec 11 2010 In such cases we have to ask what's your use case/purpose. Isn't @truste...
- Johannes Pfau (15/23) Dec 12 2010 Well, for my signal implementation (Latest code: http://ideone.com/SM11K...
Is there something like Unqual that can remove the safety attributes from a type? Unqual doesn't work: ----------------------------------------------------------------------------------- class handler { safe void opCall(int i) {} } static assert(is(Unqual!(typeof(&(handler.init.opCall))) == void delegate(int))); ----------------------------------------------------------------------------------- event.d(554): Error: static assert (is(void delegate(int i) safe == void delegate(int b))) is false -- Johannes Pfau
Dec 11 2010
Johannes Pfau:Is there something like Unqual that can remove the safety attributes from a type?In such cases we have to ask what's your use case/purpose. Isn't trusted enough? Bye, bearophile
Dec 11 2010
Am 11.12.2010, 19:33 Uhr, schrieb bearophile <bearophileHUGS lycos.com>:Johannes Pfau:Well, for my signal implementation (Latest code: http://ideone.com/SM11K ) I have templates which accept functions, delegates and callable objects. I used something like "static if(is(T == void delegate(int)))" to check if: 1. T is a delegate 2. it returns void 3. it takes one int parameter In this case I'm only interested in these three points, I don't care if T is safe trusted or system, but the above check fails if T is safe. I found a solution though, I now do these checks with functions from std.traits: ReturnType!(T) for the return type, is(typeof(T.init(Init!(Types)))) for parameters and is(T == delegate). Seems to work fine now. -- Johannes PfauIs there something like Unqual that can remove the safety attributes from a type?In such cases we have to ask what's your use case/purpose. Isn't trusted enough? Bye, bearophile
Dec 12 2010