alloc/arena: add move operations for owning arenas

This commit is contained in:
Danny Robson 2018-10-04 15:36:48 +10:00
parent c383f6579f
commit 1fc7e562c7

View File

@ -94,11 +94,24 @@ namespace cruft::alloc {
class owned { class owned {
public: public:
template <typename ...ArgsT> template <typename ...ArgsT>
owned (ArgsT &&...args): explicit owned (ArgsT &&...args)
m_store (std::forward<ArgsT> (args)...), : m_store (std::forward<ArgsT> (args)...)
m_arena {m_store} , m_arena {m_store}
{ ; } { ; }
owned (owned &&rhs)
: m_store (std::move (rhs.m_store))
, m_arena (m_store)
{ ; }
owned& operator= (owned &&rhs)
{
m_store = std::move (rhs.m_store);
}
owned (owned const&) = delete;
owned& operator= (owned const&) = delete;
template <typename T, typename ...ArgsT> template <typename T, typename ...ArgsT>
decltype(auto) acquire (ArgsT &&...args) decltype(auto) acquire (ArgsT &&...args)
{ return m_arena.template acquire<T,ArgsT...> (std::forward<ArgsT> (args)...); } { return m_arena.template acquire<T,ArgsT...> (std::forward<ArgsT> (args)...); }
@ -119,6 +132,6 @@ namespace cruft::alloc {
AllocT m_store; AllocT m_store;
arena<AllocT> m_arena; arena<AllocT> m_arena;
}; };
}; }
#endif #endif