object: add destroy method for owned types

This commit is contained in:
Danny Robson 2017-09-07 15:52:36 +10:00
parent 8d26b2ac92
commit 140a94759f

View File

@ -38,7 +38,7 @@ namespace cruft::vk {
const id_t& id (void) const&;
id_t& id (void) &;
private:
protected:
id_t m_id;
};
@ -117,13 +117,31 @@ namespace cruft::vk {
template <typename SelfT, typename OwnerT>
struct owned : public object<SelfT> {
using id_t = typename object<SelfT>::id_t;
using owner_t = OwnerT;
using object<SelfT>::object;
template <typename ...Args>
owned (Args &&...args):
object<SelfT> (make (std::forward<Args> (args)...))
{ ; }
~owned ()
{
CHECK_EQ (this->id (), VK_NULL_HANDLE);
}
void
destroy (OwnerT &parent)
{
life_traits<SelfT>::destroy (parent.id (), this->id (), nullptr);
this->m_id = VK_NULL_HANDLE;
}
private:
template <typename ...Args>
static