Typeinfo
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 3 04:53:20 PDT 2015
On 4/2/15 8:21 PM, Andrei Alexandrescu wrote:
> Hey folks, is there any way to figure out whether a type is immutable or
> shared given its typeinfo? I see there's only the flags() method that
> doesn't tell that. I'm thinking we'd do good to extend that.
>
> This is needed for allocators. I'm thinking an allocator might be
> interested at creation time to use different allocation strategies for
> qualified types, especially shared ones.
I use this technique in lifetime.d:
// typeof(ti) is TypeInfo
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d#L640
-Steve
More information about the Digitalmars-d
mailing list