Commit fb5a7b0
Add visitAllocationClasses to TypeToMaskAdapter when using F14 Maps
Summary:
When using a `Mask` field in a Thrift struct that uses the plugin: thrift_plugin_allocated, it fails to compile.
This is because we need to define the traits somewhere as:
```
template <typename T>
struct allocated_size_traits<
apache::thrift::protocol::detail::ValidatingTypeMap<T>> {
static std::size_t allocated_bytes(
const apache::thrift::protocol::detail::ValidatingTypeMap<T>& container,
unsigned flags = 0U) {
auto result =
bytesAllocatedByRange(container.begin(), container.end(), flags);
container.visitAllocationClasses(
[&result](size_t const size, size_t const count) {
result += count * bytesAllocatedForSize(size);
});
return result;
}
};
```
TypeToMaskAdapter is a wrapper around F14Map (or std::map) [with private internal `map_` field] and other methods just forward to map_. So, e can define the above trait as similarly done for F14Map, but we need to add a public method `visitAllocationClasses` similar to F14Map.
Reviewed By: iahs
Differential Revision: D95068786
fbshipit-source-id: 0e4adde79d633c88ae11338c10928378af8554311 parent 2fb78d7 commit fb5a7b0
1 file changed
Lines changed: 4 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
0 commit comments