On 12/13/17 11:30 AM, jmh530 wrote:
On Wednesday, 13 December 2017 at 16:00:32 UTC, Steven Schveighoffer wrote:
A nice puzzle for those template gurus out there.

I have a function like this:

auto foo(T: V[K], V, K)(T t)
{
   RealAAType!(T, V, K) aa = t;
   return aa;
}

So I need to know what to write RealAAType. What I'm looking for is a mechanism to write the exact AA type that is passed in. RealAAType should be an AA, and nothing else.

[snip]

How about:

template RealAAType!(T, V, K)
{
     import std.traits : CopyConstness;

     alias RealAAType = CopyConstness!(T, V[K]);
}

Yes, that seems to work, I was worried that something like this would give me multiple type modifiers (.e.g const(const(int)[int])

Now, I need to figure out how to do this in object.d :)

BTW, the PR that spurred this for reference: https://github.com/dlang/druntime/pull/1992

-Steve

Reply via email to