feat(c++): support unsigned type for cpp #3022
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why?
C++ natively supports unsigned integer types (
uint8_t,uint16_t,uint32_t,uint64_t) which are widely used in systems programming. This PR adds serialization support for these types in native mode (xlang=false), following the same pattern as the Rust implementation.What does this PR do?
Adds unsigned TypeIds to
cpp/fory/type/type.h:U8 = 64,U16 = 65,U32 = 66,U64 = 67for basic unsigned typesU16_ARRAY = 73,U32_ARRAY = 74,U64_ARRAY = 75for unsigned arraysImplements unsigned type serializers in
cpp/fory/serialization/unsigned_serializer.h:uint8_t,uint16_t,uint32_t,uint64_tstd::array<uintN_t, N>std::vector<uintN_t>Updates struct serializer to recognize unsigned types as primitive types, enabling efficient serialization of structs with unsigned fields.
Adds comprehensive tests covering:
Note: Unsigned types are only supported in native mode (
xlang=false). This follows the xlang specification which does not include unsigned types for cross-language compatibility.Related issues
#2906
Does this PR introduce any user-facing change?
Yes - users can now serialize/deserialize unsigned integer types in C++ when using native mode.
Benchmark
N/A - This is a new feature addition, not a performance optimization.