From ea1848ce0a5f03c3a9f7e0a221350f4f4044bb08 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 29 Sep 2022 09:18:07 +0300 Subject: Use `constexpr` in the conditions with template parameters and `sizeof`s to suppress C4127 warnings. --- core/templates/local_vector.h | 10 +++++----- core/templates/pooled_list.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'core/templates') diff --git a/core/templates/local_vector.h b/core/templates/local_vector.h index 49690f2373..dc93acc8ab 100644 --- a/core/templates/local_vector.h +++ b/core/templates/local_vector.h @@ -68,7 +68,7 @@ public: CRASH_COND_MSG(!data, "Out of memory"); } - if (!std::is_trivially_constructible::value && !force_trivial) { + if constexpr (!std::is_trivially_constructible::value && !force_trivial) { memnew_placement(&data[count++], T(p_elem)); } else { data[count++] = p_elem; @@ -81,7 +81,7 @@ public: for (U i = p_index; i < count; i++) { data[i] = data[i + 1]; } - if (!std::is_trivially_destructible::value && !force_trivial) { + if constexpr (!std::is_trivially_destructible::value && !force_trivial) { data[count].~T(); } } @@ -94,7 +94,7 @@ public: if (count > p_index) { data[p_index] = data[count]; } - if (!std::is_trivially_destructible::value && !force_trivial) { + if constexpr (!std::is_trivially_destructible::value && !force_trivial) { data[count].~T(); } } @@ -135,7 +135,7 @@ public: _FORCE_INLINE_ U size() const { return count; } void resize(U p_size) { if (p_size < count) { - if (!std::is_trivially_destructible::value && !force_trivial) { + if constexpr (!std::is_trivially_destructible::value && !force_trivial) { for (U i = p_size; i < count; i++) { data[i].~T(); } @@ -152,7 +152,7 @@ public: data = (T *)memrealloc(data, capacity * sizeof(T)); CRASH_COND_MSG(!data, "Out of memory"); } - if (!std::is_trivially_constructible::value && !force_trivial) { + if constexpr (!std::is_trivially_constructible::value && !force_trivial) { for (U i = count; i < p_size; i++) { memnew_placement(&data[i], T); } diff --git a/core/templates/pooled_list.h b/core/templates/pooled_list.h index 08f53572e7..2b67da87ba 100644 --- a/core/templates/pooled_list.h +++ b/core/templates/pooled_list.h @@ -112,7 +112,7 @@ public: list.resize(r_id + 1); static_assert((!zero_on_first_request) || (__is_pod(T)), "zero_on_first_request requires trivial type"); - if (zero_on_first_request && __is_pod(T)) { + if constexpr (zero_on_first_request && __is_pod(T)) { list[r_id] = {}; } -- cgit v1.2.3