Non-Purity of Algebraic opEquals
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 18 11:37:01 PDT 2015
On 9/18/15 2:05 PM, Nordlöw wrote:
> On Friday, 18 September 2015 at 15:40:09 UTC, Jonathan M Davis wrote:
>
>> Regardless, VariantN couldn't have its opEquals explicitly marked with
>> pure, because it's a template and needs to work with types that don't
>> have a pure opEquals. But it _should_ be able to be inferred as pure
>> if the types in question have pure opEquals. However, the situation
>> with Object continues to haunt us.
>
> I'm currently only in need of a VariantN of value-types and string.
>
> Therefore I don't understand why I should need Object.opEquals
> especially not in the case I gave above where Variant only contains a
> `long` and a `double`.
>
> Is there an easy way to modify `VariantN` to not need `Object.opEquals`
> when `VariantN` contains only value types and strings?
The issue is not the comparison of the values, it's the comparison of
the TypeInfo, which is going to be Object.opEquals no matter what your
actual types are.
-Steve
More information about the Digitalmars-d
mailing list