January 27, 2009 Re: Trick for teasing out static/constness of member in D1? | ||||
---|---|---|---|---|
| ||||
Taking a cue from a trick seen in recent bug report from Andrei, I found that this seems to do what I want:
static if(is(typeof({return A.length; }))) {
writefln("A is static");
}
I'm really more interested in it being static than being const so that should do it for me.
--bb
On Tue, Jan 27, 2009 at 12:08 PM, Bill Baxter <wbaxter@gmail.com> wrote:
> I'd like to do something like this:
>
> static if (AType.length is a static constant ) {
> const has_static_length = true;
> }
> else static if (AType.length exists but it's not a compile-time constant) {
> const has_static_length = false;
> }
> else {
> // there is no .length at all
> }
>
>
> Anyone have a neat trick for this that works in D1?
>
>
> --bb
>
|
Copyright © 1999-2021 by the D Language Foundation