aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src/std/traits.d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-03-21 16:52:40 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2022-03-21 19:51:50 +0100
commitfbdaa58162ee4189f441b75170af89215465d189 (patch)
tree77c5816b721cad2691bea1d228cb5ecc31568f9c /libphobos/src/std/traits.d
parent4a3073f04e8b7987ad7bfe1bc23bfeb1d627ee6a (diff)
downloadgcc-fbdaa58162ee4189f441b75170af89215465d189.zip
gcc-fbdaa58162ee4189f441b75170af89215465d189.tar.gz
gcc-fbdaa58162ee4189f441b75170af89215465d189.tar.bz2
d: Merge upstream dmd 2503f17e5, phobos a74fa63e6.
D front-end changes: - Import dmd mainline development. - Removed internal d_intN and d_unsN aliases to stdint types, which caused a regression on Solaris where int8_t is a char (PR104911). Phobos changes: - Import phobos mainline development. PR d/104911 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 2503f17e5. * d-convert.cc (convert_expr): Replace d_uns64 with dinteger_t. * d-lang.cc: Remove dmd/root/file.h include. (d_handle_option): Update for new front-end interface. (d_parse_file): Likewise. libphobos/ChangeLog: * src/MERGE: Merge upstream phobos a74fa63e6.
Diffstat (limited to 'libphobos/src/std/traits.d')
-rw-r--r--libphobos/src/std/traits.d40
1 files changed, 40 insertions, 0 deletions
diff --git a/libphobos/src/std/traits.d b/libphobos/src/std/traits.d
index 596c11c..9ca676d 100644
--- a/libphobos/src/std/traits.d
+++ b/libphobos/src/std/traits.d
@@ -9080,3 +9080,43 @@ enum isCopyable(S) = __traits(isCopyable, S);
static assert(isCopyable!int);
static assert(isCopyable!(int[]));
}
+
+/**
+ * The parameter type deduced by IFTI when an expression of type T is passed as
+ * an argument to a template function.
+ *
+ * For all types other than pointer and slice types, `DeducedParameterType!T`
+ * is the same as `T`. For pointer and slice types, it is `T` with the
+ * outer-most layer of qualifiers dropped.
+ */
+package(std) template DeducedParameterType(T)
+{
+ static if (is(T == U*, U) || is(T == U[], U))
+ alias DeducedParameterType = Unqual!T;
+ else
+ alias DeducedParameterType = T;
+}
+
+@safe unittest
+{
+ static assert(is(DeducedParameterType!(const(int)) == const(int)));
+ static assert(is(DeducedParameterType!(const(int[2])) == const(int[2])));
+
+ static assert(is(DeducedParameterType!(const(int*)) == const(int)*));
+ static assert(is(DeducedParameterType!(const(int[])) == const(int)[]));
+}
+
+@safe unittest
+{
+ static struct NoCopy
+ {
+ @disable this(this);
+ }
+
+ static assert(is(DeducedParameterType!NoCopy == NoCopy));
+}
+
+@safe unittest
+{
+ static assert(is(DeducedParameterType!(inout(int[])) == inout(int)[]));
+}