aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src/std/traits.d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2023-11-02 13:24:07 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2023-11-02 14:54:13 +0100
commit04802ed3b94bdc3083547ac08bca71764a004d01 (patch)
tree2d492f8013b9bdb4af409c973fdd3990ab34dd31 /libphobos/src/std/traits.d
parent8a4cde6319b40802a842a8fe71267524dd8af828 (diff)
downloadgcc-04802ed3b94bdc3083547ac08bca71764a004d01.zip
gcc-04802ed3b94bdc3083547ac08bca71764a004d01.tar.gz
gcc-04802ed3b94bdc3083547ac08bca71764a004d01.tar.bz2
d: Merge upstream dmd, druntime 643b1261bb, phobos 1c98326e7
D front-end changes: - Suggested preview switches now give gdc flags (PR109681). - `new S[10]' is now lowered to `_d_newarrayT!S(10)'. D runtime changes: - Runtime compiler library functions `_d_newarrayU', `_d_newarrayT', `_d_newarrayiT' have been converted to templates. Phobos changes: - Add new `std.traits.Unshared' template. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 643b1261bb. * d-attribs.cc (build_attributes): Update for new front-end interface. * d-lang.cc (d_post_options): Likewise. * decl.cc (layout_class_initializer): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 643b1261bb. * libdruntime/Makefile.am (DRUNTIME_DSOURCES_FREEBSD): Add core/sys/freebsd/ifaddrs.d, core/sys/freebsd/net/if_dl.d, core/sys/freebsd/sys/socket.d, core/sys/freebsd/sys/types.d. (DRUNTIME_DSOURCES_LINUX): Add core/sys/linux/linux/if_arp.d, core/sys/linux/linux/if_packet.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 1c98326e7.
Diffstat (limited to 'libphobos/src/std/traits.d')
-rw-r--r--libphobos/src/std/traits.d41
1 files changed, 41 insertions, 0 deletions
diff --git a/libphobos/src/std/traits.d b/libphobos/src/std/traits.d
index aa69aac..2e7a4f6 100644
--- a/libphobos/src/std/traits.d
+++ b/libphobos/src/std/traits.d
@@ -132,6 +132,7 @@
* $(LREF PointerTarget)
* $(LREF Signed)
* $(LREF Unconst)
+ * $(LREF Unshared)
* $(LREF Unqual)
* $(LREF Unsigned)
* $(LREF ValueType)
@@ -7848,6 +7849,46 @@ else
static assert(is(Unconst!ImmIntArr == immutable(int)[]));
}
+/++
+ Removes `shared` qualifier, if any, from type `T`.
+
+ Note that while `immutable` is implicitly `shared`, it is unaffected by
+ Unshared. Only explict `shared` is removed.
+ +/
+template Unshared(T)
+{
+ static if (is(T == shared U, U))
+ alias Unshared = U;
+ else
+ alias Unshared = T;
+}
+
+///
+@safe unittest
+{
+ static assert(is(Unshared!int == int));
+ static assert(is(Unshared!(const int) == const int));
+ static assert(is(Unshared!(immutable int) == immutable int));
+
+ static assert(is(Unshared!(shared int) == int));
+ static assert(is(Unshared!(shared(const int)) == const int));
+
+ static assert(is(Unshared!(shared(int[])) == shared(int)[]));
+}
+
+@safe unittest
+{
+ static assert(is(Unshared!( int) == int));
+ static assert(is(Unshared!( const int) == const int));
+ static assert(is(Unshared!( inout int) == inout int));
+ static assert(is(Unshared!( inout const int) == inout const int));
+ static assert(is(Unshared!(shared int) == int));
+ static assert(is(Unshared!(shared const int) == const int));
+ static assert(is(Unshared!(shared inout int) == inout int));
+ static assert(is(Unshared!(shared inout const int) == inout const int));
+ static assert(is(Unshared!( immutable int) == immutable int));
+}
+
version (StdDdoc)
{
/**