[ox/std] Add std::allocator
This commit is contained in:
parent
2bcea545f5
commit
6bee2d12d7
25
deps/ox/src/ox/std/memory.hpp
vendored
25
deps/ox/src/ox/std/memory.hpp
vendored
@ -8,8 +8,33 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __has_include(<memory>)
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct allocator {
|
||||||
|
[[nodiscard]]
|
||||||
|
constexpr T *allocate(size_t n) {
|
||||||
|
return static_cast<T*>(::operator new(n * sizeof(T)));
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr void deallocate(T *p, std::size_t) {
|
||||||
|
::operator delete(p);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user