On Wednesday, 6 May 2020 at 16:01:37 UTC, Paul Backus wrote:
On Wednesday, 6 May 2020 at 09:40:47 UTC, wjoe wrote:
yes, I did read the spec. I read the language spec on traits as well as std.traits docs as well as searching the internet for a solution since day before yesterday. But I couldn't bring it together because

  } else static if (__traits(isRef, T)) {

compiles, but e.g.

   assert (modifier!(ref int) == "[out] ");

doesn't.
Anyways, thanks for your reply.

D doesn't have reference *types*, it only has reference *parameters*. Here's an example:

void fun(ref int r, int v) {
    static assert(is(typeof(r) == int)); // note: not `ref int`
static assert(is(typeof(r) == typeof(v))); // `ref` makes no difference to type

static assert(__traits(isRef, r)); // note: not `__traits(isRef, typeof(r))`
    static assert(!__traits(isRef, v));
}

Hello Paul, thanks for the explanation. This is quite the dilemma then. What this guy does in his library is he builds a static array at compile time and populates it with const and ref type names.

Reply via email to