Can std.variant be used with std.container.rbtree?
Vijay Nayar
madric at gmail.com
Sat Apr 2 14:49:15 UTC 2022
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[] _2) pure nothrow @nogc @safe` never
> matches"
> ```
Through sheer trial and error, I discovered that changing the
handler arguments from `ref ubyte[]` to `const ref ubyte[]` the
error goes away. However, I did not find any information in the
documentation or code that made this requirement clear. It was
basically a guess based on the fact that `string` has no trouble
but `ubyte[]` did, and string is basically just
`immutable(char[])`.
So far, I'm finding that learning to use `SumType` is
significantly more cryptic than `Variant`, by a large margin.
I'll still give it a shot of course, because I want to get past
this problem.
More information about the Digitalmars-d-learn
mailing list