How to cast `shared` away reliably

Arafel er.krali at gmail.com
Wed Feb 11 12:38:37 UTC 2026


On 2/11/26 12:26, Nick Treleaven wrote:
> There is also `Unshared`:
> https://dlang.org/phobos/std_traits.html#Unshared
> 
> It only strips head shared though.

Interesting, it seems the implementation is the second one I tried:

https://github.com/dlang/phobos/blob/v2.112.0/std/traits.d#L7898-L7904

So it seems this is known and documented, even with a test / example:

> Only explict shared is removed.

> static assert(is(Unshared!(shared(int[])) == shared(int)[]));

How can I know what _implicit_ shared there are? Is there a rationale 
for them, or somewhere in the spec where they are mentioned?

Or it is how it is, and that's all there is to it?


More information about the Digitalmars-d mailing list