[Issue 21902] New: Templated Aliases and Enums should support restrictions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri May 7 14:43:37 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21902
Issue ID: 21902
Summary: Templated Aliases and Enums should support
restrictions
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: per.nordlow at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list