diff options
-rw-r--r-- | c/data.h | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -93,11 +93,29 @@ struct FileView memcpy(fv+i, &t, sizeof(T)); } - return { filename, c }; + return {filename, c}; } FileView(FileView<T>&) = delete; - FileView(FileView<T>&& fv) = delete; + FileView<T>& operator =(const FileView<unsigned char>&) = delete; + + FileView(FileView<T>&& other) + { + hf = other.hf; + hm = other.hf; + view = other.view; + c = other.c; + other.view = nullptr; + } + FileView<T>& operator =(FileView<unsigned char>&& other) + { + hf = other.hf; + hm = other.hf; + view = other.view; + c = other.c; + other.view = nullptr; + return *this; + } FileView(const wchar_t* filename, size_t c) : c(c) { @@ -131,10 +149,12 @@ struct FileView ~FileView() { - FlushViewOfFile(view, 0); - UnmapViewOfFile(view); - CloseHandle(hm); - CloseHandle(hf); + if (view) { + FlushViewOfFile(view, 0); + UnmapViewOfFile(view); + CloseHandle(hm); + CloseHandle(hf); + } } /* Access element by index, performing bounds check and, if |