diff --git a/src/util/util.h b/src/util/util.h index 3470f59c0..8d3682943 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -269,6 +269,11 @@ public: return *this; } + scoped_ptr& operator=(scoped_ptr&& other) { + *this = other.detach(); + return *this; + }; + T * detach() { T* tmp = m_ptr; m_ptr = nullptr; diff --git a/src/util/vector.h b/src/util/vector.h index 665569c03..1cb25a8c4 100644 --- a/src/util/vector.h +++ b/src/util/vector.h @@ -641,7 +641,7 @@ public: return m_data; } - void swap(vector & other) { + void swap(vector & other) noexcept { std::swap(m_data, other.m_data); } @@ -720,6 +720,17 @@ public: ptr_vector(unsigned s):vector(s) {} ptr_vector(unsigned s, T * elem):vector(s, elem) {} ptr_vector(unsigned s, T * const * data):vector(s, const_cast(data)) {} + std::ostream& display(std::ostream& out, char const* delim = " ") const { + char const* d = ""; + for (auto const* u : *this) { + if (u) + out << d << *u; + else + out << d << ""; + d = delim; + } + return out; + } }; template @@ -746,6 +757,11 @@ inline std::ostream& operator<<(std::ostream& out, svector const& v) { return out; } +template +inline std::ostream& operator<<(std::ostream& out, ptr_vector const& v) { + return v.display(out); +} + template struct vector_hash_tpl {