[ox/mc] Add def writer
This commit is contained in:
2
deps/ox/src/ox/std/CMakeLists.txt
vendored
2
deps/ox/src/ox/std/CMakeLists.txt
vendored
@@ -17,6 +17,8 @@ set_property(
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
||||
target_link_libraries(OxStd PUBLIC OxTrace)
|
||||
|
||||
install(
|
||||
FILES
|
||||
assert.hpp
|
||||
|
17
deps/ox/src/ox/std/hashmap.hpp
vendored
17
deps/ox/src/ox/std/hashmap.hpp
vendored
@@ -38,6 +38,13 @@ class HashMap {
|
||||
*/
|
||||
T &operator[](K key) noexcept;
|
||||
|
||||
/**
|
||||
* K is assumed to be a null terminated string.
|
||||
*/
|
||||
T &at(K key) noexcept;
|
||||
|
||||
bool contains(K key) noexcept;
|
||||
|
||||
std::size_t size() const noexcept;
|
||||
|
||||
private:
|
||||
@@ -93,6 +100,16 @@ T &HashMap<K, T>::operator[](K k) noexcept {
|
||||
return p->value;
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
T &HashMap<K, T>::at(K k) noexcept {
|
||||
return operator[](k);
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
bool HashMap<K, T>::contains(K k) noexcept {
|
||||
return access(m_pairs, k) != nullptr;
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
std::size_t HashMap<K, T>::size() const noexcept {
|
||||
return m_keys.size();
|
||||
|
1
deps/ox/src/ox/std/std.hpp
vendored
1
deps/ox/src/ox/std/std.hpp
vendored
@@ -21,6 +21,7 @@
|
||||
#include "stddef.hpp"
|
||||
#include "strops.hpp"
|
||||
#include "string.hpp"
|
||||
#include "typeinfo.hpp"
|
||||
#include "types.hpp"
|
||||
#include "typetraits.hpp"
|
||||
#include "vector.hpp"
|
||||
|
34
deps/ox/src/ox/std/typeinfo.hpp
vendored
Normal file
34
deps/ox/src/ox/std/typeinfo.hpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2015 - 2018 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<typeinfo>)
|
||||
#include <typeinfo>
|
||||
#else
|
||||
|
||||
namespace std {
|
||||
|
||||
// this is not at all guaranteed to work, and does not even fully comply with
|
||||
// what little the standard does define
|
||||
struct type_info {
|
||||
private:
|
||||
const char *m_name = "";
|
||||
|
||||
protected:
|
||||
explicit type_info(const char *name): m_name(name) {
|
||||
}
|
||||
|
||||
const char *name() {
|
||||
return m_name;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
19
deps/ox/src/ox/std/typetraits.hpp
vendored
19
deps/ox/src/ox/std/typetraits.hpp
vendored
@@ -60,4 +60,23 @@ struct enable_if<true, T> {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct RemoveIndirection {
|
||||
|
||||
private:
|
||||
template<typename ST>
|
||||
static constexpr ST decay(ST t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
template<typename ST>
|
||||
static constexpr ST decay(ST *t) {
|
||||
return decay(*t);
|
||||
}
|
||||
|
||||
public:
|
||||
using type = decltype(decay(static_cast<T*>(nullptr)));
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
2
deps/ox/src/ox/std/vector.hpp
vendored
2
deps/ox/src/ox/std/vector.hpp
vendored
@@ -197,7 +197,7 @@ void Vector<T>::expandCap(std::size_t cap) noexcept {
|
||||
m_items[i] = oldItems[i];
|
||||
}
|
||||
for (std::size_t i = itRange; i < m_cap; i++) {
|
||||
m_items[i] = {};
|
||||
m_items[i] = T();
|
||||
}
|
||||
delete[] oldItems;
|
||||
}
|
||||
|
Reference in New Issue
Block a user