www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19226] New: std.typecons.Nullable(T, T nullValue) doesn't

https://issues.dlang.org/show_bug.cgi?id=19226

          Issue ID: 19226
           Summary: std.typecons.Nullable(T, T nullValue) doesn't fully
                    handle non-self-equal nullValue
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

Nullable(T, T nullValue) special-cases floating point numbers but this doesn't
account for all types where nullValue != nullValue. For instance:

https://run.dlang.io/is/hiLncI

---
struct S
{
    float f;
}

void main()
{
    import std.typecons : Nullable;

    alias N = Nullable!(S, S.init);
    assert(N(S.init).isNull); // Fails!
}
---

--
Sep 05 2018