diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-09-29 09:18:07 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-09-29 10:38:21 +0300 |
commit | ea1848ce0a5f03c3a9f7e0a221350f4f4044bb08 (patch) | |
tree | fdbb5979dfe5f81a4d3e53ea71f625d84848e730 /core/templates | |
parent | f8745f2f71c79972df66f17a3da75f6e328bc55d (diff) |
Use `constexpr` in the conditions with template parameters and `sizeof`s to suppress C4127 warnings.
Diffstat (limited to 'core/templates')
-rw-r--r-- | core/templates/local_vector.h | 10 | ||||
-rw-r--r-- | core/templates/pooled_list.h | 2 |
2 files changed, 6 insertions, 6 deletions
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<T>::value && !force_trivial) { + if constexpr (!std::is_trivially_constructible<T>::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<T>::value && !force_trivial) { + if constexpr (!std::is_trivially_destructible<T>::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<T>::value && !force_trivial) { + if constexpr (!std::is_trivially_destructible<T>::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<T>::value && !force_trivial) { + if constexpr (!std::is_trivially_destructible<T>::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<T>::value && !force_trivial) { + if constexpr (!std::is_trivially_constructible<T>::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] = {}; } |