summaryrefslogtreecommitdiff
path: root/libphobos/src/std/traits.d
diff options
context:
space:
mode:
Diffstat (limited to 'libphobos/src/std/traits.d')
-rw-r--r--libphobos/src/std/traits.d21
1 files changed, 18 insertions, 3 deletions
diff --git a/libphobos/src/std/traits.d b/libphobos/src/std/traits.d
index 9ca676d312a..18400e3e859 100644
--- a/libphobos/src/std/traits.d
+++ b/libphobos/src/std/traits.d
@@ -1422,6 +1422,11 @@ if (isCallable!func)
enum val = "val" ~ (name == "val" ? "_" : "");
enum ptr = "ptr" ~ (name == "ptr" ? "_" : "");
mixin("
+ enum hasDefaultArg = (PT[i .. i+1] " ~ args ~ ") { return true; };
+ ");
+ static if (is(typeof(hasDefaultArg())))
+ {
+ mixin("
// workaround scope escape check, see
// https://issues.dlang.org/show_bug.cgi?id=16582
// should use return scope once available
@@ -1432,10 +1437,9 @@ if (isCallable!func)
auto " ~ val ~ " = " ~ args ~ "[0];
auto " ~ ptr ~ " = &" ~ val ~ ";
return *" ~ ptr ~ ";
- };
- ");
- static if (is(typeof(get())))
+ };");
enum Get = get();
+ }
else
alias Get = void;
// If default arg doesn't exist, returns void instead.
@@ -1483,6 +1487,17 @@ if (isCallable!func)
static foreach (V; Voids) static assert(is(V == void));
}
+// https://issues.dlang.org/show_bug.cgi?id=20182
+@safe pure nothrow @nogc unittest
+{
+ struct S
+ {
+ this(ref S) {}
+ }
+
+ static assert(__traits(compiles, ParameterDefaults!(S.__ctor)));
+}
+
/**
* Alternate name for $(LREF ParameterDefaults), kept for legacy compatibility.
*/