bytecode_ptr updates

This commit is contained in:
Justin Viiret 2017-04-04 10:51:09 +10:00 committed by Matthew Barr
parent d9bac2bdb3
commit 5653fa55a1

View File

@ -28,7 +28,8 @@
/** /**
* \file * \file
* \brief bytecode_ptr: Smart pointer that knows its length and alignment. * \brief bytecode_ptr: Smart pointer with unique ownership that knows its
* length and alignment.
*/ */
#ifndef UTIL_BYTECODE_PTR_H #ifndef UTIL_BYTECODE_PTR_H
@ -44,12 +45,14 @@
namespace ue2 { namespace ue2 {
/** /**
* \brief Smart pointer that knows its length and alignment. * \brief Smart pointer that knows its length and alignment and behaves like a
* std::unique_ptr -- i.e. it retains unique ownership of the memory region.
* *
* This is intended to be used for flat aligned memory regions that will * This is intended to be used for flat aligned memory regions that will
* eventually end up copied into the Hyperscan bytecode. * eventually end up copied into the Hyperscan bytecode.
*/ */
template<typename T> class bytecode_ptr : totally_ordered<bytecode_ptr<T>> { template<typename T>
class bytecode_ptr : totally_ordered<bytecode_ptr<T>> {
public: public:
bytecode_ptr() = default; bytecode_ptr() = default;
explicit bytecode_ptr(size_t size, size_t align = alignof(T)) explicit bytecode_ptr(size_t size, size_t align = alignof(T))
@ -65,7 +68,7 @@ public:
bytecode_ptr(std::nullptr_t) {} bytecode_ptr(std::nullptr_t) {}
T *get() const { return ptr.get(); }; T *get() const { return ptr.get(); }
T &operator*() { return *ptr; } T &operator*() { return *ptr; }
const T &operator*() const { return *ptr; } const T &operator*() const { return *ptr; }