Commit graph

80 commits

Author SHA1 Message Date
k-hara
206d6f7fe9 Add workaround to fix issue 10567
Currently VariantN does not support const objects comparison. So just add specialized opCmp member and use cast().
2013-07-10 01:33:21 +09:00
Martin Nowak
2dba41d032 fix issue 10017 2013-05-27 17:15:43 +02:00
Vladimir Panteleev
2e4dbe8623 std.variant: Fix "ditto ditto" documentation bug 2013-04-10 13:21:41 +00:00
k-hara
3eecfd2b1e fix Issue 3789 - Structs members that require non-bitwise comparison not correctly compared 2013-03-09 16:52:43 +09:00
Andrei Alexandrescu
74cd007c6f Fix issue 4921 - Synopsis code in std.variant documentation throws an assertion error
http://d.puremagic.com/issues/show_bug.cgi?id=4921
2013-02-26 12:04:07 -05:00
Andrei Alexandrescu
7b03c1eda5 issue 5310 2013-02-25 01:48:46 +02:00
jmdavis
a9bf4d4136 Make std.variant.maxSize public.
It's kind of hard to use VariantN without it.
2013-02-04 19:54:57 -08:00
k-hara
128aa9f8fc Remove remain redundant parenthesis. 2012-12-03 00:53:38 +09:00
k-hara
01df2f60be Remove redundant parenthesis for getters, and use assignment syntax for setters 2012-11-23 15:07:17 +09:00
David Nadlinger
d3d0bf0ffc Fix Issue 9043 - Crash on comparing unordered types. 2012-11-18 01:27:49 +01:00
David Nadlinger
0d05bfb615 Fix Variant comparison ops (fixes issue 7990).
Note that ptrdiff_t.min is used as a sentinel value in opCmp;
seems like this was an oversight during the 64 bit mass migration
in 8331c709.
2012-11-18 00:58:07 +01:00
David Nadlinger
464151ddc1 Removed unneeded imports. 2012-11-18 00:17:08 +01:00
alexrp
b202180295 Remove all uses of sizediff_t in favor of ptrdiff_t. 2012-10-15 04:24:09 +02:00
Andrei Alexandrescu
d94803416b Merge pull request #805 from callumenator/master
Fix for issue 8689, Variant doesn't attempt float conversion in opArithmetic
2012-09-28 06:40:36 -07:00
André Stein
f5600708b4 Changes according to 9rnsr's review. 2012-09-27 18:25:17 +02:00
André Stein
b01ef30580 Integrated 9rnsr's suggestions. 2012-09-27 17:25:49 +02:00
André Stein
69faa7ab24 Fixed comments (ouch). 2012-09-27 14:48:41 +02:00
André Stein
62223f51da Fixed auto tester errors - () forgotten in visit call. 2012-09-27 14:39:26 +02:00
André Stein
a14142d3fb Integrated first chunk of changes of Andrei's review. 2012-09-27 14:25:59 +02:00
André Stein
038813a4c8 Fix warnings, auto tester should succeed now. 2012-09-22 12:28:19 +02:00
Callum Anderson
3bd4e2a055 Add check for conversion to float in opArithmetic 2012-09-18 12:21:12 -08:00
André Stein
7469408f81 visit and tryVisit have been extended to allow at most one function with no parameters which is called in case of errors (variant doesn't hold a value or in case of tryVisit, holds a value which can't be handled by visiting functions). 2012-09-13 22:59:44 +02:00
André Stein
692916fbd9 Updated visit to allow just delegates passed using the template parameter list. 2012-09-13 22:59:44 +02:00
André Stein
8eec1a2502 New implementation of visit and tryVisit that allows visitor structs and classes as well as delegate functions to be passed as parameters.
tryVisit is a new function which doesn't statically ensures that all types are handled by the visiting
functions. A VariantException is thrown if the algebraic holds a value which isn't handled by
the visitors.

