Commit graph

20 commits

Author SHA1 Message Date
John Colvin
9789701e6e fix array members 2019-10-24 17:54:00 +01:00
Sönke Ludwig
f8a9b8c651 Add stronger restrictions to TA.opDispatch. Fixes #9.
Defines opDispatch as two levels of nested templates, so that the outer level only checks the member name to match any member defined by one of the contained types. This allows hasMember!TA  to report proper values instead of always assuming `true`.

As a side-effect, `isOutputRange!(TA, T)` now only returns true, if any of the contained types is actually a matching output range.
2019-10-11 11:13:57 +02:00
Sönke Ludwig
f4c7030459 Let all TaggedAlgebraic operations return as auto ref. Fixes #15. 2019-10-11 10:28:23 +02:00
Sönke Ludwig
ba79a25298 Add explicit unit test for commonAlignment. 2019-04-16 11:49:42 +02:00
Sönke Ludwig
fd85603576 Compute the proper struct alignment for TaggedUnion.
Before this change, the alignment of TaggedAlgebraic was always 4, which in turn had a 50% chance of aligning 8-byte pointers on a non-8-byte boundary, causing the pointer to become invisible to the GC (and less bad, causing performance degradation when dereferencing the pointer). This would happen in particular when the total size of the TaggedUnion/TaggedAlgebraic was not divisible by 8 and an array of values was built.
2019-04-16 11:37:04 +02:00
Denis Feklushkin
3258572585 Ddox fix and CI test added 2019-03-05 19:04:45 +07:00
Sönke Ludwig
141a4e290a Detect types that are obviously not function literals.
This avoids extremely cryptic error messages with no pointer to the origin of the problem.
2019-02-24 14:24:37 +01:00
Sönke Ludwig
953198a293 Fix using non-copyable types with TaggedUnion. 2019-02-23 21:49:08 +01:00
Sönke Ludwig
7145693748 Work around name lookup issue on DMD < 2.081.0. 2019-02-23 18:18:39 +01:00
Sönke Ludwig
56d50fd56c Work around Phobos issue 19696. 2019-02-23 18:18:22 +01:00
Sönke Ludwig
6589bac23a Add TaggedUnion.hasType!T. 2019-02-23 16:16:20 +01:00
Sönke Ludwig
a52958ef01 Work around ReplaceType compile error issue.
ReplaceType doesn't work for "class C : D!C {}"
2019-02-23 15:56:59 +01:00
Sönke Ludwig
b766f62d43 Actually check for superfluous handlers. 2019-02-23 15:55:57 +01:00
Sönke Ludwig
ab25b89fb1 Make self-referential types work with TaggedAlgebraic, too.
Also removes some unused template code.
2019-02-22 19:28:09 +01:00
Sönke Ludwig
f4b621963c Add support for self-referential types using "This" placeholder. 2019-02-22 17:34:08 +01:00
Sönke Ludwig
7ede6bf033 Refactor the TaggedUnion API.
- Add constructors and assignment operators for unique types
- Rename field getters to fooValue and value!() to enable sane property syntax and to avoid confusion when modifying the returned reference
- Fix misnomer "isUnionType" instead of "isUnitType"
2019-02-22 16:11:21 +01:00
Sönke Ludwig
1c88c3c65d Add template constraint to visit/tryVisit. 2019-02-22 12:22:38 +01:00
Sönke Ludwig
59826ad719 Error out on extraneous visitors. 2019-02-22 11:14:56 +01:00
Sönke Ludwig
194e0dca41 Implement a simple version of visit/tryVisit for TaggedUnion.
See #3.
2019-02-22 03:08:55 +01:00
Sönke Ludwig
88308fcba4 Split up TaggedUnion and TaggedAlgebraic into separate modules. 2019-02-22 03:08:55 +01:00