Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[struct_pack][feat] add support for user_defined type id #453

Merged
merged 4 commits into from
Sep 14, 2023

Conversation

poor-circle
Copy link
Collaborator

@poor-circle poor-circle commented Sep 14, 2023

Why

Allow user add type id to distinct different c++ type with same struct_pack type by different hash.

What is changing

Now user can defined a public static member struct_pack_id, this ID will be recorded in struct_pack type string to change hash code. This help user distinct different c++ type with same struct_pack type. User can also use this to avoid hash collision.

Example

struct foo_with_ID {
  std::vector<int> a;
  std::list<foo_with_ID> b;
  constexpr static std::size_t struct_pack_id = 0;
};

struct foo {
  std::vector<int> a;
  std::list<foo> b;
};

static_assert(struct_pack::get_type_literal<foo_with_ID>()!=struct_pack::get_type_literal<foo>());

@poor-circle poor-circle merged commit 6b8b298 into alibaba:main Sep 14, 2023
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant