J Reece Wilson
b29f8ebf21
[*] Preemptive linux/clang API fixes [*] Fix clang equiv MSVC template bug (they're nice enough to throw an error instead of crashing)
83 lines
1.9 KiB
C++
83 lines
1.9 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuroraUtils.hpp
|
|
File: auROXTLUtils.hpp
|
|
Date: 2021-6-9
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#if defined(__has_include)
|
|
#if __has_include(<intrin.h>) && defined(AURORA_PLATFORM_WIN32)
|
|
#include <intrin.h>
|
|
#endif
|
|
#if __has_include(<emmintrin.h>)
|
|
#include <emmintrin.h>
|
|
#endif
|
|
#if __has_include(<xmmintrin.h>)
|
|
#include <xmmintrin.h>
|
|
#endif
|
|
#if __has_include(<immintrin.h>)
|
|
#include <immintrin.h>
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(AURORA_ARCH_X64)
|
|
#include <nmmintrin.h>
|
|
#endif
|
|
|
|
// homeless :(
|
|
#if !defined(AURORA_RUNTIME_EXCHANGE)
|
|
#define AURORA_RUNTIME_EXCHANGE std::exchange
|
|
#endif
|
|
|
|
template<class T, class U = T>
|
|
T AuExchange(T &obj, U &&new_value)
|
|
{
|
|
return AURORA_RUNTIME_EXCHANGE(obj, new_value);
|
|
}
|
|
|
|
#include <auROXTL/auMemory.hpp>
|
|
#include <auROXTL/auCopyMoveUtils.hpp>
|
|
#include <auROXTL/auContainerUtils.hpp>
|
|
#include <auROXTL/auStringUtils.hpp>
|
|
#include <auROXTL/auTupleUtils.hpp>
|
|
#include <auROXTL/auNumberUtils.hpp>
|
|
#include <auROXTL/auEndianness.hpp>
|
|
#include <auROXTL/auAtomic.hpp>
|
|
#include <auROXTL/auBitsUtils.hpp>
|
|
#include <auROXTL/auMagicUtils.hpp>
|
|
#include <auROXTL/auWin32Utils.hpp>
|
|
#include <auROXTL/auCastUtils.hpp>
|
|
#include <auROXTL/auTypeUtils.hpp>
|
|
#include <auROXTL/auNumericLimits.hpp>
|
|
#include <auROXTL/auUnitUtils.hpp>
|
|
|
|
|
|
struct IAuNullDelegate
|
|
{
|
|
virtual void OnCall() = 0;
|
|
};
|
|
|
|
struct AuNullCallback
|
|
{
|
|
const AuVoidFunc voidFunc;
|
|
const AuSPtr<IAuNullDelegate> callbackFunc;
|
|
|
|
AU_DEFINE_CTOR_ONE(AuNullCallback, (AuVoidFunc, voidFunc));
|
|
AU_DEFINE_CTOR_ONE(AuNullCallback, (AuSPtr<IAuNullDelegate>, callbackFunc));
|
|
|
|
auline void operator()()
|
|
{
|
|
if (voidFunc)
|
|
{
|
|
voidFunc();
|
|
}
|
|
else if (callbackFunc)
|
|
{
|
|
callbackFunc->OnCall();
|
|
}
|
|
}
|
|
};
|