diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-07 20:49:06 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-11 19:18:03 +0100 |
commit | c9f7090d930504db772557c18f16599e03d616ea (patch) | |
tree | 0b4658e755356787447f7c721919608e4da0cddc /libphobos/src/std/traits.d | |
parent | 292be6817150ed11d599b6ac92269041ed62eb3a (diff) | |
download | gcc-c9f7090d930504db772557c18f16599e03d616ea.zip gcc-c9f7090d930504db772557c18f16599e03d616ea.tar.gz gcc-c9f7090d930504db772557c18f16599e03d616ea.tar.bz2 |
d: Merge upstream dmd, druntime 82a5d2a7c4, phobos dbc09d823
D front-end changes:
- Import latest fixes from dmd v2.110.0-beta.1.
- Added traits `getBitfieldOffset' and `getBitfieldWidth'.
- Added trait `isCOMClass' to detect if a type is a COM class.
- Added `-fpreview=safer` which enables safety checking on
unattributed functions.
D runtime changes:
- Import latest fixes from druntime v2.110.0-beta.1.
Phobos changes:
- Import latest fixes from phobos v2.110.0-beta.1.
- Added `fromHexString' and `fromHexStringAsRange' functions to
`std.digest'.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 82a5d2a7c4.
* d-lang.cc (d_handle_option): Handle new option `-fpreview=safer'.
* expr.cc (ExprVisitor::NewExp): Remove gcc_unreachable for the
generation of `_d_newThrowable'.
* lang.opt: Add -fpreview=safer.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime 82a5d2a7c4.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add
core/internal/gc/blkcache.d, core/internal/gc/blockmeta.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos dbc09d823.
Diffstat (limited to 'libphobos/src/std/traits.d')
-rw-r--r-- | libphobos/src/std/traits.d | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/libphobos/src/std/traits.d b/libphobos/src/std/traits.d index 69362c0..f230aa3 100644 --- a/libphobos/src/std/traits.d +++ b/libphobos/src/std/traits.d @@ -7251,16 +7251,21 @@ alias PointerTarget(T : T*) = T; /** * Detect whether type `T` is an aggregate type. */ -enum bool isAggregateType(T) = is(T == struct) || is(T == union) || - is(T == class) || is(T == interface); +template isAggregateType(T) +{ + static if (is(T == enum)) + enum isAggregateType = isAggregateType!(OriginalType!T); + else + enum isAggregateType = is(T == struct) || is(T == class) || is(T == interface) || is(T == union); +} /// @safe unittest { - class C; - union U; - struct S; - interface I; + class C {} + union U {} + struct S {} + interface I {} static assert( isAggregateType!C); static assert( isAggregateType!U); @@ -7271,6 +7276,16 @@ enum bool isAggregateType(T) = is(T == struct) || is(T == union) || static assert(!isAggregateType!(int[])); static assert(!isAggregateType!(C[string])); static assert(!isAggregateType!(void delegate(int))); + + enum ES : S { a = S.init } + enum EC : C { a = C.init } + enum EI : I { a = I.init } + enum EU : U { a = U.init } + + static assert( isAggregateType!ES); + static assert( isAggregateType!EC); + static assert( isAggregateType!EI); + static assert( isAggregateType!EU); } /** @@ -9238,12 +9253,16 @@ enum isCopyable(S) = __traits(isCopyable, S); * 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) +package(std) alias DeducedParameterType(T) = DeducedParameterTypeImpl!T; +/// ditto +package(std) alias DeducedParameterType(alias T) = DeducedParameterTypeImpl!T; + +private template DeducedParameterTypeImpl(T) { static if (is(T == U*, U) || is(T == U[], U)) - alias DeducedParameterType = Unqual!T; + alias DeducedParameterTypeImpl = Unqual!T; else - alias DeducedParameterType = T; + alias DeducedParameterTypeImpl = T; } @safe unittest @@ -9263,6 +9282,7 @@ package(std) template DeducedParameterType(T) } static assert(is(DeducedParameterType!NoCopy == NoCopy)); + static assert(is(DeducedParameterType!(inout(NoCopy)) == inout(NoCopy))); } @safe unittest |