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

Remove scary pointer arithmetic and linear search in the built-in descriptor #44

Closed
Anton3 opened this issue Apr 17, 2023 · 1 comment
Closed

Comments

@Anton3
Copy link

Anton3 commented Apr 17, 2023

Currently every any has a built-in descriptor support. To support it for upcasted any instances, there is a scary piece of code:

  auto* p = reinterpret_cast<const value_type*>(vtable_ptr);
  do {
    --p;
  } while (*p);
  auto* type_desc_ptr = reinterpret_cast<const std::byte*>(p) - offsetof(vtable_with_metainfo<>, terminator);
  return *reinterpret_cast<const descriptor_t*>(type_desc_ptr);

It goes back, searching for a nullptr entry in the beginning, then assumes that next goes the descriptor. We at userver think that such code is unnecessarily scary.

Descriptors can be implemented as a regular requirement, as e.g. Boost.TypeErasure does. Then no special logic will be needed to retrieve the corresponding vtable slot.

@kelbon
Copy link
Owner

kelbon commented May 8, 2023

removed, now RTTI is optional and enabled by aa::type_info Method

@kelbon kelbon closed this as completed May 8, 2023
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

No branches or pull requests

2 participants