Bug 21902 – Templated Aliases and Enums should support restrictions

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-07T14:43:37Z
Last change time
2024-12-13T19:16:15Z
Assigned to
No Owner
Creator
Per Nordlöw
Moved to GitHub: dmd#19923 →

Comments

Comment #0 by per.nordlow — 2021-05-07T14:43:37Z
Template aliases and enums should support restrictions as, for instance, enum maxAlignment(Ts...) if (Ts.length > 0) { size_t result = 0; static foreach (T; Ts) if (T.alignof > result) result = T.alignof; return result; }(); Currently it's only possible to simplify definitions such as template maxAlignment(Ts...) if (Ts.length > 0) { enum maxAlignment = { size_t result = 0; static foreach (T; Ts) if (T.alignof > result) result = T.alignof; return result; }(); } to enum maxAlignment(Ts...) { static assert(Ts.length > 0); size_t result = 0; static foreach (T; Ts) if (T.alignof > result) result = T.alignof; return result; }(); because of this limitation.
Comment #1 by robert.schadek — 2024-12-13T19:16:15Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19923 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB