clean public header dependencies (#8725)
* remove io::ostream dependency from CString.h + clang tidy * remove ostream.h dependency from Invocable.h * remove Panic.h dependency from FixedCapacityVector.h * remove ostream.h dependency from backend/ headers * clang tidy Panic.h/Panic.cpp
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/compressed_pair.h>
|
||||
#include <utils/Panic.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
@@ -40,6 +40,11 @@
|
||||
|
||||
namespace utils {
|
||||
|
||||
class FixedCapacityVectorBase {
|
||||
protected:
|
||||
UTILS_NORETURN static void capacityCheckFailed(size_t capacity, size_t size);
|
||||
};
|
||||
|
||||
/**
|
||||
* FixedCapacityVector is (almost) a drop-in replacement for std::vector<> except it has a
|
||||
* fixed capacity decided at runtime. The vector storage is never reallocated unless reserve()
|
||||
@@ -56,7 +61,7 @@ namespace utils {
|
||||
* the optional value argument, e.g. FixedCapacityVector<int>(4, 0) or foo.resize(4, 0).
|
||||
*/
|
||||
template<typename T, typename A = std::allocator<T>, bool CapacityCheck = true>
|
||||
class UTILS_PUBLIC FixedCapacityVector {
|
||||
class UTILS_PUBLIC FixedCapacityVector : protected FixedCapacityVectorBase {
|
||||
public:
|
||||
using allocator_type = A;
|
||||
using value_type = T;
|
||||
@@ -266,7 +271,7 @@ public:
|
||||
mSize = 0;
|
||||
}
|
||||
|
||||
void resize(size_type count) {
|
||||
void resize(size_type const count) {
|
||||
assertCapacityForSize(count);
|
||||
if constexpr(std::is_trivially_constructible_v<value_type> &&
|
||||
std::is_trivially_destructible_v<value_type>) {
|
||||
@@ -277,12 +282,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void resize(size_type count, const_reference v) {
|
||||
void resize(size_type const count, const_reference v) {
|
||||
assertCapacityForSize(count);
|
||||
resize_non_trivial(count, v);
|
||||
}
|
||||
|
||||
void swap(FixedCapacityVector& other) {
|
||||
void swap(FixedCapacityVector& other) noexcept {
|
||||
using std::swap;
|
||||
swap(mData, other.mData);
|
||||
swap(mSize, other.mSize);
|
||||
@@ -326,16 +331,16 @@ private:
|
||||
return mCapacityAllocator.second();
|
||||
}
|
||||
|
||||
iterator assertCapacityForSize(size_type s) {
|
||||
iterator assertCapacityForSize(size_type const s) {
|
||||
if constexpr(CapacityCheck || FILAMENT_FORCE_CAPACITY_CHECK) {
|
||||
FILAMENT_CHECK_PRECONDITION(capacity() >= s)
|
||||
<< "capacity exceeded: requested size " << (unsigned long)s
|
||||
<< "u, available capacity " << (unsigned long)capacity() << "u.";
|
||||
if (UTILS_VERY_UNLIKELY(capacity() < s)) {
|
||||
capacityCheckFailed(capacity(), s);
|
||||
}
|
||||
}
|
||||
return end();
|
||||
}
|
||||
|
||||
inline void construct(iterator first, iterator last) noexcept {
|
||||
void construct(iterator const first, iterator const last) noexcept {
|
||||
// we check for triviality here so that the implementation could be non-inline
|
||||
if constexpr(!std::is_trivially_constructible_v<value_type>) {
|
||||
construct_non_trivial(first, last);
|
||||
@@ -358,7 +363,7 @@ private:
|
||||
}
|
||||
|
||||
|
||||
inline void destroy(iterator first, iterator last) noexcept {
|
||||
void destroy(iterator const first, iterator const last) noexcept {
|
||||
// we check for triviality here so that the implementation could be non-inline
|
||||
if constexpr(!std::is_trivially_destructible_v<value_type>) {
|
||||
destroy_non_trivial(first, last);
|
||||
@@ -419,7 +424,7 @@ private:
|
||||
explicit SizeTypeWrapper(TYPE value) noexcept : value(value) { }
|
||||
SizeTypeWrapper& operator=(TYPE rhs) noexcept { value = rhs; return *this; }
|
||||
SizeTypeWrapper& operator=(SizeTypeWrapper& rhs) noexcept = delete;
|
||||
operator TYPE() const noexcept { return value; }
|
||||
operator TYPE() const noexcept { return value; } // NOLINT(*-explicit-constructor)
|
||||
};
|
||||
|
||||
pointer mData{};
|
||||
|
||||
Reference in New Issue
Block a user