Files
Luke Street 2c46a69188 CMorphBall & link RMathUtils (#44)
* Update tool versions

* Initial CMorphBall

* Cleanup CMorphBall, link RMathUtils

* Rematch a couple symbols

* Fix _01 DolphinCGraphics .sdata size regression
2026-03-17 00:10:26 -06:00

56 lines
1.1 KiB
C++

#ifndef _RSTL_CONSTRUCT
#define _RSTL_CONSTRUCT
#include "types.h"
#include "Kyoto/Alloc/CMemory.hpp"
namespace rstl {
template < typename T >
static inline void construct(void* dest, const T& src) {
new (dest) T(src);
}
template < typename T >
static inline void destroy(T* in) {
in->~T();
}
template < typename It >
static inline void destroy(It begin, It end) {
It cur = begin;
for (; cur != end; ++cur) {
destroy(&*cur);
}
}
template < typename It, typename T >
static inline T uninitialized_copy(It begin, It end, T out) {
T tmp = out;
It cur = begin;
for (; cur != end; ++tmp, ++cur) {
construct(tmp, *cur);
}
return tmp;
}
template < typename S, typename D >
static inline void uninitialized_copy_n(S src, int n, D dest) {
D cur = dest;
for (int i = 0; i < n; ++cur, ++i, ++src) {
construct(&*cur, *src);
}
}
template < typename D, typename S >
static inline void uninitialized_fill_n(D dest, int n, const S& value) {
D cur = dest;
for (int i = 0; i < n; ++i, ++cur) {
construct(&*cur, value);
}
}
} // namespace rstl
#endif // _RSTL_CONSTRUCT