www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24587] New: Allow negated qualifiers in cast expressions

https://issues.dlang.org/show_bug.cgi?id=24587

          Issue ID: 24587
           Summary: Allow negated qualifiers in cast expressions
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

Allow a `!` in a cast expression to remove specific qualifiers from a type.
Unlike `cast()`, notably `cast(!shared)` removes `shared` only and leaves
`inout` and/or `const` intact if they’re present. More than one can be used
and
`!` negates all of them: `cast(!const shared)` removes `const` and `shared`,
but leaves `inout` intact.

Grammar:
```diff
    CastQual:
        cast ( TypeCtors? ) UnaryExpression
+       cast ( ! TypeCtors ) UnaryExpression
```
Note that the `TypeCtors` in the second rule one aren’t optional.

--
Jun 05