Skip to content

Commit

Permalink
Merge pull request #2981 from WalterBright/totype
Browse files Browse the repository at this point in the history
fix Issue 21585 - add __traits(totype, string)
  • Loading branch information
WalterBright committed Mar 16, 2021
2 parents 2298fc2 + f813034 commit 332ae63
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/traits.dd
Expand Up @@ -75,6 +75,7 @@ $(GNAME TraitsKeyword):
$(GLINK derivedMembers)
$(GLINK isSame)
$(GLINK compiles)
$(GLINK toType)

$(GNAME TraitsArguments):
$(GLINK TraitsArgument)
Expand Down Expand Up @@ -1663,6 +1664,27 @@ void main()
partial specialization allows for.)
)

$(H2 $(GNAME toType))

$(P Takes a single argument, which must evaluate to an expression of type `string`.
The contents of the string must correspond to the $(DDSUBLINK abi, name_mangling, mangled contents of a type)
that has been seen by the implementation.)

$(P Only D mangling is supported. Other manglings, such as C++ mangling, are not.)

$(P The value returned is a type.)

---
template Type(T) { alias Type = T; }

Type!(__traits(toType, "i")) j = 3; // j is declared as type `int`

static assert(is(Type!(__traits(toType, (int*).mangleof)) == int*));

__traits(toType, "i") x = 4; // x is also declared as type `int`
---

$(RATIONALE Provides the inverse operation of the $(DDSUBLINK property, mangleof, `.mangleof`) property.)


$(SPEC_SUBNAV_PREV_NEXT version, Conditional Compilation, errors, Error Handling)
Expand Down

0 comments on commit 332ae63

Please sign in to comment.