Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 2 April 2022 at 14:49:15 UTC, Vijay Nayar wrote: On Saturday, 2 April 2022 at 14:35:10 UTC, Vijay Nayar wrote: The `tryMatch` method fails to compile, and instead I get the following error: ```d /dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(2004): Error: static assert: "`

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/1/22 6:22 PM, Vijay Nayar wrote: Consider the following program: ```d void main() {   import std.stdio;   import std.container.rbtree;   import std.variant;   // alias Type = int;  // Works with no problem.   alias Type = Variant; // Produces error.   auto rbTree = new RedBlackTree!(

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread vit via Digitalmars-d-learn
On Saturday, 2 April 2022 at 14:49:15 UTC, Vijay Nayar wrote: On Saturday, 2 April 2022 at 14:35:10 UTC, Vijay Nayar wrote: The `tryMatch` method fails to compile, and instead I get the following error: ```d /dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(2004): Error: static assert: "`

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 14:35:10 UTC, Vijay Nayar wrote: The `tryMatch` method fails to compile, and instead I get the following error: ```d /dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(2004): Error: static assert: "`handlers[0]` of type `int function(ref ubyte[] _1, ref ubyte[]

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 10:04:49 UTC, vit wrote: Try use ```std.sumtype```. I'm playing with SumType to see how it works, and I must be doing something silly, because it fails to compile with the first example type I attempted. Consider the following: ```d import std.sumtype; import st

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 14:23:31 UTC, Salih Dincer wrote: If your type includes opCmp() there is no reason not to use rbTree. I am using rbTree, the problem is when I try to use it with Variant, at which point it blows up.

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 1 April 2022 at 22:22:21 UTC, Vijay Nayar wrote: A `RedBlackTree` constructs and runs perfectly fine using "int" as the data type, but it seems to blow up as soon as I use `std.variant : Variant`. ``` Compilation output (1: ) /dlang/dmd/linux/bin64/../../src/phobos/std/container/

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 10:03:19 UTC, JG wrote: You need an order on the elements in a red black tree. Am I correct in thinking you want a container of the form given a key (a string) recover some data (of different types). If so make the elements you store in the red black tree tuples (k,

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread vit via Digitalmars-d-learn
On Friday, 1 April 2022 at 22:22:21 UTC, Vijay Nayar wrote: Consider the following program: ```d void main() { import std.stdio; import std.container.rbtree; import std.variant; [...] Variant can contain any type => variant cannot assume attributes like pure nothrow @safe @nogc o

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread JG via Digitalmars-d-learn
On Friday, 1 April 2022 at 22:22:21 UTC, Vijay Nayar wrote: Consider the following program: ```d void main() { import std.stdio; import std.container.rbtree; import std.variant; [...] You need an order on the elements in a red black tree. Am I correct in thinking you want a conta

Can std.variant be used with std.container.rbtree?

2022-04-01 Thread Vijay Nayar via Digitalmars-d-learn
Consider the following program: ```d void main() { import std.stdio; import std.container.rbtree; import std.variant; // alias Type = int; // Works with no problem. alias Type = Variant; // Produces error. auto rbTree = new RedBlackTree!(Type); rbTree.stable