Commit 73e9b41a authored by Harris Hancock's avatar Harris Hancock

Implement DynamicValue::Reader::as<DynamicValue>()

This is required to allow the compiler to successfully instantiate a
JsonCodec::Handler<DynamicValue, Style::POINTER> using Handler's default
partial specialization for Style::POINTER. Such an instantiation is
currently only used in dead code that clang and gcc eliminate but MSVC
does not, which is why the problem was not caught until now.

Also implemented DynamicValue::Builder::as<DynamicValue>() to preserve
symmetry.
parent 0414faac
......@@ -634,6 +634,7 @@ public:
// - DynamicEnum: Returns the corresponding type.
// - DynamicStruct, DynamicList: Returns the corresponding Reader.
// - Any capability type, including DynamicCapability: Returns the corresponding Client.
// - DynamicValue: Returns an identical Reader. Useful to avoid special-casing in generic code.
// (TODO(perf): On GCC 4.8 / Clang 3.3, provide rvalue-qualified version that avoids
// refcounting.)
//
......@@ -1408,6 +1409,19 @@ struct DynamicValue::Builder::AsImpl<T, Kind::INTERFACE> {
}
};
template <>
struct DynamicValue::Reader::AsImpl<DynamicValue> {
static DynamicValue::Reader apply(const Reader& reader) {
return reader;
}
};
template <>
struct DynamicValue::Builder::AsImpl<DynamicValue> {
static DynamicValue::Builder apply(Builder& builder) {
return builder;
}
};
inline DynamicValue::Pipeline::Pipeline(std::nullptr_t n): type(UNKNOWN) {}
inline DynamicValue::Pipeline::Pipeline(DynamicStruct::Pipeline&& value)
: type(STRUCT), structValue(kj::mv(value)) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment