www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22647] New: [std.variant.Variant] Cannot compare types


          Issue ID: 22647
           Summary: [std.variant.Variant] Cannot compare types compliant
                    with null comparison with 'null'
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: jlourenco5691 gmail.com

std.variant.Variant should behave the same as the core language. Some types are
comparable with null (arrays and pointers). If the Variant's current type is
one of those, then comparing with null should be allowed.

import std;

void main()
    int* ptr;
    Variant a = ptr; // is of type int*

    assert(ptr == null); // true
    assert(a == null); // false

Jan 03 2022