Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions std/mmfile.d
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ class MmFile
version (Windows)
{
FlushViewOfFile(data.ptr, data.length);
FlushFileBuffers(hFile);
}
else version (Posix)
{
Expand Down
27 changes: 21 additions & 6 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -3814,13 +3814,16 @@ struct Nullable(T)
assert(e != 12);
}

size_t toHash() const @safe nothrow
static if (!isAggregateType!T || hasMember!(T, "toHash"))
{
static if (__traits(compiles, .hashOf(_value.payload)))
return _isNull ? 0 : .hashOf(_value.payload);
else
// Workaround for when .hashOf is not both @safe and nothrow.
return _isNull ? 0 : typeid(T).getHash(&_value.payload);
size_t toHash() const @safe nothrow
{
static if (__traits(compiles, .hashOf(_value.payload)))
return _isNull ? 0 : .hashOf(_value.payload);
else
// Workaround for when .hashOf is not both @safe and nothrow.
return _isNull ? 0 : typeid(T).getHash(&_value.payload);
}
}

/**
Expand Down Expand Up @@ -4826,6 +4829,18 @@ auto nullable(T)(T t)
auto result = cast(immutable(Nullable!(int*))) a;
}

// https://github.com/dlang/phobos/issues/10758
@safe unittest
{
struct F
{
bool opEquals(ref const F rhs) const { return true; }
}

static assert(!__traits(compiles, bool[F]));
static assert(!__traits(compiles, bool[Nullable!F]));
}

/**
Just like `Nullable!T`, except that the null state is defined as a
particular value. For example, $(D Nullable!(uint, uint.max)) is an
Expand Down
Loading