Open ashn-dot-dev opened 12 months ago
A better workaround was used in https://github.com/ashn-dot-dev/bubby/commit/afc18d96430c4d74059844c00f9a453d83b496a4. The size of both std::hash_map
and std::hash_set
is fixed regardless of the template types used, so std::hash_map[[void, void]]
and std::hash_set[[void]]
can be used as placeholder types, with type punning being used to later extract the desired type from the hash map and hash set member variables.
std::hash_map
std::hash_set
Additional Notes
Attempting to box the templated type using a pointer also does not work:
In order to hold the data, a boxed
any
must be used to "smuggle" the heap allocated struct:The discovery of this issue, and an example of this smuggling in action, comes from an initial draft of a data interchange format library called bubby: https://github.com/ashn-dot-dev/bubby/blob/4f1f6f0f605b8ba7f6d18fa1c0945460576fabab/bubby.sunder#L22C1-L23C50