Commit graph

745 commits

Author SHA1 Message Date
Walter Bright
1591ce9fe7 swap-and-destroy called too eagerly 2024-03-18 09:24:00 -07:00
Jonathan M Davis
115b7f61a9 fix Bugzilla Issue 24403 - Nullable doesn't work with non-mutable types with a destructor
This should make it so that a variable of type Nullable!T has the same
behavior with regards to destruction as a variable of type T even when
it's const, immutable, or shared.
2024-02-21 19:06:29 +08:00
Vladimir Panteleev
73a54e2fab std.typecons: Support non-copyable types
Fixes issue 24318.
2024-01-05 07:38:16 +08:00
Vladimir Panteleev
826b00ff58 std.typecons: Avoid a copy in Nullable.opAssign
Use `move` directly.
2024-01-05 07:38:16 +08:00
Vladimir Panteleev
bc2ad75289 std.typecons: Allow calling destructor on default value in unittest
Generally, if a type has a default value, it should be safe to assume
that it's OK to call the destructor on a default-initialized variable.

The converse is not compatible with `move`, and goes against
implementing non-copyable types.
2024-01-05 07:38:16 +08:00
Vladimir Panteleev
03a961d5a5 std.typecons: Refactor a unit test for clarity 2024-01-05 07:38:16 +08:00
Mathis Beer
10601cc046 Add std.typecons.Rebindable2 for internal use.
Rebindable2 is a simplified version of std.typecons.Rebindable that clears up every special case: classes, arrays and structs now have the same struct.
Whichever type you instantiate `Rebindable2` with, you always get the same type out by calling `value.get` on the resulting container.
Also use this type to simplify the parts of Phobos we previously used `Rebindable` for.
2023-06-19 13:24:30 +02:00
Johan Engelen
75a507f883
typecons: fix use-after-scope bug in RefCounted unittest (#8751)
* typecons: fix use-after-scope bug in RefCounted unittest

The access through `p` to `rc1` outside the scope of `rc1` is undefined behavior. We have to artificially end the scope of `rc1` and `rc2`, such that within the same scope we can check that the destructor calls do the correct thing of nulling the `_store`.

* fixup

* fixup
2023-05-29 16:00:15 +03:00
Mathis Beer
2f6b2efaf7 Change struct Rebindable to just use cast() if this is sufficient.
This works better at compiletime.
2023-04-19 22:59:43 +00:00
FeepingCreature
c26d25eecd
Implement Rebindable for non-class/non-array types. (#8722)
Note that you cannot access a reference to the contained value in struct Rebindable.
2023-04-18 11:33:17 +03:00
Mathis Beer
19eaf8a1bd Fix issue 23640: Use Nullable[] to allow iterating Nullable of immutable type. 2023-01-19 12:20:06 +01:00
Nick Treleaven
fdab7cdef9 Remove unnecessary @trusted 2022-12-24 13:07:22 +00:00
Nick Treleaven
c27f250eb5 Tweak 2 tests 2022-12-24 13:06:37 +00:00
Nick Treleaven
d5c1067131
Fix Issue 23561 - std.typecons.Unique!struct does not destroy struct … (#8651)
Fix Issue 23561 - std.typecons.Unique!struct does not destroy struct …

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Signed-off-by: Razvan Nitu <razvan.nitu1305@gmail.com>
Merged-on-behalf-of: Razvan Nitu <razvan.nitu1305@gmail.com>
2022-12-24 13:40:54 +01:00
Walter Bright
2c7e732236 replace isImplicitlyConvertible with is expression 2022-12-01 00:52:55 -08:00
Lucian Danescu
322fed7bf7 add local imports 2022-11-12 19:29:28 +02:00
Lucian Danescu
cdee7e6939 remove redundant attributes in typecons.d 2022-11-04 21:52:10 +01:00
Mathias LANG
3c97810b36
Re-instate accidentally reverted fixes on RefCounted (#8599)
Those fixes were done in PR #8509 but PR #8368 accidentally reverted them.
2022-10-14 06:23:22 +08:00
Ate Eskola
bbd03c9351 Added the needed AliasSeq import to betterC tests. 2022-09-21 23:08:14 +03:00
Ate Eskola
d7b6838fc2 Took copies of most SafeRefCounted unit tests for RefCounted. 2022-09-17 19:48:05 +03:00
Ate Eskola
c277df5547 Applied suggested documentation fixes. 2022-09-17 18:57:22 +03:00
Ate Eskola
490caa7090 RefCounted -> SafeRefCounted, OldRefCounted -> RefCounted. 2022-09-11 01:35:35 +03:00
Ate Eskola
bb145a09a6 Ate's work on safe ref counted 2022-09-11 01:35:35 +03:00
Atila Neves
be598abbeb Atila's work on safe ref counted 2022-09-11 01:35:35 +03:00
Martin Nowak
85d0520220 Merge remote-tracking branch 'upstream/stable' into merge_stable 2022-09-10 15:23:06 +02:00
wolframw
7ce739c5ff
fix issue 23238 - Cannot write a const Nullable(T, T nullValue) 2022-08-26 00:15:55 +02:00
Walter Bright
056606ea56 get std.typecons to compile with PR #14364 2022-08-15 11:48:45 +00:00
Geod24
501a3ab35a std.typecons: Remove workaround for fixed issue 15862 2022-07-18 17:11:59 +02:00
Iain Buclaw
a9a504f406 Merge remote-tracking branch 'upstream/stable' into merge_stable 2022-07-09 17:08:41 +02:00
Razvan Nitu
7e0dbdf1a3
Merge pull request #8500 from RazvanN7/fix_scope_failure
Use try-catch instead of scope(failure) for block that returns
2022-07-07 16:08:38 +03:00
RazvanN7
52935b182a Use try-catch instead of scope(failure) for block that returns 2022-07-07 15:28:43 +03:00
Martin Kinkelin
b20444aca4 Use new __traits(classInstanceAlignment)
Tackling the Phobos part of issue 16508.
2022-05-13 18:38:09 +00:00
Hiroki Noda
5429908c4a Fix: add missing FunctionAttribute 2022-04-25 15:22:59 +00:00
Cameron Ross
90f65d49fb Add range interface to Nullable 2022-03-27 19:18:11 +00:00
Arne Ludwig
3a2cf7f3cb Fixed negation of BitFlags
- negation did not work with unsigned integers with dmd v2.099.0
- also made double negation of flags possible
2022-03-22 12:47:36 +00:00
Iain Buclaw
68ae00efbc Merge branch 'stable' into merge_stable 2022-02-11 22:11:48 +01:00
Mathis Beer
ac5c8d0c85 Fix issue 22701: Remove is(typeof()) callable check in std.typecons.apply.
It creates unreadable template errors for no benefit.
2022-01-26 13:03:29 +01:00
The Dlang Bot
a86c1eba9f
Merge pull request #6876 from thaven/enhancement/autoimplement-add-abstract-parent
Also expose 'parent' when it's abstract

Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2022-01-18 03:54:04 +00:00
Martin Kinkelin
9db3a9afdf Work around issue 22619 - Avoid Nullable copy ctor unless required
Copy ctors are still buggy, so unconditionally adding one for Nullable
is everything but a non-breaking change (and was added in the 2.098.1
point release).
2022-01-10 16:48:29 +01:00
Nick Treleaven
9f336484dc [typecons] Tweak Tuple example and split out Rebindable example 2022-01-10 14:03:09 +00:00
Eduard Staniloiu
95d47777f9 Fix typecons Proxy.opCmp 2021-12-17 17:13:48 +00:00
thaven
47291bb0e6 Temporarily comment out overload in test to work around Issue 19715 2021-12-03 14:07:14 +01:00
Harry T. Vennik
eeccd10f8b Add specific test for parent alias 2021-12-03 14:07:14 +01:00
Harry T. Vennik
443c5d400f Also expose 'parent' when it's abstract 2021-12-03 14:07:14 +01:00
dkorpel
5d0cfcd13a Fix scope usage of SysTime/TimeZone 2021-11-18 23:49:51 +00:00
Ömer Faruk IRMAK
e84de9faae Fix Issue 22511 - Add explicit copy ctor for Nullable 2021-11-15 11:33:51 +03:00
Ömer Faruk IRMAK
b141ae469b Fix Issue 22511 - Add explicit copy ctor for Nullable 2021-11-15 10:33:27 +03:00
DoctorNoobingstoneIPresume
eb66705762 refCounted: unittest now also checks object destruction..
One of the `unittest`'s has been modified to also check that
a `File` object managed via `RefCounted!File` handles is deleted
when its last handle is destroyed;
2021-09-27 02:19:34 +03:00
Paul Backus
1984e8d2a9 Fix Issue 22325 - ReplaceType fails on templated type instantiated with void-returning function
Previously, when recursing into a type's template arguments,
ReplaceTypeUnless would mistakenly attempt to evaluate a template alias
parameter as an expression. In cases where the alias parameter was not a
valid expression or could not be evaluated at compile time, this caused
a compilation failure; in other cases, it caused ReplaceTypeUnless to
give an incorrect result.

This change makes ReplaceTypeUnless correctly treat template alias
parameters as aliases.
2021-09-20 21:42:31 +00:00
Martin Kinkelin
d0bf92cab7 std.typecons: Minimize redundant template declarations/instantiations wrt. Tuple
While glancing over the Tuple template, I've noticed that it uses the
anti-pattern of nested template declarations *not* depending on the
outer Tuple template parameters.
2021-09-17 04:38:55 +00:00