If shared has not been applied to the outer layer of type T, then
the result is T.
Note that while immutable is implicitly shared, it is unaffected
by Unshared. Only explicit shared is removed.
For the built-in scalar types (that is bool, the character types, and
the numeric types), they only have one layer, so sharedU simply
becomes U.
Where the layers come in is pointers and arrays. shared(U*) becomes
shared(U)*, and shared(U[]), becomes shared(U)[]. So, a
pointer goes from being fully shared to being a mutable pointer to
shared, and a dynamic array goes from being fully shared to being
a mutable dynamic array of shared elements. And if there are multiple
layers of pointers or arrays, it's just that outer layer which is affected
- e.g. shared(U**) would become shared(U*)*.
For user-defined types, the effect is that sharedU becomes U,
and how that affects member variables depends on the type of the member
variable. If a member variable is explicitly marked with shared, then
it will continue to be shared even after Unshared has stripped
shared from the containing type. However, if shared was on the
member variable only because the containing type was shared, then when
Unshared removes the qualifier from the containing type, it is removed from
the member variable as well.
Also, Unshared has no effect on what a templated type is instantiated
with, so if a templated type is instantiated with a template argument which
has a type qualifier, the template instantiation will not change.
Removes the outer layer of shared from type T.
If shared has not been applied to the outer layer of type T, then the result is T.
Note that while immutable is implicitly shared, it is unaffected by Unshared. Only explicit shared is removed.
For the built-in scalar types (that is bool, the character types, and the numeric types), they only have one layer, so shared U simply becomes U.
Where the layers come in is pointers and arrays. shared(U*) becomes shared(U)*, and shared(U[]), becomes shared(U)[]. So, a pointer goes from being fully shared to being a mutable pointer to shared, and a dynamic array goes from being fully shared to being a mutable dynamic array of shared elements. And if there are multiple layers of pointers or arrays, it's just that outer layer which is affected - e.g. shared(U**) would become shared(U*)*.
For user-defined types, the effect is that shared U becomes U, and how that affects member variables depends on the type of the member variable. If a member variable is explicitly marked with shared, then it will continue to be shared even after Unshared has stripped shared from the containing type. However, if shared was on the member variable only because the containing type was shared, then when Unshared removes the qualifier from the containing type, it is removed from the member variable as well.
Also, Unshared has no effect on what a templated type is instantiated with, so if a templated type is instantiated with a template argument which has a type qualifier, the template instantiation will not change.