You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an issue with the DeserializeFromBuffer function templates in the serialization header. When attempting to deserialize a user-defined templated type, the compiler selects the incorrect overload. Specifically, it picks the container overload intended for standard containers (like std::vector, std::array, etc.) instead of the generic overload.
Code Details:
We have the following overloads of DeserializeFromBuffer:
the compiler incorrectly selects the container overload instead of the generic one. This happens because MyCustomType matches the template pattern Container<T, TArgs...> due to its variadic template parameters, even though it is not a container (and not iterable).
Proposed Solutions:
To resolve this issue, I suggest constraining the container overload so that it only matches actual container types.
We could implement a type trait to detect acceptable containers (iterables?) and use std::enable_if to constrain the container overload.
Or, we could use has_TypeDefinition to enforce usage of the generic overload when a TypeDefinition is available.
Thank you for your attention to this matter!
In addition to the overload resolution problem, I've noticed that the example provided for TypeDefinition in the README or documentation corresponds to an older implementation. The current code uses a function template for TypeDefinition, but the example still shows a struct specialization.
The text was updated successfully, but these errors were encountered:
Description:
I am encountering an issue with the
DeserializeFromBuffer
function templates in the serialization header. When attempting to deserialize a user-defined templated type, the compiler selects the incorrect overload. Specifically, it picks the container overload intended for standard containers (likestd::vector
,std::array
, etc.) instead of the generic overload.Code Details:
We have the following overloads of
DeserializeFromBuffer
:Generic Overload:
Container Overload:
Problem:
When deserializing a user-defined templated type, such as:
the compiler incorrectly selects the container overload instead of the generic one. This happens because
MyCustomType
matches the template patternContainer<T, TArgs...>
due to its variadic template parameters, even though it is not a container (and not iterable).Proposed Solutions:
To resolve this issue, I suggest constraining the container overload so that it only matches actual container types.
We could implement a type trait to detect acceptable containers (iterables?) and use
std::enable_if
to constrain the container overload.Or, we could use has_TypeDefinition to enforce usage of the generic overload when a TypeDefinition is available.
Thank you for your attention to this matter!
In addition to the overload resolution problem, I've noticed that the example provided for TypeDefinition in the README or documentation corresponds to an older implementation. The current code uses a function template for TypeDefinition, but the example still shows a struct specialization.
The text was updated successfully, but these errors were encountered: