Skip to content
Open
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
13 changes: 7 additions & 6 deletions std/variant.d
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Source: $(PHOBOSSRC std/variant.d)
module std.variant;

import std.meta, std.traits, std.typecons;
import core.memory : GC;

///
@system unittest
Expand Down Expand Up @@ -428,8 +429,8 @@ private:
}
else
{
// object will be intialized later. Using ubyte buffer in case `this()` is disabled
A* p = cast(A*) (new ubyte[A.sizeof]).ptr;
// object will be intialized later. Using malloc in case `this()` is disabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments don't appear to make a whole lot of sense given the changes that have taken place.

Please remove all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to communicate that I'm using GC.malloc here because the constructor of a type might be disabled, but this would be fine because we don't care about the constructor, only the postblit

If you say this doesn't make sense, is this because I have an error in my logic, written the comment in a confusing way or is it because the comment is self evident and redundant?

A* p = cast(A*) GC.malloc(A.sizeof, 0, typeid(A));
}
*cast(A**)&target.store = p;
}
Expand Down Expand Up @@ -679,8 +680,8 @@ switchStmtTupAssign:
static if (is(A == U[n], U, size_t n))
auto p = cast(A*) (new U[n]).ptr;
else
// object will be intialized later. Using ubyte buffer in case `this()` is disabled
A* p = cast(A*) (new ubyte[A.sizeof]).ptr;
// object will be intialized later. Using malloc in case `this()` is disabled
A* p = cast(A*) GC.malloc(A.sizeof, 0, typeid(A));
// Emplace will run the postblit of `A` us, no need to do it manually, then
copyEmplace(*zis, *p);
*(cast(A**) pStore) = p;
Expand Down Expand Up @@ -789,8 +790,8 @@ public:
static if (is(T == U[n], U, size_t n))
T* p = cast(T*) (new U[n]).ptr;
else
// object will be intialized later. Using ubyte buffer in case `this()` is disabled
T* p = cast(T*) (new ubyte[T.sizeof]).ptr;
// object will be intialized later. Using malloc in case `this()` is disabled
T* p = cast(T*) GC.malloc(T.sizeof, 0, typeid(T));
copyEmplace(rhs, *p);
*(cast(T**) &store) = p;
}
Expand Down
Loading