diff --git a/filament/include/filament/FilamentAPI.h b/filament/include/filament/FilamentAPI.h index d34de84981..21ee83e540 100644 --- a/filament/include/filament/FilamentAPI.h +++ b/filament/include/filament/FilamentAPI.h @@ -65,7 +65,7 @@ public: // none of these methods must be implemented inline because it's important that their // implementation be hidden from the public headers. template - BuilderBase(ARGS&& ...) noexcept; + explicit BuilderBase(ARGS&& ...) noexcept; BuilderBase() noexcept; ~BuilderBase() noexcept; BuilderBase(BuilderBase const& rhs) noexcept; diff --git a/filament/include/filament/LightManager.h b/filament/include/filament/LightManager.h index 473acc26a3..dd5e895bda 100644 --- a/filament/include/filament/LightManager.h +++ b/filament/include/filament/LightManager.h @@ -223,7 +223,7 @@ public: * * @param type #Type of Light object to create. */ - Builder(Type type) noexcept; + explicit Builder(Type type) noexcept; Builder(Builder const& rhs) noexcept; Builder(Builder&& rhs) noexcept; ~Builder() noexcept; diff --git a/filament/include/filament/RenderableManager.h b/filament/include/filament/RenderableManager.h index 3dfc6e27e1..d08fcb907f 100644 --- a/filament/include/filament/RenderableManager.h +++ b/filament/include/filament/RenderableManager.h @@ -194,13 +194,13 @@ public: }; template -Box RenderableManager::computeAABB(VECTOR const* positions, INDEX const* indices, size_t count, +Box RenderableManager::computeAABB(VECTOR const* vertices, INDEX const* indices, size_t count, size_t stride) noexcept { math::float3 bmin(std::numeric_limits::max()); math::float3 bmax(std::numeric_limits::lowest()); for (size_t i = 0; i < count; ++i) { VECTOR const* p = reinterpret_cast( - (char const*)positions + indices[i] * stride); + (char const*)vertices + indices[i] * stride); const math::float3 v(p->x, p->y, p->z); bmin = min(bmin, v); bmax = max(bmax, v); diff --git a/filament/include/filament/View.h b/filament/include/filament/View.h index 193728100c..8da8314b33 100644 --- a/filament/include/filament/View.h +++ b/filament/include/filament/View.h @@ -103,7 +103,7 @@ public: // this one exists for backward compatibility } - DynamicResolutionOptions(bool enabled) : enabled(enabled) { } + explicit DynamicResolutionOptions(bool enabled) : enabled(enabled) { } math::float2 minScale = math::float2(0.5f); //!< minimum scale factors in x and y math::float2 maxScale = math::float2(1.0f); //!< maximum scale factors in x and y diff --git a/filament/src/Engine.cpp b/filament/src/Engine.cpp index a0a58fcf34..878890a0c2 100644 --- a/filament/src/Engine.cpp +++ b/filament/src/Engine.cpp @@ -110,7 +110,7 @@ UniformInterfaceBlock FEngine::PostProcessingUib::getUib() noexcept { } SamplerInterfaceBlock FEngine::PerViewSib::getSib() noexcept { - return SibGenerator::getPerViewSib(); + return SibGenerator::getPerViewSib(); } SamplerInterfaceBlock FEngine::PostProcessSib::getSib() noexcept { @@ -237,7 +237,7 @@ void FEngine::shutdown() { size_t wm = mCommandBufferQueue.getHigWatermark(); size_t wmpct = wm / (CONFIG_COMMAND_BUFFERS_SIZE / 100); slog.d << "CircularBuffer: High watermark " - << wm / 1024 << " KiB (" << wmpct << "%)" << io::endl; + << wm / 1024 << " KiB (" << wmpct << "%)" << io::endl; #endif DriverApi& driver = getDriverApi(); @@ -348,7 +348,7 @@ int FEngine::loop() { mExternalContext = ExternalContext::create(&mBackend); #if !defined(NDEBUG) slog.d << "FEngine resolved backend: " - << (mBackend == driver::Backend::VULKAN ? "Vulkan" : "OpenGL") << io::endl; + << (mBackend == driver::Backend::VULKAN ? "Vulkan" : "OpenGL") << io::endl; #endif } mDriver = mExternalContext->createDriver(mSharedGLContext); @@ -578,7 +578,7 @@ void FEngine::cleanupResourceList(ResourceList& list) { if (!list.empty()) { #ifndef NDEBUG slog.d << "cleaning up " << list.size() - << " leaked " << CallStack::typeName().c_str() << io::endl; + << " leaked " << CallStack::typeName().c_str() << io::endl; #endif // Move the list (copy-and-clear). We can only modify/access the list from this // thread, because it's not thread-safe. @@ -602,9 +602,9 @@ void FEngine::terminateAndDestroy(const T* ptr, ResourceList& list) { // object not found, do nothing and log an error on DEBUG builds. #ifndef NDEBUG slog.d << "object " - << CallStack::typeName().c_str() - << " at " << ptr << " doesn't exist!" - << io::endl; + << CallStack::typeName().c_str() + << " at " << ptr << " doesn't exist!" + << io::endl; #endif } } diff --git a/filament/src/RenderPass.cpp b/filament/src/RenderPass.cpp index 8cb11292d0..a89f610b30 100644 --- a/filament/src/RenderPass.cpp +++ b/filament/src/RenderPass.cpp @@ -114,7 +114,7 @@ void RenderPass::recordDriverCommands( Slice const& commands) noexcept { SYSTRACE_CALL(); - if (commands.size()) { + if (!commands.empty()) { FMaterialInstance const* UTILS_RESTRICT previousMi = nullptr; FMaterial const* UTILS_RESTRICT ma = nullptr; Command const* UTILS_RESTRICT c; diff --git a/filament/src/RenderTargetPool.cpp b/filament/src/RenderTargetPool.cpp index 62f0f3417b..b71f09f3e1 100644 --- a/filament/src/RenderTargetPool.cpp +++ b/filament/src/RenderTargetPool.cpp @@ -53,7 +53,7 @@ RenderTargetPool::Target const* RenderTargetPool::get( FEngine& engine = *mEngine; DriverApi& driver = engine.getDriverApi(); - + // Since we order the cache by width then by height, we can get a cached // entry with a smaller height. Only reuse if both dimensions are higher. auto pos = find(&entry); diff --git a/filament/src/Renderer.cpp b/filament/src/Renderer.cpp index 8cf1adeb11..6aecada28a 100644 --- a/filament/src/Renderer.cpp +++ b/filament/src/Renderer.cpp @@ -47,6 +47,8 @@ FRenderer::FRenderer(FEngine& engine) : mEngine(engine), mFrameSkipper(engine, 2), mFrameInfoManager(engine), + mIsRGB16FSupported(false), + mIsRGB8Supported(false), mPerRenderPassArena(engine.getPerRenderPassAllocator()) { } diff --git a/filament/src/ShadowMap.cpp b/filament/src/ShadowMap.cpp index 98bf3500a2..59ecec245f 100644 --- a/filament/src/ShadowMap.cpp +++ b/filament/src/ShadowMap.cpp @@ -716,8 +716,7 @@ size_t ShadowMap::intersectFrustums( float3 const* quadsVertices) noexcept { #pragma nounroll - for (size_t i = 0; i < 12; ++i) { - const Segment segment = sBoxSegments[i]; + for (const Segment segment : sBoxSegments) { const float3 s0 = segmentsVertices[segment.v0]; const float3 s1 = segmentsVertices[segment.v1]; // each segment should only intersect with 2 quads at most diff --git a/filament/src/components/CameraManager.h b/filament/src/components/CameraManager.h index dfd31b8801..e7215dc0b7 100644 --- a/filament/src/components/CameraManager.h +++ b/filament/src/components/CameraManager.h @@ -41,7 +41,7 @@ class UTILS_PRIVATE FCameraManager : public CameraManager { public: using Instance = CameraManager::Instance; - FCameraManager(FEngine& engine) noexcept; + explicit FCameraManager(FEngine& engine) noexcept; ~FCameraManager() noexcept; diff --git a/filament/src/components/LightManager.h b/filament/src/components/LightManager.h index 59975bf8a8..b8202b7737 100644 --- a/filament/src/components/LightManager.h +++ b/filament/src/components/LightManager.h @@ -38,7 +38,7 @@ class FLightManager : public LightManager { public: using Instance = LightManager::Instance; - FLightManager(FEngine& engine) noexcept; + explicit FLightManager(FEngine& engine) noexcept; ~FLightManager(); void init(FEngine& engine) noexcept; diff --git a/filament/src/details/Renderer.h b/filament/src/details/Renderer.h index b588dc62e0..a25b71ba3c 100644 --- a/filament/src/details/Renderer.h +++ b/filament/src/details/Renderer.h @@ -52,7 +52,7 @@ class ShadowMap; */ class FRenderer : public Renderer { public: - FRenderer(FEngine& engine); + explicit FRenderer(FEngine& engine); ~FRenderer() noexcept; void init() noexcept; @@ -82,13 +82,13 @@ private: utils::JobSystem::Job* jobFroxelize = nullptr; FView* const view; Handle const rth; - virtual void beginRenderPass(driver::DriverApi& driver, Viewport const& viewport, const CameraInfo& camera) noexcept override; - virtual void endRenderPass(DriverApi& driver, Viewport const& viewport) noexcept override; + void beginRenderPass(driver::DriverApi& driver, Viewport const& viewport, const CameraInfo& camera) noexcept override; + void endRenderPass(DriverApi& driver, Viewport const& viewport) noexcept override; public: ColorPass(const char* name, utils::JobSystem& js, utils::JobSystem::Job* jobFroxelize, - FView* view, Handle const rth); + FView* view, Handle rth); static void renderColorPass(FEngine& engine, utils::JobSystem& js, - Handle const rth, + Handle rth, FView* view, Viewport const& scaledViewport, utils::GrowingSlice& commands) noexcept; }; @@ -97,8 +97,8 @@ private: class ShadowPass final : public RenderPass { using DriverApi = driver::DriverApi; ShadowMap const& shadowMap; - virtual void beginRenderPass(driver::DriverApi& driver, Viewport const& viewport, const CameraInfo& camera) noexcept override; - virtual void endRenderPass(DriverApi& driver, Viewport const& viewport) noexcept override; + void beginRenderPass(driver::DriverApi& driver, Viewport const& viewport, const CameraInfo& camera) noexcept override; + void endRenderPass(DriverApi& driver, Viewport const& viewport) noexcept override; public: ShadowPass(const char* name, ShadowMap const& shadowMap) noexcept; static void renderShadowMap(FEngine& engine, utils::JobSystem& js, diff --git a/filament/src/driver/CircularBuffer.h b/filament/src/driver/CircularBuffer.h index 9c77187daf..d140273b7e 100644 --- a/filament/src/driver/CircularBuffer.h +++ b/filament/src/driver/CircularBuffer.h @@ -35,7 +35,7 @@ public: // This must be at least 2*requiredSize to avoid blocking on flush, however // because sometimes the display can get ahead of the render() thread, it's good // to set it to 3*requiredSize to avoid blocking the render thread (usually the UI thread). - CircularBuffer(size_t bufferSize); + explicit CircularBuffer(size_t bufferSize); // can't be moved or copy-constructed CircularBuffer(CircularBuffer const& rhs) = delete; diff --git a/filament/src/driver/CommandBufferQueue.cpp b/filament/src/driver/CommandBufferQueue.cpp index 2be19e34a9..d3d92b46e6 100644 --- a/filament/src/driver/CommandBufferQueue.cpp +++ b/filament/src/driver/CommandBufferQueue.cpp @@ -103,7 +103,7 @@ void CommandBufferQueue::flush() noexcept { std::vector CommandBufferQueue::waitForCommands() const { std::unique_lock lock(mLock); - while (!mCommandBuffersToExecute.size() && !mExitRequested) { + while (mCommandBuffersToExecute.empty() && !mExitRequested) { mCondition.wait(lock); } return std::move(mCommandBuffersToExecute); diff --git a/filament/src/driver/Driver.h b/filament/src/driver/Driver.h index 302d0959be..b7614ab74b 100644 --- a/filament/src/driver/Driver.h +++ b/filament/src/driver/Driver.h @@ -50,9 +50,6 @@ class Dispatcher; class Driver { public: - static std::unique_ptr - create(driver::ExternalContext* externalContext, void* sharedGLContext) noexcept; - // constants static constexpr size_t MAX_ATTRIBUTE_BUFFER_COUNT = 8; @@ -211,7 +208,7 @@ public: static size_t getElementTypeSize(ElementType type) noexcept; // This is here to be compatible with CommandStream (nice for debugging) - inline void queueCommand(std::function command) { + inline void queueCommand(const std::function& command) { command(); } diff --git a/filament/src/driver/DriverBase.h b/filament/src/driver/DriverBase.h index c9c8acc562..0f61f17241 100644 --- a/filament/src/driver/DriverBase.h +++ b/filament/src/driver/DriverBase.h @@ -88,19 +88,19 @@ struct HwProgram : public HwBase { #if defined(NDEBUG) HwProgram(const utils::CString& name) noexcept { } #else - HwProgram(const utils::CString& name) noexcept : name(name) { } + explicit HwProgram(const utils::CString& name) noexcept : name(name) { } utils::CString name; #endif }; struct HwSamplerBuffer : public HwBase { - HwSamplerBuffer(size_t size) noexcept : sb(new SamplerBuffer(size)) { } + explicit HwSamplerBuffer(size_t size) noexcept : sb(new SamplerBuffer(size)) { } // NOTE: we have to use out-of-line allocation here because the size of a Handle<> is limited std::unique_ptr sb; }; struct HwUniformBuffer : public HwBase { - HwUniformBuffer(size_t size) noexcept : ub(size) { } + explicit HwUniformBuffer(size_t size) noexcept : ub(size) { } UniformBuffer ub; }; @@ -135,7 +135,7 @@ struct HwSwapChain : public HwBase { struct HwStream : public HwBase { HwStream() = default; - HwStream(driver::ExternalContext::Stream* stream) : stream(stream) { } + explicit HwStream(driver::ExternalContext::Stream* stream) : stream(stream) { } driver::ExternalContext::Stream* stream = nullptr; uint32_t width = 0; uint32_t height = 0; @@ -149,14 +149,14 @@ class DriverBase : public Driver { public: DriverBase() = delete; explicit DriverBase(Dispatcher* dispatcher) noexcept; - ~DriverBase() noexcept; + ~DriverBase() noexcept override; static SamplerFormat getSamplerFormat(TextureFormat format) noexcept; static SamplerPrecision getSamplerPrecision(TextureFormat format) noexcept; - void purge() noexcept override final; + void purge() noexcept final; - Dispatcher& getDispatcher() noexcept override final { return *mDispatcher; } + Dispatcher& getDispatcher() noexcept final { return *mDispatcher; } // -------------------------------------------------------------------------------------------- // Privates diff --git a/filament/src/driver/Handle.h b/filament/src/driver/Handle.h index 107a475376..1904d0fb18 100644 --- a/filament/src/driver/Handle.h +++ b/filament/src/driver/Handle.h @@ -55,7 +55,7 @@ public: HandleBase() noexcept : object(nullid) { } - explicit HandleBase(no_init) noexcept { } + explicit HandleBase(no_init) noexcept { } // NOLINT explicit HandleBase(HandleId id) noexcept : object(id) { assert(object != nullid); // usually means an uninitialized handle is used @@ -66,7 +66,7 @@ public: #ifndef NDEBUG // implement move ctor and copy operator for safety - HandleBase(HandleBase&& rhs) noexcept { + HandleBase(HandleBase&& rhs) noexcept : object(nullid) { std::swap(object, rhs.object); } HandleBase& operator = (HandleBase&& rhs) noexcept { @@ -77,14 +77,16 @@ public: void clear() noexcept { object = nullid; } - operator bool() const noexcept { return object != nullid; } + explicit operator bool() const noexcept { return object != nullid; } + + bool operator==(const HandleBase& rhs) noexcept { return object == rhs.object; } + bool operator!=(const HandleBase& rhs) noexcept { return object != rhs.object; } // get this handle's handleId HandleId getId() const noexcept { return object; } protected: HandleId object; - }; template diff --git a/filament/src/driver/opengl/OpenGLDriver.cpp b/filament/src/driver/opengl/OpenGLDriver.cpp index cb1d53c7eb..247d8583c4 100644 --- a/filament/src/driver/opengl/OpenGLDriver.cpp +++ b/filament/src/driver/opengl/OpenGLDriver.cpp @@ -1313,8 +1313,8 @@ void OpenGLDriver::destroyStream(Driver::StreamHandle sh) { if (s->gl.fbo) { glDeleteFramebuffers(1, &s->gl.fbo); } - for (size_t i = 0; i < GLStream::ROUND_ROBIN_TEXTURE_COUNT; i++) { - mContextManager.destroyExternalTextureStorage(s->user_thread.infos[i].ets); + for (auto const& info : s->user_thread.infos) { + mContextManager.destroyExternalTextureStorage(info.ets); } } destruct(sh, s); diff --git a/libs/utils/include/utils/Allocator.h b/libs/utils/include/utils/Allocator.h index 2ff6923f14..1c28ab4b8b 100644 --- a/libs/utils/include/utils/Allocator.h +++ b/libs/utils/include/utils/Allocator.h @@ -617,7 +617,7 @@ public: struct rebind { using other = STLAllocator; }; public: - STLAllocator(ARENA& arena) : mArena(arena) { } + explicit STLAllocator(ARENA& arena) : mArena(arena) { } TYPE* allocate(std::size_t n) { return static_cast(mArena.alloc(n * sizeof(n), alignof(TYPE))); diff --git a/libs/utils/include/utils/CString.h b/libs/utils/include/utils/CString.h index 24f016c6f7..568a99812a 100644 --- a/libs/utils/include/utils/CString.h +++ b/libs/utils/include/utils/CString.h @@ -81,7 +81,7 @@ public: using StringLiteral = const char[N]; template - StaticString(StringLiteral const& other) noexcept + StaticString(StringLiteral const& other) noexcept // NOLINT(google-explicit-constructor) : mString(other), mLength(size_type(N - 1)) { } @@ -91,14 +91,13 @@ public: mLength(size_type(length)) { } - template StaticString& operator=(StringLiteral const& other) noexcept { mString = other; mLength = size_type(N - 1); + return *this; } - const_pointer c_str() const noexcept { return mString; } const_pointer data() const noexcept { return mString; } size_type size() const noexcept { return mLength; } diff --git a/libs/utils/include/utils/CountDownLatch.h b/libs/utils/include/utils/CountDownLatch.h index 9e65d918db..fc01f0438a 100644 --- a/libs/utils/include/utils/CountDownLatch.h +++ b/libs/utils/include/utils/CountDownLatch.h @@ -75,11 +75,11 @@ public: */ size_t getCount() const noexcept; -private: CountDownLatch() = delete; CountDownLatch(const CountDownLatch&) = delete; - CountDownLatch& operator =(const CountDownLatch&) = delete; + CountDownLatch& operator=(const CountDownLatch&) = delete; +private: uint32_t m_initial_count; uint32_t m_remaining_count; mutable Mutex m_lock; diff --git a/libs/utils/include/utils/CyclicBarrier.h b/libs/utils/include/utils/CyclicBarrier.h index 69b87d9890..6f90cfd8b9 100644 --- a/libs/utils/include/utils/CyclicBarrier.h +++ b/libs/utils/include/utils/CyclicBarrier.h @@ -61,11 +61,11 @@ public: */ void reset() noexcept; -private: CyclicBarrier() = delete; CyclicBarrier(const CyclicBarrier&) = delete; - CyclicBarrier& operator =(const CyclicBarrier&) = delete; + CyclicBarrier& operator=(const CyclicBarrier&) = delete; +private: enum class State { TRAP, RELEASE }; diff --git a/libs/utils/include/utils/Entity.h b/libs/utils/include/utils/Entity.h index 872821669e..a5e61b5248 100644 --- a/libs/utils/include/utils/Entity.h +++ b/libs/utils/include/utils/Entity.h @@ -49,7 +49,7 @@ public: return mIdentity; } - operator bool() const noexcept { return !isNull(); } + explicit operator bool() const noexcept { return !isNull(); } private: friend class EntityManager; @@ -57,7 +57,7 @@ private: friend struct std::hash; using Type = uint32_t; - Entity(Type identity) noexcept : mIdentity(identity) { } + explicit Entity(Type identity) noexcept : mIdentity(identity) { } Type mIdentity = 0; }; diff --git a/libs/utils/include/utils/EntityInstance.h b/libs/utils/include/utils/EntityInstance.h index ba4d55551b..a2bc1761e0 100644 --- a/libs/utils/include/utils/EntityInstance.h +++ b/libs/utils/include/utils/EntityInstance.h @@ -45,12 +45,13 @@ public: // EDIT instances can be converted to "read" Instances of same type template > - constexpr EntityInstance(EntityInstance const& other) noexcept { + constexpr explicit EntityInstance(EntityInstance const& other) noexcept { mInstance = other.asValue(); } template > EntityInstance& operator=(EntityInstance const& other) noexcept { mInstance = other.asValue(); + return *this; } // Instances can be compared @@ -65,19 +66,19 @@ public: // and we can iterate constexpr EntityInstance& operator++() noexcept { ++mInstance; return *this; } - constexpr EntityInstance operator++(int) const noexcept { return EntityInstance{ mInstance + 1 }; } constexpr EntityInstance& operator--() noexcept { --mInstance; return *this; } - constexpr EntityInstance operator--(int) const noexcept { return EntityInstance{ mInstance - 1 }; } + constexpr const EntityInstance operator++(int) const noexcept { return EntityInstance{ mInstance + 1 }; } + constexpr const EntityInstance operator--(int) const noexcept { return EntityInstance{ mInstance - 1 }; } // return a value for this Instance (mostly needed for debugging constexpr uint32_t asValue() const noexcept { return mInstance; } // auto convert to Type so it can be used as an index - constexpr operator Type() const noexcept { return mInstance; } + constexpr operator Type() const noexcept { return mInstance; } // NOLINT(google-explicit-constructor) // conversion from Type so we can initialize from an index - constexpr EntityInstance(Type value) noexcept { mInstance = value; } + constexpr EntityInstance(Type value) noexcept { mInstance = value; } // NOLINT(google-explicit-constructor) }; } // namespace utils diff --git a/libs/utils/include/utils/Hash.h b/libs/utils/include/utils/Hash.h index d69b4b9352..3e2b7b16fa 100644 --- a/libs/utils/include/utils/Hash.h +++ b/libs/utils/include/utils/Hash.h @@ -17,6 +17,9 @@ #ifndef TNT_UTILS_HASH_H #define TNT_UTILS_HASH_H +#include +#include + namespace utils { namespace hash { diff --git a/libs/utils/include/utils/JobSystem.h b/libs/utils/include/utils/JobSystem.h index ecc554e28e..793c31fd5f 100644 --- a/libs/utils/include/utils/JobSystem.h +++ b/libs/utils/include/utils/JobSystem.h @@ -75,7 +75,7 @@ public: (CACHELINE_SIZE % sizeof(Job) == 0), "A Job must be N cache-lines long or N Jobs must fit in a cache line exactly."); - JobSystem(size_t threadCount = 0, size_t adoptableThreadsCount = 1) noexcept; + explicit JobSystem(size_t threadCount = 0, size_t adoptableThreadsCount = 1) noexcept; ~JobSystem(); @@ -269,7 +269,7 @@ private: static constexpr uint32_t m = 0x7fffffffu; uint32_t mState; // must be 0 < seed < 0x7fffffff public: - inline constexpr default_random_engine(uint32_t seed = 1u) noexcept + inline constexpr explicit default_random_engine(uint32_t seed = 1u) noexcept : mState(((seed % m) == 0u) ? 1u : seed % m) { } inline uint32_t operator()() noexcept { diff --git a/libs/utils/include/utils/NameComponentManager.h b/libs/utils/include/utils/NameComponentManager.h index e83b201e45..7d56f7b5e2 100644 --- a/libs/utils/include/utils/NameComponentManager.h +++ b/libs/utils/include/utils/NameComponentManager.h @@ -33,7 +33,7 @@ namespace details { class SafeString { public: SafeString() noexcept = default; - SafeString(const char* str) noexcept : mCStr(strdup(str)) { } + explicit SafeString(const char* str) noexcept : mCStr(strdup(str)) { } SafeString(SafeString&& rhs) noexcept : mCStr(rhs.mCStr) { rhs.mCStr = nullptr; } SafeString& operator=(SafeString&& rhs) noexcept { mCStr = rhs.mCStr; @@ -53,7 +53,7 @@ class NameComponentManager : public SingleInstanceComponentManager; - NameComponentManager(EntityManager& em); + explicit NameComponentManager(EntityManager& em); ~NameComponentManager(); using SingleInstanceComponentManager::hasComponent; diff --git a/libs/utils/include/utils/Range.h b/libs/utils/include/utils/Range.h index 1e710a9599..ba922bd37a 100644 --- a/libs/utils/include/utils/Range.h +++ b/libs/utils/include/utils/Range.h @@ -54,8 +54,9 @@ struct Range { const_iterator& operator++() { ++value; return *this; } const_iterator& operator--() { --value; return *this; } - const_iterator operator++(int) { const_iterator t(value); value++; return t; } - const_iterator operator--(int) { const_iterator t(value); value--; return t; } + + const const_iterator operator++(int) { const_iterator t(value); value++; return t; } + const const_iterator operator--(int) { const_iterator t(value); value--; return t; } const_iterator operator+(size_t rhs) const { return { value + rhs }; } const_iterator operator+(size_t rhs) { return { value + rhs }; } diff --git a/libs/utils/include/utils/StructureOfArrays.h b/libs/utils/include/utils/StructureOfArrays.h index 23475d9293..61fa958476 100644 --- a/libs/utils/include/utils/StructureOfArrays.h +++ b/libs/utils/include/utils/StructureOfArrays.h @@ -203,8 +203,8 @@ public: bool operator< (Iterator const& rhs) const { return (index < rhs.index); } // Postfix operator needed by Microsoft STL. - Iterator operator++(int) { Iterator it(*this); index++; return it; } - Iterator operator--(int) { Iterator it(*this); index--; return it; } + const Iterator operator++(int) { Iterator it(*this); index++; return it; } + const Iterator operator--(int) { Iterator it(*this); index--; return it; } }; iterator begin() noexcept { return { this, 0u }; } @@ -622,7 +622,7 @@ StructureOfArraysBase::StructureRef::assign( // implements StructureRef& StructureRef::operator=(Structure const& rhs) auto UTILS_UNUSED l = { (soa->elementAt(index) = std::get(rhs.elements), 0)... }; return *this; -}; +} template template diff --git a/libs/utils/include/utils/Zip2Iterator.h b/libs/utils/include/utils/Zip2Iterator.h index d5c5ef4fb5..3f60cf161b 100644 --- a/libs/utils/include/utils/Zip2Iterator.h +++ b/libs/utils/include/utils/Zip2Iterator.h @@ -79,14 +79,14 @@ public: } // Postfix operator needed by Microsoft C++ - Zip2Iterator operator++(int) { + const Zip2Iterator operator++(int) { Zip2Iterator t(*this); mIt.first++; mIt.second++; return t; } - Zip2Iterator operator--(int) { + const Zip2Iterator operator--(int) { Zip2Iterator t(*this); mIt.first--; mIt.second--; diff --git a/libs/utils/include/utils/memalign.h b/libs/utils/include/utils/memalign.h index 05599ba6a4..ae0393686c 100644 --- a/libs/utils/include/utils/memalign.h +++ b/libs/utils/include/utils/memalign.h @@ -17,6 +17,9 @@ #ifndef TNT_UTILS_MEMALIGN_H #define TNT_UTILS_MEMALIGN_H +#include +#include + #include #include #include @@ -85,7 +88,7 @@ public: inline STLAlignedAllocator() noexcept = default; template - inline STLAlignedAllocator(const STLAlignedAllocator&) noexcept {} + inline explicit STLAlignedAllocator(const STLAlignedAllocator&) noexcept {} inline ~STLAlignedAllocator() noexcept = default; diff --git a/libs/utils/include/utils/unwindows.h b/libs/utils/include/utils/unwindows.h index b87111ac70..6bd6574d84 100644 --- a/libs/utils/include/utils/unwindows.h +++ b/libs/utils/include/utils/unwindows.h @@ -48,4 +48,4 @@ #undef PURE #endif -#endif \ No newline at end of file +#endif diff --git a/libs/utils/src/NameComponentManager.cpp b/libs/utils/src/NameComponentManager.cpp index 6a580b382b..b3fd2daedc 100644 --- a/libs/utils/src/NameComponentManager.cpp +++ b/libs/utils/src/NameComponentManager.cpp @@ -24,12 +24,11 @@ static constexpr size_t NAME = 0; NameComponentManager::NameComponentManager(EntityManager& em) { } -NameComponentManager::~NameComponentManager() { -} +NameComponentManager::~NameComponentManager() = default; void NameComponentManager::setName(Instance instance, const char* name) noexcept { if (instance) { - elementAt(instance) = { name }; + elementAt(instance) = details::SafeString{ name }; } }