*: reformat
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <utils/types.hpp>
|
||||
#include <utils/error.hpp>
|
||||
#include <utils/types.hpp>
|
||||
|
||||
namespace kvm {
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace kvm {
|
||||
class VM {
|
||||
/// The primary vCPU.
|
||||
util::Ref<CPU> vcpu;
|
||||
public:
|
||||
|
||||
public:
|
||||
/// Creates a new VM instance.
|
||||
static util::ErrorOr<util::Ref<VM>> create();
|
||||
|
||||
// TODO: more stuff
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace kvm
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ namespace util {
|
||||
return Error::format("System error: {}", std::string_view(pStr));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace util
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <format>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <optional>
|
||||
#include <format>
|
||||
|
||||
namespace util {
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace util {
|
||||
static Error vFormat(const std::string_view formatString, std::format_args args);
|
||||
|
||||
public:
|
||||
explicit Error(const std::string& message)
|
||||
: msg(message) {}
|
||||
explicit Error(const std::string& message) : msg(message) {}
|
||||
|
||||
template <class... Args>
|
||||
static constexpr auto format(const std::string_view formatString, Args... args) {
|
||||
@@ -30,53 +29,35 @@ namespace util {
|
||||
/// A type which can store either an error or a value.
|
||||
template <class T>
|
||||
class ErrorOr {
|
||||
std::variant<
|
||||
Error,
|
||||
T
|
||||
> variant;
|
||||
std::variant<Error, T> variant;
|
||||
|
||||
public:
|
||||
constexpr ErrorOr(const Error& error)
|
||||
: variant(error) {}
|
||||
constexpr ErrorOr(const Error& error) : variant(error) {}
|
||||
|
||||
constexpr ErrorOr(const T& value)
|
||||
: variant(value) {}
|
||||
constexpr ErrorOr(const T& value) : variant(value) {}
|
||||
|
||||
bool isValue() const {
|
||||
return std::holds_alternative<T>(variant);
|
||||
}
|
||||
bool isValue() const { return std::holds_alternative<T>(variant); }
|
||||
|
||||
bool isError() const {
|
||||
return std::holds_alternative<Error>(variant);
|
||||
}
|
||||
bool isError() const { return std::holds_alternative<Error>(variant); }
|
||||
|
||||
const Error& err() const {
|
||||
return std::get<Error>(variant);
|
||||
}
|
||||
const Error& err() const { return std::get<Error>(variant); }
|
||||
|
||||
T& value() {
|
||||
return std::get<T>(variant);
|
||||
}
|
||||
T& value() { return std::get<T>(variant); }
|
||||
|
||||
T& value() const {
|
||||
return std::get<T>(variant);
|
||||
}
|
||||
T& value() const { return std::get<T>(variant); }
|
||||
};
|
||||
|
||||
template <>
|
||||
class ErrorOr<void> {
|
||||
std::optional<Error> error;
|
||||
|
||||
public:
|
||||
ErrorOr() = default;
|
||||
ErrorOr(const Error& error)
|
||||
: error(error) {}
|
||||
ErrorOr(const Error& error) : error(error) {}
|
||||
|
||||
bool isError() const {
|
||||
return error.has_value();
|
||||
}
|
||||
bool isError() const { return error.has_value(); }
|
||||
|
||||
const Error& err() const {
|
||||
return error.value();
|
||||
}
|
||||
const Error& err() const { return error.value(); }
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace util
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
//! Core types and includes
|
||||
#pragma once
|
||||
|
||||
#include <base/assert.hpp>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include <base/assert.hpp>
|
||||
|
||||
// these are in the global namespace since most libraries
|
||||
// won't try defining anything like this in the global namespace
|
||||
// (and I'd like these types to be used globally a lot more anyways)
|
||||
@@ -56,4 +55,4 @@ namespace util {
|
||||
template <class T, auto Free = std::free>
|
||||
using CUnique = Unique<T, UniqueCDeleter<T, Free>>;
|
||||
|
||||
} // namespace base
|
||||
} // namespace util
|
||||
|
||||
3
tools/format.sh
Executable file
3
tools/format.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
# Reformats the entire tv2hv source tree.
|
||||
find src/ -type f | rg -e "(.cpp|.h|.hpp)" | xargs -i -- clang-format -i "{}"
|
||||
Reference in New Issue
Block a user