@@ -1076,12 +1076,26 @@ static assert(__traits(getParameterStorageClasses, foo(p, a, b, c), 3)[0] == "la
1076
1076
$(H3 $(GNAME parameters))
1077
1077
1078
1078
$(P May only be used inside a function. Takes no arguments, and returns
1079
- a sequence of the enclosing function's parameters.)
1080
-
1081
- $(P If the function is nested, the parameters returned are those of the
1082
- inner function, not the outer one.)
1079
+ an $(DDSUBLINK spec/template, lvalue-sequences, lvalue sequence) of the
1080
+ enclosing function's parameters.)
1083
1081
1082
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
1084
1083
---
1084
+ alias AliasSeq(A...) = A;
1085
+
1086
+ void f(int n, char c)
1087
+ {
1088
+ alias PS = __traits(parameters);
1089
+ PS[0]++; // increment n
1090
+ static assert(is(typeof(PS) == AliasSeq!(int, char)));
1091
+
1092
+ // output parameter names
1093
+ static foreach (i, p; PS)
1094
+ {
1095
+ pragma(msg, __traits(identifier, p));
1096
+ }
1097
+ }
1098
+
1085
1099
int add(int x, int y)
1086
1100
{
1087
1101
return x + y;
@@ -1093,7 +1107,13 @@ $(H3 $(GNAME parameters))
1093
1107
// equivalent to;
1094
1108
//return add(x, y);
1095
1109
}
1110
+ ---
1111
+ )
1112
+
1113
+ $(P If the function is nested, the parameters returned are those of the
1114
+ inner function, not the outer one.)
1096
1115
1116
+ ---
1097
1117
int nestedExample(int x)
1098
1118
{
1099
1119
// outer function's parameters
@@ -1108,7 +1128,8 @@ $(H3 $(GNAME parameters))
1108
1128
1109
1129
return add(x, x);
1110
1130
}
1111
-
1131
+ ---
1132
+ ---
1112
1133
class C
1113
1134
{
1114
1135
int opApply(int delegate(size_t, C) dg)
0 commit comments