-
-
Notifications
You must be signed in to change notification settings - Fork 189
Closed
Description
I have the following code.
T is an arbitrary class, in this case request_data_t, which is marked with JSONCONS_ALL_MEMBER_TRAITS.
buffer_stream is std::basic_ostream subclass.
if (
((_incoming._media_type == "application") && (_incoming._media_subtype == "json")) ||
((_incoming._media_type == "text") && (_incoming._media_subtype == "json")))
{
if ((_incoming._media_charset != "UTF-8") && (_incoming._media_charset != "utf-8"))
{
THROW_WIN_EXCEPTION(ERROR_INVALID_PARAMETER, L"Only UTF-8 charset is supported for JSON data");
}
jsoncons::template encode_json<T, char>(value, buffer_stream);
}
else if ((_incoming._media_type == "application") && (_incoming._media_subtype == "bson"))
{
jsoncons::bson::template encode_bson<T>(value, buffer_stream);
}
else if ((_incoming._media_type == "application") && (_incoming._media_subtype == "cbor"))
{
jsoncons::cbor::template encode_cbor<T>(value, buffer_stream);
}
else if ((_incoming._media_type == "application") && (_incoming._media_subtype == "msgpack"))
{
jsoncons::msgpack::template encode_msgpack<T>(value, buffer_stream);
}
else if ((_incoming._media_type == "application") && (_incoming._media_subtype == "ubjson"))
{
jsoncons::ubjson::template encode_ubjson<T>(value, buffer_stream);
}
Compilation fails with
...\vendor\jsoncons_ext/cbor/encode_cbor.hpp(75,1): error C2664: 'void jsoncons::cbor::encode_cbor<jsoncons::cbor::cbor_encode_options,std::ostream>(jsoncons::temp_allocator_arg_t,const TempAllocator &,const T &,std::ostream &,const jsoncons::cbor::cbor_encode_options &)': cannot convert argument 1 from 'const T' to 'jsoncons::temp_allocator_arg_t'
with
[
TempAllocator=std::ostream,
T=jsoncons::cbor::cbor_encode_options
]
and
[
T=request_data_t
]
...\vendor\jsoncons_ext/cbor/encode_cbor.hpp(75,21): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
...\vendor\jsoncons_ext/cbor/encode_cbor.hpp(134,5): message : see declaration of 'jsoncons::cbor::encode_cbor'
...\http-server\http-context.h(240): message : see reference to function template instantiation 'void jsoncons::cbor::encode_cbor<T>(const T &,std::ostream &,const jsoncons::cbor::cbor_encode_options &)' being compiled
with
[
T=request_data_t
]
...\http-services\service\service-v1.cpp(98): message : see reference to function template instantiation 'void http_context_t::set_outgoing_packet_json<request_data_t>(const T &)' being compiled
with
[
T=request_data_t
]
Looks like some overload is missing, so that code which works for json, bson, msgpack and ubjson does not work for cbor.
Unfortunately, I am not familiar with source code of this project to give you more hints.