NFC: Introduce pointer domestication backend support

`capptr_domesticate<Backend>(Backend::LocalState*, CapPtr<T, B>)` is the
intended affordance for conversion to covert from a `CapPtr<T, B>` with
`B::wildness` `Wild` to a `CapPtr<>` with `B::with_wildness<Tame>` and thence
plumbed into the rest of the machinery.

David added the SFINAE wrapper so that `Backend`-s now don't need to implement a
domestication callback; instead, if the `Backend` does not provide a
`capptr_domesticate` function, a default, which just does an explicit type cast,
will be used instead.

This is not yet hooked into the rest of the tree.

Co-authored-by: David Chisnall <David.Chisnall@microsoft.com>
This commit is contained in:
Nathaniel Wesley Filardo
2021-08-16 21:03:29 +01:00
committed by Nathaniel Wesley Filardo
parent 7e53a2e82a
commit 1a608e6066
6 changed files with 133 additions and 1 deletions

View File

@@ -205,6 +205,15 @@ namespace snmalloc
body_opt = new_body;
}
template<bool has_bounds_ = has_bounds>
std::enable_if_t<has_bounds_, std::pair<address_t, size_t>> get_bounds()
{
static_assert(
has_bounds_ == has_bounds, "Don't set SFINAE template parameter!");
return {base, size};
}
/**
* Get the number of entries.
*/