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

@ -11,4 +11,7 @@ jobs:
- name: Check out repo
uses: actions/checkout@v3
- name: Run clang-format
uses: jidicula/clang-format-action@4.11.0
uses: jidicula/clang-format-action@v4.11.0
with:
exclude-regex: (libspirv|3rdparty)
clang-format-version: 16

View file

@ -12,14 +12,10 @@ jobs:
uses: ZedThree/clang-tidy-review@v0.13.1
id: review
with:
clang_tidy_version: 15
apt_packages: libunwind-dev, libglfw3-dev, libvulkan-dev, vulkan-validationlayers-dev, spirv-tools
cmake_command: cmake . -DCMAKE_EXPORT_COMPILE_COMMANDS=on
# Uploads an artefact containing clang_fixes.json
split_workflow: true
- name: Upload review
uses: ZedThree/clang-tidy-review/upload@v0.13.1
id: upload-review
# If there are any comments, fail the check
- if: steps.review.outputs.total_comments > 0
run: exit 1
id: upload-review

13
.github/workflows/tidy-comments.yml vendored Normal file
View file

@ -0,0 +1,13 @@
name: Post clang-tidy review comments
on:
workflow_run:
workflows: ["Linting"]
types:
- completed
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: ZedThree/clang-tidy-review/post@v0.12.0
with:
lgtm_comment_body: "No linting issues found!"

View file

