August 23, 2015 [phobos] [D-Programming-Language/phobos] 005775: Allow Variant.visit to support const types. | ||||
---|---|---|---|---|
| ||||
Attachments:
| Branch: refs/heads/master Home: https://github.com/D-Programming-Language/phobos Commit: 0057756b28f78664cc184eac100dc975e3fdc625 https://github.com/D-Programming-Language/phobos/commit/0057756b28f78664cc184eac100dc975e3fdc625 Author: Ryan Roden-Corrent <ryan@rcorre.net> Date: 2015-08-11 (Tue, 11 Aug 2015) Changed paths: M std/variant.d Log Message: ----------- Allow Variant.visit to support const types. Assuming that Foo.depth and Bar.depth are both const (e.g. both are just int members), the following should compile: ----- int depth(in FooBar fb) { return fb.visit!((Foo foo) => foo.depth, (Bar bar) => bar.depth); } ----- However, it was failing with: std/variant.d(2246): Error: cannot implicitly convert expression (variant.peek()) of type const(Foo)* to Foo* std/variant.d(2246): Error: cannot implicitly convert expression (variant.peek()) of type const(Bar)* to Bar* This patch changes an explicit `T*` declaration to an `auto` declaration so const types can be visited. Commit: 82b98200953d38978aab70b567f0658f606bd520 https://github.com/D-Programming-Language/phobos/commit/82b98200953d38978aab70b567f0658f606bd520 Author: Dmitry Olshansky <dmitry.olsh@gmail.com> Date: 2015-08-23 (Sun, 23 Aug 2015) Changed paths: M std/variant.d Log Message: ----------- Merge pull request #3549 from rcorre/variant-visit-inout-fix Allow Variant.visit to support const types. Compare: https://github.com/D-Programming-Language/phobos/compare/354778b43009...82b98200953d |
Copyright © 1999-2021 by the D Language Foundation