[ox] Cleanup unnecessary namespace specifications
This commit is contained in:
parent
72f53b08cb
commit
46ea85fa7d
2
deps/ox/src/ox/claw/read.cpp
vendored
2
deps/ox/src/ox/claw/read.cpp
vendored
@ -64,7 +64,7 @@ Result<Buffer> stripClawHeader(const char *buff, std::size_t buffLen) noexcept {
|
||||
oxReturnError(header);
|
||||
Buffer out(header.value.dataSize);
|
||||
ox_memcpy(out.data(), header.value.data, out.size());
|
||||
return ox::move(out);
|
||||
return move(out);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ struct StatInfo {
|
||||
|
||||
template<typename size_t>
|
||||
struct OX_PACKED FileStoreItem: public ptrarith::Item<size_t> {
|
||||
ox::LittleEndian<size_t> id = 0;
|
||||
ox::LittleEndian<uint8_t> fileType = 0;
|
||||
ox::LittleEndian<size_t> links = 0;
|
||||
ox::LittleEndian<size_t> left = 0;
|
||||
ox::LittleEndian<size_t> right = 0;
|
||||
LittleEndian<size_t> id = 0;
|
||||
LittleEndian<uint8_t> fileType = 0;
|
||||
LittleEndian<size_t> links = 0;
|
||||
LittleEndian<size_t> left = 0;
|
||||
LittleEndian<size_t> right = 0;
|
||||
|
||||
FileStoreItem() = default;
|
||||
|
||||
@ -65,8 +65,8 @@ class FileStoreTemplate {
|
||||
static constexpr auto MaxInode = MaxValue<size_t> / 2;
|
||||
|
||||
struct OX_PACKED FileStoreData {
|
||||
ox::LittleEndian<size_t> rootNode = 0;
|
||||
ox::Random random;
|
||||
LittleEndian<size_t> rootNode = 0;
|
||||
Random random;
|
||||
};
|
||||
|
||||
size_t m_buffSize = 0;
|
||||
|
2
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
2
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
@ -56,7 +56,7 @@ Error FileSystem::read(const FileAddress &addr, std::size_t readStart, std::size
|
||||
}
|
||||
}
|
||||
|
||||
Result<Vector<String>> FileSystem::ls(const ox::String &dir) noexcept {
|
||||
Result<Vector<String>> FileSystem::ls(const String &dir) noexcept {
|
||||
return ls(dir.c_str());
|
||||
}
|
||||
|
||||
|
2
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
2
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@ -50,7 +50,7 @@ class FileSystem {
|
||||
|
||||
Result<const char*> directAccess(const FileAddress &addr) noexcept;
|
||||
|
||||
Result<Vector<String>> ls(const ox::String &dir) noexcept;
|
||||
Result<Vector<String>> ls(const String &dir) noexcept;
|
||||
|
||||
virtual Result<Vector<String>> ls(const char *dir) noexcept = 0;
|
||||
|
||||
|
@ -23,7 +23,7 @@ PassThroughFS::PassThroughFS(const char *dirPath) {
|
||||
PassThroughFS::~PassThroughFS() {
|
||||
}
|
||||
|
||||
ox::String PassThroughFS::basePath() {
|
||||
String PassThroughFS::basePath() {
|
||||
return m_path.string().c_str();
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ Result<Vector<String>> PassThroughFS::ls(const char *dir) noexcept {
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: ls failed"));
|
||||
for (auto &p : di) {
|
||||
auto u8p = p.path().filename().u8string();
|
||||
out.emplace_back(ox::bit_cast<const char*>(u8p.c_str()));
|
||||
out.emplace_back(bit_cast<const char*>(u8p.c_str()));
|
||||
}
|
||||
return ox::move(out);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class PassThroughFS: public FileSystem {
|
||||
~PassThroughFS();
|
||||
|
||||
[[nodiscard]]
|
||||
ox::String basePath();
|
||||
String basePath();
|
||||
|
||||
Error mkdir(const char *path, bool recursive = false) noexcept override;
|
||||
|
||||
@ -95,7 +95,7 @@ Error PassThroughFS::ls(const char *dir, F cb) noexcept {
|
||||
oxReturnError(OxError(ec.value(), "PassThroughFS: ls failed"));
|
||||
for (auto &p : di) {
|
||||
auto u8p = p.path().filename().u8string();
|
||||
oxReturnError(cb(ox::bit_cast<const char*>(u8p.c_str()), 0));
|
||||
oxReturnError(cb(bit_cast<const char*>(u8p.c_str()), 0));
|
||||
}
|
||||
return OxError(0);
|
||||
}
|
||||
|
12
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
12
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
@ -20,9 +20,9 @@ class OX_PACKED NodeBuffer {
|
||||
|
||||
public:
|
||||
struct OX_PACKED Header {
|
||||
ox::LittleEndian<size_t> size = sizeof(Header); // capacity
|
||||
ox::LittleEndian<size_t> bytesUsed = sizeof(Header);
|
||||
ox::LittleEndian<size_t> firstItem = 0;
|
||||
LittleEndian<size_t> size = sizeof(Header); // capacity
|
||||
LittleEndian<size_t> bytesUsed = sizeof(Header);
|
||||
LittleEndian<size_t> firstItem = 0;
|
||||
};
|
||||
|
||||
using ItemPtr = Ptr<Item, size_t, sizeof(Header)>;
|
||||
@ -435,11 +435,11 @@ uint8_t *NodeBuffer<size_t, Item>::data() noexcept {
|
||||
template<typename size_t>
|
||||
struct OX_PACKED Item {
|
||||
public:
|
||||
ox::LittleEndian<size_t> prev = 0;
|
||||
ox::LittleEndian<size_t> next = 0;
|
||||
LittleEndian<size_t> prev = 0;
|
||||
LittleEndian<size_t> next = 0;
|
||||
|
||||
private:
|
||||
ox::LittleEndian<size_t> m_size = sizeof(Item);
|
||||
LittleEndian<size_t> m_size = sizeof(Item);
|
||||
|
||||
public:
|
||||
size_t size() const {
|
||||
|
2
deps/ox/src/ox/model/desctypes.hpp
vendored
2
deps/ox/src/ox/model/desctypes.hpp
vendored
@ -179,6 +179,6 @@ Error modelRead(T *io, DescriptorField *field) {
|
||||
return err;
|
||||
}
|
||||
|
||||
using TypeStore = ox::HashMap<ModelString, DescriptorType*>;
|
||||
using TypeStore = HashMap<ModelString, DescriptorType*>;
|
||||
|
||||
}
|
||||
|
2
deps/ox/src/ox/model/descwrite.hpp
vendored
2
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -145,7 +145,7 @@ class TypeDescWriter {
|
||||
template<typename T>
|
||||
Error TypeDescWriter::field(const char *name, T *val, std::size_t) {
|
||||
if (m_type) {
|
||||
constexpr typename ox::remove_pointer<decltype(val)>::type *p = nullptr;
|
||||
constexpr typename remove_pointer<decltype(val)>::type *p = nullptr;
|
||||
bool alreadyExisted = false;
|
||||
const auto t = type(p, &alreadyExisted);
|
||||
oxAssert(t != nullptr, "field(const char *name, T *val, std::size_t): Type not found or generated");
|
||||
|
6
deps/ox/src/ox/model/optype.hpp
vendored
6
deps/ox/src/ox/model/optype.hpp
vendored
@ -40,11 +40,11 @@ constexpr Error modelWriteDefinition(T*, O*) {
|
||||
template<typename T, typename O>
|
||||
constexpr Error model(T *io, O *obj) {
|
||||
Error err;
|
||||
if constexpr(ox_strcmp(T::opType(), ox::OpType::Read) == 0) {
|
||||
if constexpr(ox_strcmp(T::opType(), OpType::Read) == 0) {
|
||||
err = modelRead(io, obj);
|
||||
} else if constexpr(ox_strcmp(T::opType(), ox::OpType::Write) == 0) {
|
||||
} else if constexpr(ox_strcmp(T::opType(), OpType::Write) == 0) {
|
||||
err = modelWrite(io, obj);
|
||||
} else if constexpr(ox_strcmp(T::opType(), ox::OpType::WriteDefinition) == 0) {
|
||||
} else if constexpr(ox_strcmp(T::opType(), OpType::WriteDefinition) == 0) {
|
||||
err = modelWriteDefinition(io, obj);
|
||||
}
|
||||
oxAssert(err, "Missing model function");
|
||||
|
6
deps/ox/src/ox/model/types.hpp
vendored
6
deps/ox/src/ox/model/types.hpp
vendored
@ -60,7 +60,7 @@ class SerStr {
|
||||
|
||||
public:
|
||||
template<std::size_t sz>
|
||||
constexpr SerStr(BString<sz> *str) noexcept {
|
||||
explicit constexpr SerStr(BString<sz> *str) noexcept {
|
||||
m_str = str->data();
|
||||
m_cap = str->cap();
|
||||
}
|
||||
@ -70,14 +70,14 @@ class SerStr {
|
||||
m_cap = cap;
|
||||
}
|
||||
|
||||
constexpr SerStr(char **tgt, int cap = -1) noexcept {
|
||||
explicit constexpr SerStr(char **tgt, int cap = -1) noexcept {
|
||||
m_tgt = tgt;
|
||||
m_str = const_cast<char*>(*tgt);
|
||||
m_cap = cap;
|
||||
}
|
||||
|
||||
template<std::size_t cap>
|
||||
constexpr SerStr(char (&str)[cap]) noexcept {
|
||||
explicit constexpr SerStr(char (&str)[cap]) noexcept {
|
||||
m_str = str;
|
||||
m_cap = cap;
|
||||
}
|
||||
|
28
deps/ox/src/ox/std/byteswap.hpp
vendored
28
deps/ox/src/ox/std/byteswap.hpp
vendored
@ -75,7 +75,7 @@ class OX_PACKED ByteSwapInteger {
|
||||
m_value = other.m_value;
|
||||
}
|
||||
|
||||
constexpr ByteSwapInteger(T value) noexcept: m_value(ox::conditionalByteSwap<T, byteSwap>(value)) {
|
||||
constexpr ByteSwapInteger(T value) noexcept: m_value(conditionalByteSwap<T, byteSwap>(value)) {
|
||||
}
|
||||
|
||||
constexpr const ByteSwapInteger &operator=(const ByteSwapInteger &other) noexcept {
|
||||
@ -85,39 +85,39 @@ class OX_PACKED ByteSwapInteger {
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator=(I value) noexcept {
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(value);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
constexpr operator T() const noexcept {
|
||||
return ox::conditionalByteSwap<T, byteSwap>(m_value);
|
||||
return conditionalByteSwap<T, byteSwap>(m_value);
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator+=(I other) noexcept {
|
||||
auto newVal = *this + other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator-=(I other) noexcept {
|
||||
auto newVal = *this - other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator*=(I other) noexcept {
|
||||
auto newVal = *this * other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator/=(I other) noexcept {
|
||||
auto newVal = *this / other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
@ -148,35 +148,35 @@ class OX_PACKED ByteSwapInteger {
|
||||
template<typename I>
|
||||
constexpr T operator&=(I other) noexcept {
|
||||
auto newVal = *this & other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator|=(I other) noexcept {
|
||||
auto newVal = *this | other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator^=(I other) noexcept {
|
||||
auto newVal = *this ^ other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator>>=(I other) noexcept {
|
||||
auto newVal = *this >> other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
template<typename I>
|
||||
constexpr T operator<<=(I other) noexcept {
|
||||
auto newVal = *this << other;
|
||||
m_value = ox::conditionalByteSwap<T, byteSwap>(newVal);
|
||||
m_value = conditionalByteSwap<T, byteSwap>(newVal);
|
||||
return newVal;
|
||||
}
|
||||
|
||||
@ -198,9 +198,9 @@ class OX_PACKED ByteSwapInteger {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using LittleEndian = ByteSwapInteger<T, ox::defines::BigEndian>;
|
||||
using LittleEndian = ByteSwapInteger<T, defines::BigEndian>;
|
||||
|
||||
template<typename T>
|
||||
using BigEndian = ByteSwapInteger<T, ox::defines::LittleEndian>;
|
||||
using BigEndian = ByteSwapInteger<T, defines::LittleEndian>;
|
||||
|
||||
}
|
||||
|
6
deps/ox/src/ox/std/error.hpp
vendored
6
deps/ox/src/ox/std/error.hpp
vendored
@ -59,7 +59,7 @@ struct [[nodiscard]] Error {
|
||||
template<typename T>
|
||||
struct [[nodiscard]] Result {
|
||||
|
||||
using type = typename ox::remove_reference<T>::type;
|
||||
using type = typename remove_reference<T>::type;
|
||||
|
||||
T value;
|
||||
Error error;
|
||||
@ -73,7 +73,7 @@ struct [[nodiscard]] Result {
|
||||
constexpr Result(const type &value, const Error &error = OxError(0)) noexcept: value(const_cast<type&>(value)), error(error) {
|
||||
}
|
||||
|
||||
constexpr Result(type &&value, const Error &error = OxError(0)) noexcept: value(ox::move(value)), error(error) {
|
||||
constexpr Result(type &&value, const Error &error = OxError(0)) noexcept: value(move(value)), error(error) {
|
||||
}
|
||||
|
||||
explicit constexpr operator const type&() const noexcept {
|
||||
@ -100,7 +100,7 @@ struct [[nodiscard]] Result {
|
||||
}
|
||||
|
||||
constexpr Error moveTo(type *val) noexcept {
|
||||
*val = ox::move(value);
|
||||
*val = move(value);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
4
deps/ox/src/ox/std/fmt.hpp
vendored
4
deps/ox/src/ox/std/fmt.hpp
vendored
@ -29,11 +29,11 @@ constexpr const char *stringify(const char *s) noexcept {
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr const char *stringify(const ox::BString<size> &s) noexcept {
|
||||
constexpr const char *stringify(const BString<size> &s) noexcept {
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
constexpr const char *stringify(const ox::String &s) noexcept {
|
||||
constexpr const char *stringify(const String &s) noexcept {
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
|
8
deps/ox/src/ox/std/hashmap.hpp
vendored
8
deps/ox/src/ox/std/hashmap.hpp
vendored
@ -96,8 +96,8 @@ HashMap<K, T>::HashMap(const HashMap<K, T> &other) {
|
||||
|
||||
template<typename K, typename T>
|
||||
HashMap<K, T>::HashMap(HashMap<K, T> &&other) {
|
||||
m_keys = ox::move(other.m_keys);
|
||||
m_pairs = ox::move(other.m_pairs);
|
||||
m_keys = move(other.m_keys);
|
||||
m_pairs = move(other.m_pairs);
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
@ -133,8 +133,8 @@ template<typename K, typename T>
|
||||
HashMap<K, T> &HashMap<K, T>::operator=(HashMap<K, T> &&other) {
|
||||
if (this != &other) {
|
||||
clear();
|
||||
m_keys = ox::move(other.m_keys);
|
||||
m_pairs = ox::move(other.m_pairs);
|
||||
m_keys = move(other.m_keys);
|
||||
m_pairs = move(other.m_pairs);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
16
deps/ox/src/ox/std/heapmgr.cpp
vendored
16
deps/ox/src/ox/std/heapmgr.cpp
vendored
@ -25,29 +25,29 @@ static constexpr std::size_t alignedSize(T = {}) noexcept {
|
||||
return alignedSize(sizeof(T));
|
||||
}
|
||||
|
||||
void HeapSegment::init(std::size_t maxSize = ox::bit_cast<std::size_t>(g_heapEnd)) noexcept {
|
||||
this->size = maxSize - ox::bit_cast<std::size_t>(this);
|
||||
void HeapSegment::init(std::size_t maxSize = bit_cast<std::size_t>(g_heapEnd)) noexcept {
|
||||
this->size = maxSize - bit_cast<std::size_t>(this);
|
||||
this->inUse = false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *HeapSegment::data() noexcept {
|
||||
return ox::bit_cast<T*>(ox::bit_cast<uint8_t*>(this) + alignedSize(this));
|
||||
return bit_cast<T*>(bit_cast<uint8_t*>(this) + alignedSize(this));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *HeapSegment::end() noexcept {
|
||||
const auto size = alignedSize(this) + alignedSize(this->size);
|
||||
auto e = ox::bit_cast<uintptr_t>(ox::bit_cast<uint8_t*>(this) + size);
|
||||
return ox::bit_cast<T*>(e);
|
||||
auto e = bit_cast<uintptr_t>(bit_cast<uint8_t*>(this) + size);
|
||||
return bit_cast<T*>(e);
|
||||
}
|
||||
|
||||
|
||||
void initHeap(char *heapBegin, char *heapEnd) noexcept {
|
||||
g_heapBegin = ox::bit_cast<HeapSegment*>(heapBegin);
|
||||
g_heapEnd = ox::bit_cast<HeapSegment*>(heapEnd);
|
||||
g_heapBegin = bit_cast<HeapSegment*>(heapBegin);
|
||||
g_heapEnd = bit_cast<HeapSegment*>(heapEnd);
|
||||
heapIdx = g_heapBegin;
|
||||
heapIdx->size = ox::bit_cast<std::size_t>(heapEnd) - ox::bit_cast<std::size_t>(heapIdx);
|
||||
heapIdx->size = bit_cast<std::size_t>(heapEnd) - bit_cast<std::size_t>(heapIdx);
|
||||
heapIdx->inUse = false;
|
||||
}
|
||||
|
||||
|
2
deps/ox/src/ox/std/new.hpp
vendored
2
deps/ox/src/ox/std/new.hpp
vendored
@ -46,7 +46,7 @@ constexpr void *operator new[](std::size_t, void *addr) noexcept {
|
||||
|
||||
namespace ox {
|
||||
|
||||
constexpr auto MallocaStackLimit = ox::defines::UseStdLib ? 1024 : 0;
|
||||
constexpr auto MallocaStackLimit = defines::UseStdLib ? 1024 : 0;
|
||||
|
||||
/**
|
||||
* MallocaPtr will automatically cleanup the pointed to address upon
|
||||
|
4
deps/ox/src/ox/std/random.cpp
vendored
4
deps/ox/src/ox/std/random.cpp
vendored
@ -28,8 +28,8 @@ uint64_t Random::gen() noexcept {
|
||||
auto retval = s0 + s1;
|
||||
|
||||
s1 ^= s0;
|
||||
m_seed[0] = ox::rotl(s0, 55) ^ s1 ^ (s1 << 14);
|
||||
m_seed[1] = ox::rotl(s1, 36);
|
||||
m_seed[0] = rotl(s0, 55) ^ s1 ^ (s1 << 14);
|
||||
m_seed[1] = rotl(s1, 36);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
4
deps/ox/src/ox/std/string.cpp
vendored
4
deps/ox/src/ox/std/string.cpp
vendored
@ -44,7 +44,7 @@ String::String(const String &other) noexcept {
|
||||
}
|
||||
|
||||
String::String(String &&other) noexcept {
|
||||
m_buff = ox::move(other.m_buff);
|
||||
m_buff = move(other.m_buff);
|
||||
}
|
||||
|
||||
String &String::operator=(const char *str) noexcept {
|
||||
@ -80,7 +80,7 @@ String &String::operator=(const String &src) noexcept {
|
||||
}
|
||||
|
||||
String &String::operator=(String &&src) noexcept {
|
||||
m_buff = ox::move(src.m_buff);
|
||||
m_buff = move(src.m_buff);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
4
deps/ox/src/ox/std/trace.hpp
vendored
4
deps/ox/src/ox/std/trace.hpp
vendored
@ -34,11 +34,11 @@ struct TraceMsg {
|
||||
int line = 0;
|
||||
uint64_t time = 0;
|
||||
const char *ch = "";
|
||||
ox::BString<100> msg;
|
||||
BString<100> msg;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, ox::trace::TraceMsg *obj) {
|
||||
constexpr Error model(T *io, TraceMsg *obj) {
|
||||
io->template setTypeInfo<TraceMsg>();
|
||||
oxReturnError(io->field("ch", &obj->ch));
|
||||
oxReturnError(io->field("file", &obj->file));
|
||||
|
54
deps/ox/src/ox/std/typetraits.hpp
vendored
54
deps/ox/src/ox/std/typetraits.hpp
vendored
@ -45,42 +45,42 @@ struct integral_constant {
|
||||
|
||||
};
|
||||
|
||||
using false_type = ox::integral_constant<bool, false>;
|
||||
using true_type = ox::integral_constant<bool, true>;
|
||||
using false_type = integral_constant<bool, false>;
|
||||
using true_type = integral_constant<bool, true>;
|
||||
|
||||
|
||||
// is_integral /////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T> struct is_integral: ox::false_type {};
|
||||
template<> struct is_integral<bool> : ox::true_type {};
|
||||
template<> struct is_integral<wchar_t> : ox::true_type {};
|
||||
template<> struct is_integral<int8_t> : ox::true_type {};
|
||||
template<> struct is_integral<uint8_t> : ox::true_type {};
|
||||
template<> struct is_integral<int16_t> : ox::true_type {};
|
||||
template<> struct is_integral<uint16_t>: ox::true_type {};
|
||||
template<> struct is_integral<int32_t> : ox::true_type {};
|
||||
template<> struct is_integral<uint32_t>: ox::true_type {};
|
||||
template<typename T> struct is_integral: false_type {};
|
||||
template<> struct is_integral<bool> : true_type {};
|
||||
template<> struct is_integral<wchar_t> : true_type {};
|
||||
template<> struct is_integral<int8_t> : true_type {};
|
||||
template<> struct is_integral<uint8_t> : true_type {};
|
||||
template<> struct is_integral<int16_t> : true_type {};
|
||||
template<> struct is_integral<uint16_t>: true_type {};
|
||||
template<> struct is_integral<int32_t> : true_type {};
|
||||
template<> struct is_integral<uint32_t>: true_type {};
|
||||
|
||||
// some of these need to be done with the actual language syntax because no one
|
||||
// can agree on what an (u)int64_t is...
|
||||
template<> struct is_integral<long>: ox::true_type {};
|
||||
template<> struct is_integral<long long>: ox::true_type {};
|
||||
template<> struct is_integral<unsigned long>: ox::true_type {};
|
||||
template<> struct is_integral<unsigned long long>: ox::true_type {};
|
||||
template<> struct is_integral<long>: true_type {};
|
||||
template<> struct is_integral<long long>: true_type {};
|
||||
template<> struct is_integral<unsigned long>: true_type {};
|
||||
template<> struct is_integral<unsigned long long>: true_type {};
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_integral_v = ox::is_integral<T>::value;
|
||||
constexpr bool is_integral_v = is_integral<T>::value;
|
||||
|
||||
template<typename T> struct is_bool: ox::false_type {};
|
||||
template<> struct is_bool<bool> : ox::true_type {};
|
||||
template<typename T> struct is_bool: false_type {};
|
||||
template<> struct is_bool<bool> : true_type {};
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_bool_v = ox::is_bool<T>::value;
|
||||
constexpr bool is_bool_v = is_bool<T>::value;
|
||||
|
||||
template<typename T> struct is_union: ox::integral_constant<bool, std::is_union_v<T>> {};
|
||||
template<typename T> struct is_union: integral_constant<bool, std::is_union_v<T>> {};
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_union_v = ox::is_union<T>();
|
||||
constexpr bool is_union_v = is_union<T>();
|
||||
|
||||
// indicates the type can have members, but not that it necessarily does
|
||||
template<typename T>
|
||||
@ -89,21 +89,21 @@ template<typename T>
|
||||
constexpr bool memberable(...) { return false; }
|
||||
|
||||
template<typename T>
|
||||
struct is_class: ox::integral_constant<bool, !ox::is_union<T>::value && ox::memberable<T>(0)> {};
|
||||
struct is_class: integral_constant<bool, !is_union<T>::value && memberable<T>(0)> {};
|
||||
|
||||
namespace test {
|
||||
struct TestClass {int i;};
|
||||
union TestUnion {int i;};
|
||||
static_assert(ox::is_class<TestClass>::value == true);
|
||||
static_assert(ox::is_class<TestUnion>::value == false);
|
||||
static_assert(ox::is_class<int>::value == false);
|
||||
static_assert(is_class<TestClass>::value == true);
|
||||
static_assert(is_class<TestUnion>::value == false);
|
||||
static_assert(is_class<int>::value == false);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_class_v = ox::is_class<T>();
|
||||
constexpr bool is_class_v = is_class<T>();
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_signed_v = ox::integral_constant<bool, T(-1) < T(0)>::value;
|
||||
constexpr bool is_signed_v = integral_constant<bool, T(-1) < T(0)>::value;
|
||||
|
||||
// enable_if ///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
4
deps/ox/src/ox/std/utility.hpp
vendored
4
deps/ox/src/ox/std/utility.hpp
vendored
@ -13,8 +13,8 @@
|
||||
namespace ox {
|
||||
|
||||
template<typename T>
|
||||
constexpr typename ox::remove_reference<T>::type &&move(T &&t) noexcept {
|
||||
return static_cast<typename ox::remove_reference<T>::type&&>(t);
|
||||
constexpr typename remove_reference<T>::type &&move(T &&t) noexcept {
|
||||
return static_cast<typename remove_reference<T>::type&&>(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
12
deps/ox/src/ox/std/vector.hpp
vendored
12
deps/ox/src/ox/std/vector.hpp
vendored
@ -124,7 +124,7 @@ Vector<T>::Vector(const Vector<T> &other) {
|
||||
m_cap = other.m_cap;
|
||||
m_items = bit_cast<T*>(new AllocAlias<T>[m_cap]);
|
||||
for (std::size_t i = 0; i < m_size; i++) {
|
||||
m_items[i] = ox::move(other.m_items[i]);
|
||||
m_items[i] = move(other.m_items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ bool Vector<T>::empty() const noexcept {
|
||||
|
||||
template<typename T>
|
||||
void Vector<T>::clear() {
|
||||
if constexpr(ox::is_class<T>()) {
|
||||
if constexpr(is_class<T>()) {
|
||||
for (std::size_t i = 0; i < m_size; ++i) {
|
||||
m_items[i].~T();
|
||||
}
|
||||
@ -288,7 +288,7 @@ void Vector<T>::insert(std::size_t pos, const T &val) {
|
||||
expandCap(m_cap ? m_cap * 2 : 100);
|
||||
}
|
||||
for (auto i = m_size; i > pos; --i) {
|
||||
m_items[i] = ox::move(m_items[i - 1]);
|
||||
m_items[i] = move(m_items[i - 1]);
|
||||
}
|
||||
m_items[pos] = val;
|
||||
++m_size;
|
||||
@ -326,7 +326,7 @@ Error Vector<T>::erase(std::size_t pos) {
|
||||
}
|
||||
--m_size;
|
||||
for (auto i = pos; i < m_size; ++i) {
|
||||
m_items[i] = ox::move(m_items[i + 1]);
|
||||
m_items[i] = move(m_items[i + 1]);
|
||||
}
|
||||
return OxError(0);
|
||||
}
|
||||
@ -337,7 +337,7 @@ Error Vector<T>::unordered_erase(std::size_t pos) {
|
||||
return OxError(1);
|
||||
}
|
||||
m_size--;
|
||||
m_items[pos] = ox::move(m_items[m_size]);
|
||||
m_items[pos] = move(m_items[m_size]);
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
@ -349,7 +349,7 @@ void Vector<T>::expandCap(std::size_t cap) {
|
||||
if (oldItems) { // move over old items
|
||||
const auto itRange = cap > m_size ? m_size : cap;
|
||||
for (std::size_t i = 0; i < itRange; i++) {
|
||||
m_items[i] = ox::move(oldItems[i]);
|
||||
m_items[i] = move(oldItems[i]);
|
||||
}
|
||||
for (std::size_t i = itRange; i < m_cap; i++) {
|
||||
new (&m_items[i]) T;
|
||||
|
Loading…
Reference in New Issue
Block a user