Files
MapLibreParticleLab/include/mbgl/util/suppress_copies.hpp
Tim Sylvester 705bdfb3de add noexcepts (#2119)
Co-authored-by: Bart Louwers <bart@emeel.net>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
2024-04-08 15:39:18 +00:00

27 lines
682 B
C++

#pragma once
namespace mbgl {
namespace util {
/// Wrapper that doesn't participate in copying.
/// This allows a default-copyable object to have members that aren't copied
template <typename T>
struct SuppressCopies {
SuppressCopies() = default;
SuppressCopies(SuppressCopies const&) noexcept {}
SuppressCopies(SuppressCopies&& other)
: value(std::forward<T>(other.value)) noexcept {}
SuppressCopies& operator=(SuppressCopies o) noexcept {
std::swap(value, o.value);
return *this;
}
operator T&() noexcept { return value; }
T& get() noexcept { return value; }
private:
T value;
};
} // namespace util
} // namespace mbgl