2 problems I can't get my head around
Adam D. Ruppe
destructionator at gmail.com
Mon Nov 26 09:11:47 PST 2012
On Monday, 26 November 2012 at 17:03:41 UTC, Manu wrote:
> Error: variable isProperty cannot be read at compile time
that doesn't make any sense :S
> TL;DR, std.traits is extremely brittle, and rather incomplete.
> As a programmer with deadlines trying to get work done, it
> is just not yet acceptable >_<
I totally get this though... just look at this pile of crap from
my web.d, which is used in some really ugly conditions.
I don't even know what it all even does or why it works. It was a
few weekends of random guessing:
// these are all filthy hacks
template isEnum(alias T) if(is(T)) {
static if (is(T == enum))
enum bool isEnum = true;
else
enum bool isEnum = false;
}
// WTF, shouldn't is(T == xxx) already do this?
template isEnum(T) if(!is(T)) {
enum bool isEnum = false;
}
template isStruct(alias T) if(is(T)) {
static if (is(T == struct))
enum bool isStruct = true;
else
enum bool isStruct = false;
}
// WTF
template isStruct(T) if(!is(T)) {
enum bool isStruct = false;
}
template Passthrough(T) {
T Passthrough;
}
template PassthroughType(T) {
alias T PassthroughType;
}
Soooo yeah. I'm sure there's a way to get what you want, but I'm
equally sure you'll have some pain in the mean time that can take
a while to figure through.
More information about the Digitalmars-d
mailing list