blob: 9a6194a90ad0de9c0f3dcc7a22cd559b98b5bda1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#pragma once
#include "nes/common/types.hh"
namespace nes
{
template<typename T>
auto launder(T* p) -> T*
{
return __builtin_launder(p);
}
template<typename T>
auto copy(T const* src, T* dst, u32 const length)
{
for (auto i = u32{ 0 }; i < length; ++i) { dst[i] = src[i]; }
}
template<typename T>
auto min(T const a, T const b)
{
return a < b ? a : b;
}
template<typename T>
auto max(T const a, T const b)
{
return a > b ? a : b;
}
template<typename T>
auto swap(T& a, T& b) -> void
{
auto const tmp = a;
a = b;
b = tmp;
}
} // namespace nes
#ifdef NES_HAS_STDLIB
#include <new>
#else
// Placement new is an API-defined operator for some reason!?
inline void* operator new(decltype(sizeof(int)), void* ptr) { return ptr; }
#endif
|