visit and tryVisit share a common private template function as backend which does all the magic. applyDelegate and
applyVisitor have practically been merged into one new function.
2012-09-13 22:59:44 +02:00
André Stein
05cb2c08a2 std.variant: Added more explicit template constraint to applyDelegate which checks for a Algebraic type.
The new constraint isAlgebraic checks for all member functions and types used from  Algebraic and makes it hard to call the applyDelegate with arbitrary types.
2012-09-13 22:59:44 +02:00
André Stein
95fcb05bfa std.variant: Updated pull request according to klickverbot's comments.
- Now compiles now on 64bit. size_t -> int cast in unittest has been the problem. Unittests and documentation has been updated.
- Updated template constraints: applyDelegates doesn't need one as the previous constraint is implicitly checked during instation. applyVisitor now has an additional template constraint to just allow Algebraic types.
- Must not compile code in unittests has been replaced by static assert and __trait(compiles) checks.
2012-09-13 22:59:44 +02:00
André Stein
7aa8d1b7d1 std.variant: applyVisitor had unnecessary template restriction. 2012-09-13 22:59:44 +02:00
André Stein
dd869b75f1 std.variant: Implement applyVisitor and applyDelegate.
applyVisitor allows to apply a visitor to the given Algebraic depending
on its held type. It works like boost::apply_visitor of Boost.Variant.
A visitor is specified as a structure
or class which implements opCall overloads for each supported type of the
Algebraic. The function statically ensures that all types are handled by the
visitor.

applyDelegate works like applyVisitor but allows to specfiy the visiting
functions as delegates or static functions. Static checks ensure that
all types are handled and only allowed delegates are passed to the function.
2012-09-13 22:59:44 +02:00
jmdavis
02931eb501 Revert "Merge pull request #664 from denis-sh/add-ArrayTarget-template"
This reverts commit f4d0a49493, reversing
changes made to 3cb69914c5.

The merging of request #664 was accidental, and it should not have been
merged. See https://github.com/D-Programming-Language/phobos/pull/664
for details.
2012-07-11 11:49:28 -07:00
Denis Shelomovskij
00c0d61403 Replace typeof(<type>.init[0]) with templates
* ArrayTarget (12)
2012-07-06 13:38:06 +04:00
jmdavis
52b51cf2dd Fix for issue# 8195. 2012-06-03 22:08:38 -07:00
alexrp
c12eebb3c8 @trusted pure nothrow const in some parts of std.variant. 2012-05-23 18:49:44 +02:00
Adam D. Ruppe
30a47fa942 string to int coerce unittest 2012-03-17 13:19:59 -04:00
Adam D. Ruppe
34a90eb531 coerce string to other types workaround 2012-03-16 17:52:50 -04:00
Walter Bright
380ae65511 remove empty statements 2011-12-29 00:05:45 -08:00
k-hara
e9a4f6660d Issue 7070 - can't assign null to Variant 2011-12-10 12:26:48 +09:00
David Nadlinger
e312f9898b Strict @property syntax compliance.
This enables the test suite to build with the -property switch enabled.

std.cpuid: vendor()/processor() have not been converted to properties in accordance to core.cpuid.
std.xml: Element.text() cannot be a property due to the optional parameter.
2011-12-04 09:56:14 +01:00
k-hara
469750227d Fix for issue 6695.
This fix never changes any behaviors.
2011-10-06 17:02:41 +09:00
Andrei Alexandrescu
ee5c3a39e5 Fixed http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=139182 and unlisted bug in std.stdio.write 2011-06-21 09:41:59 -05:00
Walter Bright
046e1b36db add source links 2011-02-06 15:46:50 -08:00
Andrei Alexandrescu
6f81c573f8 Fix for issue 5424 2011-01-23 22:26:29 -06:00
Don Clugston
84477a5d3e Move Boost copyright declaration from ddoc to normal comment. Fixes ugly ddoc output. 2010-11-24 19:34:47 +00:00
David Simcha
8331c70969 More 64 fixes for semantic errors that only show up when templates are instantiated via unittests. Now I'm actually serious about Phobos passing semantic analysis, except for a few modules due to weird druntime issues. 2010-11-10 05:25:50 +00:00
Sean Kelly
be63564a50 Minimal support for shared types within a Variant. 2010-10-07 21:27:13 +00:00
Sean Kelly
ba51dffa9d Fixed Variant to accept types that are copy constructible but not default constructible. 2010-09-30 18:00:56 +00:00
Andrei Alexandrescu
5248dc6b3f Fix for bugzilla 2669 2010-09-26 20:33:55 +00:00
Andrei Alexandrescu
5a64b47d10 Fix for Bugzilla 2073 2010-09-26 04:35:12 +00:00
Andrei Alexandrescu
3f2b8c12ea 64-bit compatibility work 2010-08-22 20:55:22 +00:00
Andrei Alexandrescu
432e3fdfc8 Replaced std.contracts with std.exception throughout 2010-07-04 22:09:03 +00:00
Sean Kelly
daded040c0 Fixed a segfault calling convertsTo for large types. 2010-06-19 05:58:20 +00:00