fix a bunch of clang-tidy warnings
fixed a couple actual real bugs (missing returns in operator=, wrong implicit bool conversion). mostly added a bunch of explicit ctor.
This commit is contained in:
committed by
Mathias Agopian
parent
9ac432d530
commit
a4851ed835
@@ -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<typename ... ARGS>
|
||||
BuilderBase(ARGS&& ...) noexcept;
|
||||
explicit BuilderBase(ARGS&& ...) noexcept;
|
||||
BuilderBase() noexcept;
|
||||
~BuilderBase() noexcept;
|
||||
BuilderBase(BuilderBase const& rhs) noexcept;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -194,13 +194,13 @@ public:
|
||||
};
|
||||
|
||||
template<typename VECTOR, typename INDEX, typename, typename>
|
||||
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<float>::max());
|
||||
math::float3 bmax(std::numeric_limits<float>::lowest());
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
VECTOR const* p = reinterpret_cast<VECTOR const*>(
|
||||
(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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<T, L>& list) {
|
||||
if (!list.empty()) {
|
||||
#ifndef NDEBUG
|
||||
slog.d << "cleaning up " << list.size()
|
||||
<< " leaked " << CallStack::typeName<T>().c_str() << io::endl;
|
||||
<< " leaked " << CallStack::typeName<T>().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<T, L>& list) {
|
||||
// object not found, do nothing and log an error on DEBUG builds.
|
||||
#ifndef NDEBUG
|
||||
slog.d << "object "
|
||||
<< CallStack::typeName<T>().c_str()
|
||||
<< " at " << ptr << " doesn't exist!"
|
||||
<< io::endl;
|
||||
<< CallStack::typeName<T>().c_str()
|
||||
<< " at " << ptr << " doesn't exist!"
|
||||
<< io::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ void RenderPass::recordDriverCommands(
|
||||
Slice<Command> 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -47,6 +47,8 @@ FRenderer::FRenderer(FEngine& engine) :
|
||||
mEngine(engine),
|
||||
mFrameSkipper(engine, 2),
|
||||
mFrameInfoManager(engine),
|
||||
mIsRGB16FSupported(false),
|
||||
mIsRGB8Supported(false),
|
||||
mPerRenderPassArena(engine.getPerRenderPassAllocator())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<HwRenderTarget> 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<HwRenderTarget> const rth);
|
||||
FView* view, Handle<HwRenderTarget> rth);
|
||||
static void renderColorPass(FEngine& engine, utils::JobSystem& js,
|
||||
Handle<HwRenderTarget> const rth,
|
||||
Handle<HwRenderTarget> rth,
|
||||
FView* view, Viewport const& scaledViewport,
|
||||
utils::GrowingSlice<Command>& 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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -103,7 +103,7 @@ void CommandBufferQueue::flush() noexcept {
|
||||
|
||||
std::vector<CommandBufferQueue::Slice> CommandBufferQueue::waitForCommands() const {
|
||||
std::unique_lock<utils::Mutex> lock(mLock);
|
||||
while (!mCommandBuffersToExecute.size() && !mExitRequested) {
|
||||
while (mCommandBuffersToExecute.empty() && !mExitRequested) {
|
||||
mCondition.wait(lock);
|
||||
}
|
||||
return std::move(mCommandBuffersToExecute);
|
||||
|
||||
@@ -50,9 +50,6 @@ class Dispatcher;
|
||||
|
||||
class Driver {
|
||||
public:
|
||||
static std::unique_ptr<Driver>
|
||||
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<void()> command) {
|
||||
inline void queueCommand(const std::function<void()>& command) {
|
||||
command();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<SamplerBuffer> 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
|
||||
|
||||
@@ -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 <typename T>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -617,7 +617,7 @@ public:
|
||||
struct rebind { using other = STLAllocator<OTHER, ARENA>; };
|
||||
|
||||
public:
|
||||
STLAllocator(ARENA& arena) : mArena(arena) { }
|
||||
explicit STLAllocator(ARENA& arena) : mArena(arena) { }
|
||||
|
||||
TYPE* allocate(std::size_t n) {
|
||||
return static_cast<TYPE *>(mArena.alloc(n * sizeof(n), alignof(TYPE)));
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
using StringLiteral = const char[N];
|
||||
|
||||
template <size_t N>
|
||||
StaticString(StringLiteral<N> const& other) noexcept
|
||||
StaticString(StringLiteral<N> const& other) noexcept // NOLINT(google-explicit-constructor)
|
||||
: mString(other),
|
||||
mLength(size_type(N - 1)) {
|
||||
}
|
||||
@@ -91,14 +91,13 @@ public:
|
||||
mLength(size_type(length)) {
|
||||
}
|
||||
|
||||
|
||||
template<size_t N>
|
||||
StaticString& operator=(StringLiteral<N> 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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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<Entity>;
|
||||
using Type = uint32_t;
|
||||
|
||||
Entity(Type identity) noexcept : mIdentity(identity) { }
|
||||
explicit Entity(Type identity) noexcept : mIdentity(identity) { }
|
||||
|
||||
Type mIdentity = 0;
|
||||
};
|
||||
|
||||
@@ -45,12 +45,13 @@ public:
|
||||
|
||||
// EDIT instances can be converted to "read" Instances of same type
|
||||
template <typename = std::enable_if<!EDIT>>
|
||||
constexpr EntityInstance(EntityInstance<T, true> const& other) noexcept {
|
||||
constexpr explicit EntityInstance(EntityInstance<T, true> const& other) noexcept {
|
||||
mInstance = other.asValue();
|
||||
}
|
||||
template <typename = std::enable_if<!EDIT>>
|
||||
EntityInstance& operator=(EntityInstance<T, true> 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
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
#ifndef TNT_UTILS_HASH_H
|
||||
#define TNT_UTILS_HASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace utils {
|
||||
namespace hash {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<details::Safe
|
||||
public:
|
||||
using Instance = EntityInstance<NameComponentManager>;
|
||||
|
||||
NameComponentManager(EntityManager& em);
|
||||
explicit NameComponentManager(EntityManager& em);
|
||||
~NameComponentManager();
|
||||
|
||||
using SingleInstanceComponentManager::hasComponent;
|
||||
|
||||
@@ -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 }; }
|
||||
|
||||
@@ -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<Allocator, Elements...>::StructureRef::assign(
|
||||
// implements StructureRef& StructureRef::operator=(Structure const& rhs)
|
||||
auto UTILS_UNUSED l = { (soa->elementAt<Is>(index) = std::get<Is>(rhs.elements), 0)... };
|
||||
return *this;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Allocator, typename... Elements>
|
||||
template<size_t... Is>
|
||||
|
||||
@@ -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--;
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
#ifndef TNT_UTILS_MEMALIGN_H
|
||||
#define TNT_UTILS_MEMALIGN_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@@ -85,7 +88,7 @@ public:
|
||||
inline STLAlignedAllocator() noexcept = default;
|
||||
|
||||
template<typename T>
|
||||
inline STLAlignedAllocator(const STLAlignedAllocator<T>&) noexcept {}
|
||||
inline explicit STLAlignedAllocator(const STLAlignedAllocator<T>&) noexcept {}
|
||||
|
||||
inline ~STLAlignedAllocator() noexcept = default;
|
||||
|
||||
|
||||
@@ -48,4 +48,4 @@
|
||||
#undef PURE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -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<NAME>(instance) = { name };
|
||||
elementAt<NAME>(instance) = details::SafeString{ name };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user