Fix typo & other problems (#12)

* Ignore external deps
* Clang 16
* clang-format 16
* Fix linting action
This commit is contained in:
Isaac Marovitz 2023-07-06 22:48:59 +01:00 committed by GitHub
parent 0bda85fdc2
commit 098220217c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 201 additions and 153 deletions

View file

@ -15,7 +15,9 @@ void kfree(void *ptr, std::size_t size);
template <typename T> struct kallocator {
using value_type = T;
template <typename U> struct rebind { using other = kallocator<U>; };
template <typename U> struct rebind {
using other = kallocator<U>;
};
T *allocate(std::size_t n) {
return static_cast<T *>(kalloc(sizeof(T) * n, alignof(T)));
@ -47,7 +49,7 @@ using kunmap =
template <typename T, typename... Args> T *knew(Args &&...args) {
auto loc = static_cast<T *>(utils::kalloc(sizeof(T), alignof(T)));
auto res = std::construct_at(loc, std::forward<Args>(args)...);
if constexpr (requires(T * t) { t->_total_size = sizeof(T); })
if constexpr (requires(T *t) { t->_total_size = sizeof(T); })
res->_total_size = sizeof(T);
return res;
}

View file

@ -13,7 +13,8 @@ namespace orbis {
inline namespace utils {
template <WithRc T, typename IdT = int, std::size_t MaxId = 4096,
std::size_t MinId = 0>
requires(MaxId > MinId) class RcIdMap {
requires(MaxId > MinId)
class RcIdMap {
static constexpr auto ChunkSize = std::min<std::size_t>(MaxId - MinId, 64);
static constexpr auto ChunkCount =
(MaxId - MinId + ChunkSize - 1) / ChunkSize;
@ -190,7 +191,8 @@ public:
template <typename T, typename IdT = int, std::size_t MaxId = 4096,
std::size_t MinId = 0>
requires(MaxId > MinId) struct OwningIdMap {
requires(MaxId > MinId)
struct OwningIdMap {
static constexpr auto ChunkSize = std::min<std::size_t>(MaxId - MinId, 64);
static constexpr auto ChunkCount =
(MaxId - MinId + ChunkSize - 1) / ChunkSize;
@ -248,8 +250,8 @@ requires(MaxId > MinId) struct OwningIdMap {
BitSet<ChunkCount> fullChunks;
template <typename... ArgsT>
requires(std::is_constructible_v<T, ArgsT...>) std::pair<IdT, T *> emplace(
ArgsT &&...args) {
requires(std::is_constructible_v<T, ArgsT...>)
std::pair<IdT, T *> emplace(ArgsT &&...args) {
auto page = fullChunks.countr_one();
if (page == ChunkCount) {

View file

@ -50,23 +50,24 @@ public:
Ref() = default;
template <typename OT>
requires(std::is_base_of_v<T, OT>) Ref(OT *ref) : m_ref(ref) {
requires(std::is_base_of_v<T, OT>)
Ref(OT *ref) : m_ref(ref) {
if (m_ref != nullptr) {
ref->incRef();
}
}
template <typename OT>
requires(std::is_base_of_v<T, OT>) Ref(const Ref<OT> &other)
: m_ref(other.get()) {
requires(std::is_base_of_v<T, OT>)
Ref(const Ref<OT> &other) : m_ref(other.get()) {
if (m_ref != nullptr) {
m_ref->incRef();
}
}
template <typename OT>
requires(std::is_base_of_v<T, OT>) Ref(Ref<OT> &&other)
: m_ref(other.release()) {}
requires(std::is_base_of_v<T, OT>)
Ref(Ref<OT> &&other) : m_ref(other.release()) {}
Ref(const Ref &other) : m_ref(other.get()) {
if (m_ref != nullptr) {
@ -76,19 +77,22 @@ public:
Ref(Ref &&other) : m_ref(other.release()) {}
template <typename OT>
requires(std::is_base_of_v<T, OT>) Ref &operator=(Ref<OT> &&other) {
requires(std::is_base_of_v<T, OT>)
Ref &operator=(Ref<OT> &&other) {
other.swap(*this);
return *this;
}
template <typename OT>
requires(std::is_base_of_v<T, OT>) Ref &operator=(OT *other) {
requires(std::is_base_of_v<T, OT>)
Ref &operator=(OT *other) {
*this = Ref(other);
return *this;
}
template <typename OT>
requires(std::is_base_of_v<T, OT>) Ref &operator=(const Ref<OT> &other) {
requires(std::is_base_of_v<T, OT>)
Ref &operator=(const Ref<OT> &other) {
*this = Ref(other);
return *this;
}