Skip to content

Commit

Permalink
Fix vibe-d#1941 - reall fix for the workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
tchaloupka committed Mar 2, 2019
1 parent 419ec62 commit 206a4bf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions data/vibe/data/serialization.d
Original file line number Diff line number Diff line change
Expand Up @@ -1199,11 +1199,15 @@ private template isBuiltinTuple(T, string member)
}

// heuristically determines @safe'ty of the serializer by testing readValue and writeValue for type int
private enum isSafeSerializer(S) = __traits(compiles, (S s) @safe {
private template isSafeSerializer(S)
{
alias T = Traits!(int, DefaultPolicy);
s.writeValue!T(42);
s.readValue!(T, int)();
});
static if (__traits(hasMember, S, "writeValue"))
enum isSafeSerializer = __traits(compiles, (S s) @safe { s.writeValue!T(42); });
else static if (__traits(hasMember, S, "readValue"))
enum isSafeSerializer = __traits(compiles, (S s) @safe { s.readValue!(T, int)(); });
else static assert(0, "Serializer without writeValue or readValue is invalid");
}

private template hasAttribute(T, alias decl) { enum hasAttribute = findFirstUDA!(T, decl).found; }

Expand Down

0 comments on commit 206a4bf

Please sign in to comment.