diff --git a/src/util/Manual.hxx b/src/util/Manual.hxx index 78006ff74..f3d424e11 100644 --- a/src/util/Manual.hxx +++ b/src/util/Manual.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2017 Max Kellermann + * Copyright 2013-2022 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,8 +27,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MANUAL_HXX -#define MANUAL_HXX +#pragma once #include #include @@ -56,7 +55,7 @@ class Manual { public: #ifndef NDEBUG - ~Manual() { + ~Manual() noexcept { assert(!initialized); } #endif @@ -64,7 +63,7 @@ public: /** * Cast a value reference to the containing Manual instance. */ - static constexpr Manual &Cast(T &value) { + static constexpr Manual &Cast(T &value) noexcept { return reinterpret_cast &>(value); } @@ -80,7 +79,7 @@ public: #endif } - void Destruct() { + void Destruct() noexcept { assert(initialized); T &t = Get(); @@ -91,33 +90,33 @@ public: #endif } - T &Get() { + T &Get() noexcept { assert(initialized); void *p = static_cast(data); return *static_cast(p); } - const T &Get() const { + const T &Get() const noexcept { assert(initialized); const void *p = static_cast(data); return *static_cast(p); } - operator T &() { + operator T &() noexcept { return Get(); } - operator const T &() const { + operator const T &() const noexcept { return Get(); } - T *operator->() { + T *operator->() noexcept { return &Get(); } - const T *operator->() const { + const T *operator->() const noexcept { return &Get(); } }; @@ -125,5 +124,3 @@ public: #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif - -#endif