@ -71,8 +71,8 @@ struct ImageValue : Value {};
struct SampledImageValue : Value {};
template <typename T>
requires(std::is_base_of_v<Value, T>) struct ConstantValue : T {
};
requires(std::is_base_of_v<Value, T>)
struct ConstantValue : T {};
struct AnyConstantValue : Value {
AnyConstantValue() = default;
@ -95,28 +95,28 @@ struct AnyConstantValue : Value {
};
template <typename T>
requires(std::is_base_of_v<Type, T>) struct VectorOfType : VectorType {
};
requires(std::is_base_of_v<Type, T>)
struct VectorOfType : VectorType {};
template <typename T>
requires(std::is_base_of_v<Type, T>) struct ArrayOfType : ArrayType {
};
requires(std::is_base_of_v<Type, T>)
struct ArrayOfType : ArrayType {};
template <typename T>
requires(std::is_base_of_v<Type, T>) struct VectorOfValue : VectorValue {
};
requires(std::is_base_of_v<Type, T>)
struct VectorOfValue : VectorValue {};
template <typename T>
requires(std::is_base_of_v<Type, T>) struct ArrayOfValue : ArrayValue {
};
requires(std::is_base_of_v<Type, T>)
struct ArrayOfValue : ArrayValue {};
template <typename T>
requires(std::is_base_of_v<Type, T>) struct PointerToType : PointerType {
};
requires(std::is_base_of_v<Type, T>)
struct PointerToType : PointerType {};
template <typename T>
requires(std::is_base_of_v<Type, T>) struct PointerToValue : PointerValue {
};
requires(std::is_base_of_v<Type, T>)
struct PointerToValue : PointerValue {};
struct StructPointerValue : Value {};
@ -125,21 +125,45 @@ struct VariableValue : PointerValue {};
namespace detail {
template <typename T> struct TypeToValueImpl;
template <> struct TypeToValueImpl<Type> { using type = Value; };
template <> struct TypeToValueImpl<BoolType> { using type = BoolValue; };
template <> struct TypeToValueImpl<IntType> { using type = IntValue; };
template <> struct TypeToValueImpl<SIntType> { using type = SIntValue; };
template <> struct TypeToValueImpl<UIntType> { using type = UIntValue; };
template <> struct TypeToValueImpl<FloatType> { using type = FloatValue; };
template <> struct TypeToValueImpl<StructType> { using type = StructValue; };
template <> struct TypeToValueImpl<PointerType> { using type = PointerValue; };
template <> struct TypeToValueImpl<Type> {
using type = Value;
};
template <> struct TypeToValueImpl<BoolType> {
using type = BoolValue;
};
template <> struct TypeToValueImpl<IntType> {
using type = IntValue;
};
template <> struct TypeToValueImpl<SIntType> {
using type = SIntValue;
};
template <> struct TypeToValueImpl<UIntType> {
using type = UIntValue;
};
template <> struct TypeToValueImpl<FloatType> {
using type = FloatValue;
};
template <> struct TypeToValueImpl<StructType> {
using type = StructValue;
};
template <> struct TypeToValueImpl<PointerType> {
using type = PointerValue;
};
template <> struct TypeToValueImpl<VariableValue> {
using type = PointerValue;
};
template <> struct TypeToValueImpl<VectorType> { using type = VectorValue; };
template <> struct TypeToValueImpl<ArrayType> { using type = ArrayValue; };
template <> struct TypeToValueImpl<SamplerType> { using type = SamplerValue; };
template <> struct TypeToValueImpl<ImageType> { using type = ImageValue; };
template <> struct TypeToValueImpl<VectorType> {
using type = VectorValue;
};
template <> struct TypeToValueImpl<ArrayType> {
using type = ArrayValue;
};
template <> struct TypeToValueImpl<SamplerType> {
using type = SamplerValue;
};
template <> struct TypeToValueImpl<ImageType> {
using type = ImageValue;
};
template <> struct TypeToValueImpl<SampledImageType> {
using type = SampledImageValue;
};
@ -160,7 +184,8 @@ template <typename T>
using TypeToValue = typename detail::TypeToValueImpl<T>::type;
template <typename T>
requires(std::is_base_of_v<Type, T>) struct ScalarOrVectorOfValue : Value {
requires(std::is_base_of_v<Type, T>)
struct ScalarOrVectorOfValue : Value {
ScalarOrVectorOfValue() = default;
ScalarOrVectorOfValue(TypeToValue<T> scalar) { id = scalar.id; }
@ -174,8 +199,8 @@ using ConstantInt = ConstantValue<IntValue>;
using ConstantFloat = ConstantValue<FloatValue>;
template <typename ToT, typename FromT>
requires(std::is_base_of_v<FromT, ToT> &&std::is_base_of_v<Id, FromT>) ToT
cast(FromT from) {
requires(std::is_base_of_v<FromT, ToT> && std::is_base_of_v<Id, FromT>)
ToT cast(FromT from) {
ToT result;
result.id = from.id;
return result;
@ -252,7 +277,8 @@ struct IdGenerator {
std::uint32_t bounds = 1;
template <typename T>
requires(std::is_base_of_v<Id, T>) T newId() {
requires(std::is_base_of_v<Id, T>)
T newId() {
T result;
result.id = bounds++;
return result;
@ -518,8 +544,9 @@ public:
// arithmetic
template <typename T>
requires(std::is_base_of_v<ScalarType, T>) TypeToValue<T> createInst(
spv::Op op, T resultType, std::span<const TypeToValue<T>> operands) {
requires(std::is_base_of_v<ScalarType, T>)
TypeToValue<T> createInst(spv::Op op, T resultType,
std::span<const TypeToValue<T>> operands) {
auto region = bodyRegion.pushOp(op, 3 + operands.size());
auto id = newId<TypeToValue<T>>();
region.pushIdUse(resultType);
@ -556,142 +583,142 @@ public:
}
template <typename T>
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSNegate(T resultType, TypeToValue<T> operand) {
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSNegate(T resultType, TypeToValue<T> operand) {
return createInst(spv::Op::OpSNegate, resultType, std::array{operand});
}
template <typename T>
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFNegate(T resultType, TypeToValue<T> operand) {
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFNegate(T resultType, TypeToValue<T> operand) {
return createInst(spv::Op::OpFNegate, resultType, std::array{operand});
}
template <typename T>
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
std::is_same_v<VectorOfType<IntType>, T> ||
std::is_same_v<VectorOfType<SIntType>, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createIAdd(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
std::is_same_v<VectorOfType<IntType>, T> ||
std::is_same_v<VectorOfType<SIntType>, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createIAdd(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpIAdd, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFAdd(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFAdd(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpFAdd, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
std::is_same_v<VectorOfType<IntType>, T> ||
std::is_same_v<VectorOfType<SIntType>, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createISub(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
std::is_same_v<VectorOfType<IntType>, T> ||
std::is_same_v<VectorOfType<SIntType>, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createISub(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpISub, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFSub(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFSub(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpFSub, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
std::is_same_v<VectorOfType<IntType>, T> ||
std::is_same_v<VectorOfType<SIntType>, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createIMul(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
std::is_same_v<VectorOfType<IntType>, T> ||
std::is_same_v<VectorOfType<SIntType>, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createIMul(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpIMul, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFMul(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFMul(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpFMul, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<UIntType, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createUDiv(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<UIntType, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createUDiv(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpUDiv, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSDiv(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSDiv(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpSDiv, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFDiv(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFDiv(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpFDiv, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<UIntType, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createUMod(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<UIntType, T> ||
std::is_same_v<VectorOfType<UIntType>, T>)
TypeToValue<T> createUMod(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpUMod, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSRem(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSRem(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpSRem, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSMod(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<SIntType, T> ||
std::is_same_v<VectorOfType<SIntType>, T>)
TypeToValue<T> createSMod(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpSMod, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFRem(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFRem(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpFRem, resultType,
std::array{operand1, operand2});
}
template <typename T>
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFMod(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
requires(std::is_same_v<FloatType, T> ||
std::is_same_v<VectorOfType<FloatType>, T>)
TypeToValue<T> createFMod(T resultType, TypeToValue<T> operand1,
TypeToValue<T> operand2) {
return createInst(spv::Op::OpFMod, resultType,
std::array{operand1, operand2});
}
@ -768,8 +795,9 @@ public:
}
template <typename T>
requires(std::is_base_of_v<Type, T>) TypeToValue<T> createPhi(
T resultType, std::span<const std::pair<Value, Block>> values) {
requires(std::is_base_of_v<Type, T>)
TypeToValue<T> createPhi(T resultType,
std::span<const std::pair<Value, Block>> values) {
return cast<TypeToValue<T>>(
createPhi(static_cast<Type>(resultType), values));
}
@ -855,8 +883,8 @@ public:
}
template <typename T>
requires(std::is_base_of_v<Type, T>)
TypeToValue<T> createLoad(T resultType, PointerValue pointer) {
requires(std::is_base_of_v<Type, T>)
TypeToValue<T> createLoad(T resultType, PointerValue pointer) {
auto region = bodyRegion.pushOp(spv::Op::OpLoad, 4);
auto id = newId<TypeToValue<T>>();
region.pushIdUse(resultType);
@ -1588,8 +1616,8 @@ public:
: mIdGenerator(&idGenerator), capabilityRegion{1}, extensionRegion{1},
extInstRegion{4}, memoryModelRegion{3}, entryPointRegion{1},
executionModeRegion{1}, debugRegion{0}, annotationRegion{1},
globalRegion{1}, functionDeclRegion{1}, functionRegion{
expInstructionsCount} {}
globalRegion{1}, functionDeclRegion{1},
functionRegion{expInstructionsCount} {}
SpirvBuilder clone() const { return *this; }
@ -1669,8 +1697,8 @@ public:
}
template <typename T>
requires(std::is_base_of_v<Type, T>)
TypeToValue<T> createUndef(T resultType) {
requires(std::is_base_of_v<Type, T>)
TypeToValue<T> createUndef(T resultType) {
return cast<TypeToValue<T>>(createUndef(resultType));
}
@ -1956,8 +1984,8 @@ public:
}
template <typename T>
requires(std::is_base_of_v<Type, T>) PointerToType<T> createTypePointer(
spv::StorageClass storageClass, T type) {
requires(std::is_base_of_v<Type, T>)
PointerToType<T> createTypePointer(spv::StorageClass storageClass, T type) {
return cast<PointerToType<T>>(
createTypePointer(storageClass, static_cast<Type>(type)));
}
@ -1995,9 +2023,9 @@ public:
}
template <typename T>
requires(std::is_base_of_v<Type, T>)
ConstantValue<TypeToValue<T>> createConstant(
T type, std::span<const std::uint32_t> values) {
requires(std::is_base_of_v<Type, T>)
ConstantValue<TypeToValue<T>>
createConstant(T type, std::span<const std::uint32_t> values) {
auto region = globalRegion.pushOp(spv::Op::OpConstant, 3 + values.size());
auto id = newId<ConstantValue<TypeToValue<T>>>();
region.pushIdUse(type);
@ -2009,16 +2037,14 @@ public:
}
template <typename T>
requires(std::is_base_of_v<Type, T>)
ConstantValue<TypeToValue<T>> createConstant32(T type,
std::uint32_t value) {
requires(std::is_base_of_v<Type, T>)
ConstantValue<TypeToValue<T>> createConstant32(T type, std::uint32_t value) {
return createConstant(type, std::array{value});
}
template <typename T>
requires(std::is_base_of_v<Type, T>)
ConstantValue<TypeToValue<T>> createConstant64(T type,
std::uint64_t value) {
requires(std::is_base_of_v<Type, T>)
ConstantValue<TypeToValue<T>> createConstant64(T type, std::uint64_t value) {
return createConstant(type,
std::array{static_cast<std::uint32_t>(value),
static_cast<std::uint32_t>(value >> 32)});

View file

@ -40,8 +40,8 @@ public:
Node *getParent() const { return mParent; }
template <typename T>
requires(std::is_base_of_v<Node, T>) auto getParent() const
-> decltype(dynCast<T>(mParent)) {
requires(std::is_base_of_v<Node, T>)
auto getParent() const -> decltype(dynCast<T>(mParent)) {
return dynCast<T>(mParent);
}
@ -53,18 +53,18 @@ public:
};
template <typename T, typename ST>
requires(std::is_base_of_v<Node, T> &&std::is_base_of_v<Node, ST>) &&
requires(ST *s) {
dynamic_cast<T *>(s);
requires(std::is_base_of_v<Node, T> && std::is_base_of_v<Node, ST>) &&
requires(ST *s) { dynamic_cast<T *>(s); }
T *dynCast(ST *s) {
return dynamic_cast<T *>(s);
}
T *dynCast(ST *s) { return dynamic_cast<T *>(s); }
template <typename T, typename ST>
requires(std::is_base_of_v<Node, T> &&std::is_base_of_v<Node, ST>) &&
requires(const ST *s) {
dynamic_cast<const T *>(s);
requires(std::is_base_of_v<Node, T> && std::is_base_of_v<Node, ST>) &&
requires(const ST *s) { dynamic_cast<const T *>(s); }
const T *dynCast(const ST *s) {
return dynamic_cast<const T *>(s);
}
const T *dynCast(const ST *s) { return dynamic_cast<const T *>(s); }
inline bool isNodeEqual(const Node *lhs, const Node *rhs) {
if (lhs == rhs) {
@ -331,7 +331,8 @@ class Context {
public:
template <typename T, typename... ArgsT>
requires(std::is_constructible_v<T, ArgsT...>) T *create(ArgsT &&...args) {
requires(std::is_constructible_v<T, ArgsT...>)
T *create(ArgsT &&...args) {
auto result = new T(std::forward<ArgsT>(args)...);
mNodes.push_front(std::unique_ptr<Node>{result});
return result;

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;
}

View file

@ -82,7 +82,8 @@ namespace detail {
template <auto Fn> struct WrapImpl;
template <typename... Args, SysResult (*Fn)(Thread *, Args...)>
requires(sizeof...(Args) < 8) struct WrapImpl<Fn> {
requires(sizeof...(Args) < 8)
struct WrapImpl<Fn> {
constexpr sysent operator()() {
sysent result;
result.narg = sizeof...(Args);