If you interact with legacy or highly portable APIs, you will often encounter various types of handles represented by trivial types.
In C++, we want to wrap these handles in an RAII wrapper to ensure we do not leak resources or access them after they are gone. However, this means a lot of boilerplate code.
Fortunately, this process can be simplified with a re-usable Mixin.
Compiler Explorer link: https://compiler-explorer.com/z/9YP7sKP1q
if your base type has no distinguished empty value to spare or is not default constructible, I tend to teach to use std::optional<T> to store a resource(handle) in a unique manager type. I'd prefer a named class type instead of a template with boilerplate, but ymmv. templates with many parameters can make debugging harder, since a nice alias tends to be lost in translation.
@PeterSommerlad I agree that I should have wrapped the arguments into an aggregate. Oh well...