This commit is contained in:
Reece Wilson 2022-04-01 05:03:03 +01:00
parent a4568be6fa
commit 7e1bf30131
50 changed files with 2 additions and 5122 deletions

View File

@ -7,8 +7,8 @@
"staticImpDefines": "AURORA_ENGINE_KERNEL_STATIC", "staticImpDefines": "AURORA_ENGINE_KERNEL_STATIC",
"defines": [], "defines": [],
"soft-depends": ["wxwidgets", "glm", "bzip2", "lz4"], "soft-depends": ["wxwidgets", "glm", "bzip2", "lz4"],
"depends": ["AuroraInterfaces", "AuroraEnum", "mimalloc", "uuid", "fmt", "json", "ltc", "o1heap", "zstd", "zlib", "mbedtls"], "depends": ["auROXTL", "AuroraInterfaces", "AuroraEnum", "mimalloc", "uuid", "fmt", "json", "ltc", "o1heap", "zstd", "zlib", "mbedtls"],
"include-depends": ["fmt", "uuid", "AuroraInterfaces", "AuroraEnum"], "include-depends": ["fmt", "uuid", "AuroraInterfaces", "AuroraEnum", "auROXTL"],
"features": ["guess-platform-code"], "features": ["guess-platform-code"],
"linkSources": "Source/Alloc.cpp", "linkSources": "Source/Alloc.cpp",
"actions": [ "actions": [

View File

@ -1,32 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auROXTL.hpp
Date: 2022-2-2
Author: Reece
***/
#pragma once
#include <AuroraEnvironment.h>
#include <AuroraTypes.hpp>
#if defined(_AUHAS_AURORAENUM)
#include <AuroraForEach.hpp>
#include <AuroraInterfaces.hpp>
#include <AuroraEnum.hpp>
#endif
#if defined(_AUHAS_FMT)
#include <fmt/format.h>
#endif
#include "auROXTL/AU_Z.hpp"
#include "auROXTL/AU_MACROS.hpp"
#include "auROXTLTypes.hpp"
#if defined(_AUHAS_AURORAENUM)
#define _ALLOW_AURORA_ENUM_AUENVHPP
#include <AuroraCommon.hpp>
#endif
#include "auROXTLUtils.hpp"

View File

@ -1,190 +0,0 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuroraMacros.hpp
File: AU_MACROS.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
#define AU_COPY(type) type(const type&) = default; type &operator=(const type &) = default;
#define AU_MOVE(type) type(type&&) = default; type &operator=(type &&) = default;
#define AU_COPY_MOVE(type) AU_COPY(type) AU_MOVE(type)
#define AU_NO_COPY(type) type(const type&) = delete;
#define AU_NO_MOVE(type) type(type&&) = delete;
#define AU_NO_COPY_NO_MOVE(type) AU_NO_COPY(type) AU_NO_MOVE(type)
#if !defined(AU_SHARED_FROM_THIS)
#define AU_SHARED_FROM_THIS (AuStaticPointerCast<AuRemovePointer_t<decltype(this)>>(this->SharedFromThis()))
#endif
#if !defined(AU_WEAK_FROM_THIS)
#define AU_WEAK_FROM_THIS (AuWPtr<AuRemovePointer_t<decltype(this)>>(AuStaticPointerCast<AuRemovePointer_t<decltype(this)>>(this->SharedFromThis())))
#endif
#define AU_BRACKET_SCOPE(...) __VA_ARGS__
#if !defined(AU_TEMPLATE_ENABLE_WHEN)
#define AU_TEMPLATE_ENABLE_WHEN(...) typename AuEnableIf<__VA_ARGS__>::type* = nullptr
#endif
#define AU_WHAT(n) n
/// @hideinitializer
#define _AU_STRINGIFY(in) #in
#define AU_STRINGIFY(in) _AU_STRINGIFY(in)
/// @hideinitializer
#define _AU_CONCAT(a, b) a ## b
#define AU_CONCAT(a, b) _AU_CONCAT(a, b)
/// @hideinitializer
#define _AUKCON_STRINGIFY_X(in) AU_STRINGIFY(in)
#if !defined(AU_SHARED_API_EX)
#define AU_SHARED_API_EX(vis, name, type, ...) \
\
vis type *name ## New(__VA_ARGS__); \
vis void name ## Release(type *); \
static inline void name ## Destroy(type *val) \
{ \
name ## Release(val); \
} \
\
struct CppDeleter ## name \
{ \
void operator()(type *t) \
{ \
name ## Release(t); \
} \
}; \
\
using name ## Unique_t = AURORA_RUNTIME_AU_UNIQUE_PTR<type, CppDeleter ## name>; \
template <class ... T> \
name ## Unique_t name ## Unique(T... args) \
{ \
return name ## Unique_t(name ## New(args...)); \
} \
\
using name ## Shared_t = AuSPtr<type>; \
template <class ... T> \
name ## Shared_t name ## Shared(T... args) \
{ \
return name ## Shared_t(name ## New(args...), name ## Release); \
}
#endif
#if !defined(AU_SHARED_API)
#define AU_SHARED_API(name, type, ...) AU_SHARED_API_EX(, name, type, #__VA_ARGS__)
#endif
#if !defined(AU_NOINLINE)
#if defined(AURORA_COMPILER_MSVC)
#define AU_NOINLINE __declspec(noinline)
#else
#define AU_NOINLINE __attribute__((noinline))
#endif
#endif
#if !defined(AU_INLINE)
#if defined(AURORA_COMPILER_MSVC)
#define AU_INLINE __forceinline
#else
#define AU_INLINE __attribute__((always_inline))
#endif
#endif
#if !defined(AU_NORETURN)
#if defined(AURORA_COMPILER_MSVC)
#define AU_NORETURN __declspec(noreturn)
#elif (defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC))
#define AU_NORETURN __attribute__((noreturn))
#elif defined(AU_LANG_CPP)
#define AU_NORETURN [[noreturn]]
#else
#define AU_NORETURN
#endif
#endif
#if !defined(AU_ALLOC)
#if defined(AURORA_PLATFORM_WIN32)
#define AU_ALLOC __declspec(allocator)
#elif defined(AURORA_COMPILER_CLANG)
#define AU_ALLOC __declspec(allocator)
#elif defined(AURORA_COMPILER_GCC)
#define AU_ALLOC __attribute__((malloc))
#else
#define AU_ALLOC
#endif
#endif
#if !defined(NO__NEW)
#if !defined(_new)
#define _new new (std::nothrow)
#endif
#endif
#if !defined(NO__INLINE)
#if !defined(auline)
#define auline AU_INLINE
#endif
#endif
#if !defined(AU_FWD)
#define AU_FWD(var) AuForward<decltype(var)>(var)
#endif
#if !defined(AU_THROW_STRING)
#define AU_THROW_STRING(var) throw AuString(var)
#endif
#define AU_ITERATE_ARRAY(index, arry) AuUInt index = 0; index < AuArraySize(arry); index++
#define AU_ITERATE_N(index, n) AuUInt index = 0; index < n; index++
#define AU_ITERATE_N_TO_X(index, n, x) AuUInt index = n; index < x; index++
#define AU_ITERATE_BACKWARDS(index, lastIdx) AuUInt index = lastIdx; index <= 0; index--
#define AU_ITR_ARRAY AU_ITERATE_ARRAY
#define AU_ITR_N AU_ITERATE_N
#define AU_ITR_N_TO_X AU_ITERATE_N_TO_X
#define AU_ITR_BACKWARDS AU_ITERATE_BACKWARDS
#define AU_STRIP_BRACKETS_IMPL(...) __VA_ARGS__
#if !defined(AU_STRIP_BRACKETS)
#define AU_STRIP_BRACKETS(X) AU_WHAT(AU_STRIP_BRACKETS_IMPL X)
#endif
#if !defined(AU_STRIP)
#define AU_STRIP AU_STRIP_BRACKETS
#endif
#if !defined(AU_EMIT_FIRST)
#define AU_EMIT_FIRST(a, b)a
#endif
#if !defined(AU_EMIT_SECOND)
#define AU_EMIT_SECOND(a, b)b
#endif
#if !defined(AU_EMIT_BOTH)
#define AU_EMIT_BOTH(a, b)a, a
#endif
#if !defined(AuBindThis)
#define AuBindThis(method, ...) std::bind(method, this, ## __VA_ARGS__)
#endif
#if !defined(AuSharedFromThis)
#define AuSharedFromThis() AU_SHARED_FROM_THIS
#endif
#if !defined(AuWeakFromThis)
#define AuWeakFromThis() AU_SHARED_FROM_THIS
#endif
#define AU_EMIT_FIRST_COMMA_FIRST(n)n
#define AU_EMIT_FIRST_COMMA_OTHERS(n),n
#include "Objects/Objects.hpp"

View File

@ -1,73 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AU_Z.hpp
Date: 2022-3-26
Author: Reece
***/
#pragma once
////////////////////////////////////////////////////////////////////////////////////////////////
// Exception model
////////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(AUROXTL_NO_TRY)
#define AUROXTL_COMMODITY_TRY try
#define AUROXTL_COMMODITY_CATCH catch (...)
#else
#define AUROXTL_COMMODITY_TRY
#define AUROXTL_COMMODITY_CATCH while (0)
#endif
////////////////////////////////////////////////////////////////////////////////////////////////
// Stinky container config (leave it alone)
////////////////////////////////////////////////////////////////////////////////////////////////
#if (!defined(AURORA_ENGINE_KERNEL) && \
!defined(_AUHAS_AURORARUNTIME))
// If we're in our ecosystem, assume global allocator override in all modules
// std::allocator __will__ be Aurora::memory backed no matter what
//
// Externally, however, the ABI of the type matters.
// > We want the differing ABI for std
// > We want customers' STLs' containers' move/copy semantics to apply
// > ...w/o copying between container types
//
// Therefore, `#if !defined(aurora)
// #define USE_STL //(for source compatibility)
// #endif `
#define AURORA_ROXTL_ALLOCATORS_USE_STD
#endif
#if defined(AURORA_ROXTL_ALLOCATORS_USE_STD)
// Crossing API boundaries will resort in an alloc + copy
// Don't enable unless you're in the ecosystem
// Default behaviour (omitted): use the exact std::string type
#define AURORA_ROXTL_CONTAINERS_USE_PURE
#endif
////////////////////////////////////////////////////////////////////////////////////////////////
// Memory, AuSPtr, and Friends
////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(AURORA_ROXTL_NULL_POINTER_CHECKS_DISABLED)
#define _AURORA_NULLEXPT_ENABLE_UB
#endif
#if defined(AURORA_ROXTL_NULL_POINTER_CHECKS_USE_COMPARE_OVER_INDIRECT_JMP)
#define _AURORA_NULLEXPT_BRANCH
#endif
#if defined(AURORA_ROXTL_NULL_POINTER_COMPARE_MODE_AGGRESSIVE)
#define _AURORA_NULLEXPT_BRANCH_BUG_CHECK
#endif
////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////
//#define _AURORA_NULLEXPT_USE_TRY_EMPLACE_AFTER_FIND

View File

@ -1,131 +0,0 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Objects.hpp
File: AuroraMacros.hpp
File: AU_MACROS.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
/*
AU_DEFINE_FOR_VA(Object,
(AU_DEFINE_CTOR_VA, // initializer-list-like ctor (extending a struct or adding a ctor will break initializer lists)
AU_DEFINE_THIS_MOVE_CTOR_VA, // add move `Object(Object &&)`
AU_DEFINE_EQUALS_VA, // add equals operator
AU_DEFINE_MOVE_VA, // add move assignment operator
AU_DEFINE_COPY_VA), // add copy assignment operator
(id, task));
*/
/// @hideinitializer
#define AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(variable) AuRemoveConst_t<AuRemoveReference_t<decltype(variable)>>
/// @hideinitializer
#define AU_EMIT_CTOR_CPY(pair) const AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &pair
/// @hideinitializer
#define AU_EMIT_CTOR_CPY_SECOND(pair) ,AU_EMIT_CTOR_CPY(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_MOV(pair) AU_EMIT_FIRST_TYPEREDUCED_PAIR_REDUCED(pair) &&pair
/// @hideinitializer
#define AU_EMIT_CTOR_MOV_SECOND(pair) ,AU_EMIT_CTOR_MOV(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN(pair) pair(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN2(pair) pair(cpy.pair)
/// @hideinitializer
#define AU_EMIT_CTOR_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN2(pair)
/// @hideinitializer
#define AU_EMIT_CTOR_MOVE_ASSIGN2(pair) pair(AuMove(cpy.pair))
/// @hideinitializer
#define AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_MOVE_ASSIGN2(pair)
/// @hideinitializer
#define AU_DEFINE_CTOR_VA_(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
/// @deprecated
#define AU_DEFINE_CTOR_ONE(thisType, pairTypeName) AU_DEFINE_CTOR_VA_(thisType, (AU_EMIT_SECOND pairTypeName))
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_A(name) this->name == ref.name
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_B(name) && AU_DEFINE_EQUALS_VA_A(name)
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_A(name) AuHashCode(this->name)
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_B(name) ^ AU_DEFINE_EQUALS_HASHCODE_A(name)
/// @hideinitializer
#define AU_DEFINE_MOVE_VA_A(name) this->name = AuMove(ref.name);
/// @hideinitializer
#define AU_DEFINE_MOVE_VA_B(name) AU_DEFINE_MOVE_VA_A(name)
/// @hideinitializer
#define AU_DEFINE_COPY_VA_A(name) this->name = ref.name;
/// @hideinitializer
#define AU_DEFINE_COPY_VA_B(name) AU_DEFINE_COPY_VA_A(name)
/// @hideinitializer
#define AU_DEFINE_CTOR_CPY_VA(thisType, args) \
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_CPY, AU_EMIT_CTOR_CPY_SECOND, AU_STRIP_BRACKETS(args))) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_CTOR_MOV_VA(thisType, args) \
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOV, AU_EMIT_CTOR_MOV_SECOND, AU_STRIP_BRACKETS(args))) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_THIS_COPY_CTOR_VA(thisType, args) \
inline thisType(const thisType &cpy) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN2, AU_EMIT_CTOR_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_THIS_MOVE_CTOR_VA(thisType, args) \
inline thisType(thisType &&cpy) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOVE_ASSIGN2, AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
{}
/// @hideinitializer
#define AU_DEFINE_FOR_VA_(pair, func) func(AU_EMIT_SECOND pair, AU_STRIP_BRACKETS(AU_EMIT_FIRST pair))
///
#define AU_DEFINE_HASHCODE_VA(thisType, args) AuUInt HashCode() const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_HASHCODE_A, AU_DEFINE_EQUALS_HASHCODE_B, AU_STRIP_BRACKETS(args)) ; }
///
#define AU_DEFINE_CTOR_VA(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
///
#define AU_DEFINE_EQUALS_VA(thisType, args) bool operator==(const thisType & ref) const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_VA_A, AU_DEFINE_EQUALS_VA_B, AU_STRIP_BRACKETS(args)) ; }
///
#define AU_DEFINE_MOVE_VA(thisType, args) thisType& operator=( thisType && ref) noexcept { AU_FOR_EACH_FIRST(AU_DEFINE_MOVE_VA_A, AU_DEFINE_MOVE_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
///
#define AU_DEFINE_COPY_VA(thisType, args) thisType& operator=(const thisType & ref) { AU_FOR_EACH_FIRST(AU_DEFINE_COPY_VA_A, AU_DEFINE_COPY_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
//
#define AU_DEFINE_FOR_VA(type, arry, members) AU_FOR_EACH_THAT(AU_DEFINE_FOR_VA_, ((members), type), AU_STRIP_BRACKETS(arry))

View File

@ -1,8 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ModuleApi.hpp
Date: 2022-3-31
Author: Reece
***/
#pragma once

View File

@ -1,11 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Objects.hpp
Date: 2022-3-31
Author: Reece
***/
#pragma once
#include "ClassHelpers.hpp"
#include "ModuleApi.hpp"

View File

@ -1,401 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ExtendStlLikeSharedPtr.hpp
Date: 2022-1-25
Author: Reece
***/
#pragma once
//#include <auROXTL/auCastUtils.hpp>
#include <auROXTL/auCopyMoveUtils.hpp>
namespace Aurora::Memory
{
inline void ThrowNullException();
namespace _detail
{
struct IPtrGet
{
virtual void *Get() = 0;
};
struct IPtrNoOpGet : IPtrGet
{
inline virtual void *Get() override
{
ThrowNullException();
return {};
}
};
inline IPtrNoOpGet gNoop;
}
template <class TType_t, class Base_t>
struct ExSharedPtr : Base_t
#if !defined(_AURORA_NULLEXPT_ENABLE_UB) && !defined(_AURORA_NULLEXPT_BRANCH)
, private _detail::IPtrGet
#endif
{
using element_type = typename Base_t::element_type;
using weak_type = typename Base_t::weak_type;
using base_type = Base_t;
using Base_t::Base_t;
ExSharedPtr() : Base_t()
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(Base_t &&in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(ExSharedPtr &&in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(const ExSharedPtr &in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template <class T_t, typename B_t>
ExSharedPtr(const ExSharedPtr<T_t, B_t> &in) : Base_t(in.BasePointerType(), static_cast<T_t *>(in.get()))
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template <class T_t, typename B_t>
ExSharedPtr(ExSharedPtr<T_t, B_t> &&in) : Base_t(in.BasePointerType(), static_cast<T_t *>(in.get()))
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template <class T_t, typename B_t>
ExSharedPtr(ExSharedPtr<T_t, B_t> &&in, element_type *ptr) : Base_t(AuMove(in.BasePointerType()), ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(Base_t &&in, element_type *ptr) : Base_t(in, ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template <class T_t, typename B_t>
ExSharedPtr(const ExSharedPtr<T_t, B_t> &in, element_type *ptr) : Base_t(in.BasePointerType(), ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(const Base_t &in, element_type *ptr) : Base_t(in, ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(const Base_t &in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template <class Y = element_type, class Deleter_t, class Alloc_t>
ExSharedPtr(Y *in, Deleter_t del, Alloc_t alloc) : Base_t(in, del, alloc)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template <class Y = element_type, class Deleter_t>
ExSharedPtr(Y *in, Deleter_t del) : Base_t(in, del)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template < class Y, class Deleter >
ExSharedPtr(AURORA_RUNTIME_AU_UNIQUE_PTR<Y, Deleter> &&r) : Base_t(r)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template <class T_t, typename B_t>
void swap(ExSharedPtr<T_t, B_t> &in)
{
Base_t::swap(in.BasePointerType());
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
void swap(Base_t &r)
{
Base_t::swap(r);
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
void reset()
{
Base_t::reset();
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
#if !defined(_AURORA_NULLEXPT_BRANCH)
ptr = &_detail::gNoop;
#endif
#endif
}
operator const Base_t &() const noexcept
{
return *this;
}
// required for move casts
operator Base_t &() noexcept
{
return *this;
}
const Base_t &BasePointerType() const noexcept
{
return *this;
}
Base_t &BasePointerType() noexcept
{
return *this;
}
operator bool() const noexcept
{
return Base_t::operator bool();
}
ExSharedPtr &operator =(const Base_t &in) noexcept
{
Base_t::operator=(in);
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
template <class T_t, typename B_t>
ExSharedPtr &operator =(ExSharedPtr<T_t, B_t> &&in) noexcept
{
Base_t::operator=(AuMove(in.BasePointerType()));
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
ExSharedPtr &operator =(Base_t &&in) noexcept
{
Base_t::operator=(in);
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
ExSharedPtr &operator =(const ExSharedPtr &in) noexcept
{
Base_t::operator=(in);
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
template <class T_t, typename B_t>
ExSharedPtr &operator =(const ExSharedPtr<T_t, B_t> &in) noexcept
{
Base_t::operator=(in.BasePointerType());
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
template <class TType2_t = TType_t>
TType2_t &operator*() const
{
return *operator->();
}
template <class TType2_t = TType_t>
TType2_t *operator->() const
{
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
return Base_t::operator->();
#elif !defined(_AURORA_NULLEXPT_BRANCH)
return reinterpret_cast<TType2_t *>(ptr->Get());
#else
throwif();
return Base_t::operator->();
#endif
}
template <class TType2_t = TType_t>
TType2_t &operator*()
{
return *operator->();
}
template <class TType2_t = TType_t>
TType2_t *operator->()
{
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
return Base_t::operator->();
#elif !defined(_AURORA_NULLEXPT_BRANCH)
return reinterpret_cast<TType2_t *>(ptr->Get());
#else
throwif();
return Base_t::operator->();
#endif
}
element_type *get() const
{
return Base_t::get();
}
#define ADD_OPERATOR(op) \
template <class T > \
bool operator op(const T &rhs) noexcept \
{ \
return static_cast<Base_t &>(*this) op(rhs); \
} \
\
template < class T > \
bool operator op(std::nullptr_t rhs) noexcept \
{ \
return static_cast<Base_t &>(*this) op(rhs); \
}
ADD_OPERATOR(==)
ADD_OPERATOR(!=)
#if defined(AU_LANG_CPP_20)
template < class T >
std::strong_ordering operator<=>(const T &rhs) noexcept
{
return Base_t::operator<=>(rhs);
}
#else
ADD_OPERATOR(>)
ADD_OPERATOR(<)
ADD_OPERATOR(<=)
ADD_OPERATOR(=>)
#endif
private:
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
void _cache()
{}
#elif !defined(_AURORA_NULLEXPT_BRANCH)
_detail::IPtrGet * ptr;
inline virtual void *Get() override
{
return Base_t::operator->();
}
auline void _cache()
{
if (Base_t::operator bool())
{
ptr = this;
}
else
{
ptr = &_detail::gNoop;
}
}
#else
bool cached {};
auline void throwif() const
{
if (!cached) [[unlikely]]
{
#if defined(_AURORA_NULLEXPT_BRANCH_BUG_CHECK)
if (!Base_t::operator bool()) [[likely]]
#endif
{
AU_THROW_STRING("ExSharedPointer Null Access Violation");
}
}
}
auline void throwif()
{
if (!cached) [[unlikely]]
{
#if defined(_AURORA_NULLEXPT_BRANCH_BUG_CHECK)
cached = Base_t::operator bool();
if (!cached) [[likely]]
#endif
{
AU_THROW_STRING("ExSharedPointer Null Access Violation");
}
}
}
auline void _cache()
{
cached = Base_t::operator bool();
}
#endif
};
template <class TType_t, class Base_t>
struct ExSharedFromThis : Base_t
{
ExSharedPtr<TType_t, AURORA_RUNTIME_AU_SHARED_PTR<TType_t>> SharedFromThis()
{
return Base_t::shared_from_this();
}
};
}

View File

@ -1,15 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auArray.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_AU_ARRAY)
#define AURORA_RUNTIME_AU_ARRAY std::array
#endif
template <class T, size_t Z>
using AuArray = AURORA_RUNTIME_AU_ARRAY<T, Z>;

View File

@ -1,312 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auAtomic.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
template <class T>
struct AuAtomicUtils
{
/**
* @brief Generic bitwise (1 << offset)
* @return original value
* @warning T is bound by platform and compiler constraints
*/
static T Set(T *in, AuUInt8 offset);
/**
* @brief Adds addend to in
* @return updated value
* @warning T is bound by platform and compiler constraints
*/
static T Add(T *in, T addend);
/**
* @brief Subtracts the minuend from in
* @return updated value
* @warning T is bound by platform and compiler constraints
*/
static T Sub(T *in, T minuend);
/**
* @brief Generic compare exchange
* @param replace replacement value for in if in matches compare
* @param compare required reference value
* @return original value
* @warning T is bound by platform and compiler constraints
*/
static T CompareExchange(T *in, T replace, T compare);
/**
* @brief { return *in & (1 << offset); in |= (1 << offset) }
* @param in
* @param offset Bit index
* @return *in & (1 << offset)
* @warning T is bound by platform and compiler constraints
*/
static bool TestAndSet(T *in, const AuUInt8 offset);
};
#if defined(AURORA_COMPILER_MSVC)
template <>
inline auline AuUInt64 AuAtomicUtils<AuUInt64>::CompareExchange(AuUInt64 *in, AuUInt64 replace, AuUInt64 compare)
{
return static_cast<AuUInt64>(_InterlockedCompareExchange64(reinterpret_cast<long long volatile *>(in), static_cast<long long>(replace), static_cast<long long>(compare)));
}
template <>
inline auline AuUInt32 AuAtomicUtils<AuUInt32>::CompareExchange(AuUInt32 *in, AuUInt32 replace, AuUInt32 compare)
{
return static_cast<AuUInt32>(_InterlockedCompareExchange(reinterpret_cast<long volatile *>(in), static_cast<long>(replace), static_cast<long>(compare)));
}
template <>
inline auline AuUInt16 AuAtomicUtils<AuUInt16>::CompareExchange(AuUInt16 *in, AuUInt16 replace, AuUInt16 compare)
{
return static_cast<AuUInt16>(_InterlockedCompareExchange16(reinterpret_cast<short volatile *>(in), static_cast<short>(replace), static_cast<short>(compare)));
}
template <>
inline auline AuInt64 AuAtomicUtils<AuInt64>::CompareExchange(AuInt64 *in, AuInt64 replace, AuInt64 compare)
{
return _InterlockedCompareExchange64(reinterpret_cast<long long volatile *>(in), static_cast<long long>(replace), static_cast<long long>(compare));
}
template <>
inline auline AuInt32 AuAtomicUtils<AuInt32>::CompareExchange(AuInt32 *in, AuInt32 replace, AuInt32 compare)
{
return _InterlockedCompareExchange(reinterpret_cast<long volatile *>(in), static_cast<long>(replace), static_cast<long>(compare));
}
template <>
inline auline AuInt16 AuAtomicUtils<AuInt16>::CompareExchange(AuInt16 *in, AuInt16 replace, AuInt16 compare)
{
return _InterlockedCompareExchange16(reinterpret_cast<short volatile *>(in), static_cast<short>(replace), static_cast<short>(compare));
}
#if !defined(AURORA_IS_32BIT)
template <>
inline auline AuUInt64 AuAtomicUtils<AuUInt64>::Add(AuUInt64 *in, AuUInt64 addend)
{
return static_cast<AuUInt64>(_InterlockedExchangeAdd64(reinterpret_cast<long long volatile *>(in), static_cast<long long>(addend)) + static_cast<long long>(addend));
}
#endif
template <>
inline auline AuUInt32 AuAtomicUtils<AuUInt32>::Add(AuUInt32 *in, AuUInt32 addend)
{
return static_cast<AuUInt32>(_InterlockedExchangeAdd(reinterpret_cast<long volatile *>(in), static_cast<long>(addend)) + static_cast<long>(addend));
}
#if !defined(AURORA_IS_32BIT)
template <>
inline auline AuInt64 AuAtomicUtils<AuInt64>::Add(AuInt64 *in, AuInt64 addend)
{
return _InterlockedExchangeAdd64(reinterpret_cast<long long volatile *>(in), static_cast<long long>(addend)) + static_cast<long long>(addend);
}
#endif
template <>
inline auline AuInt32 AuAtomicUtils<AuInt32>::Add(AuInt32 *in, AuInt32 addend)
{
return _InterlockedExchangeAdd(reinterpret_cast<long volatile *>(in), static_cast<long>(addend)) + static_cast<long>(addend);
}
// TODO:
#if 0
template <>
inline auline AuUInt16 AuAtomicUtils<AuUInt16>::Add(AuUInt16 *in, AuUInt16 addend)
{
return {};
}
#endif
template <>
inline auline AuUInt64 AuAtomicUtils<AuUInt64>::Sub(AuUInt64 *in, AuUInt64 minuend)
{
return Add(in, AuUInt64(0) - minuend);
}
template <>
inline auline AuUInt32 AuAtomicUtils<AuUInt32>::Sub(AuUInt32 *in, AuUInt32 minuend)
{
return Add(in, AuUInt32(0) - minuend);
}
// TODO:
#if 0
template <>
inline auline AuUInt16 AuAtomicUtils<AuUInt16>::Sub(AuUInt16 *in, AuUInt16 minuend)
{
return {};
}
#endif
#if !defined(AURORA_IS_32BIT)
template <>
inline auline AuUInt64 AuAtomicUtils<AuUInt64>::Set(AuUInt64 *in, AuUInt8 offset)
{
return _InterlockedOr64(reinterpret_cast<long long volatile *>(in), AuUInt64(1) << offset);
}
#endif
template <>
inline auline AuUInt32 AuAtomicUtils<AuUInt32>::Set(AuUInt32 *in, AuUInt8 offset)
{
return _InterlockedOr(reinterpret_cast<long volatile *>(in), 1 << offset);
}
template <>
inline auline AuUInt16 AuAtomicUtils<AuUInt16>::Set(AuUInt16 *in, AuUInt8 offset)
{
return _InterlockedOr16(reinterpret_cast<short volatile *>(in), 1 << offset);
}
#if !defined(AURORA_IS_32BIT)
template <>
inline auline AuInt64 AuAtomicUtils<AuInt64>::Set(AuInt64 *in, AuUInt8 offset)
{
return _InterlockedOr64(reinterpret_cast<long long volatile *>(in), AuUInt64(1) << offset);
}
#endif
template <>
inline auline AuInt32 AuAtomicUtils<AuInt32>::Set(AuInt32 *in, AuUInt8 offset)
{
return _InterlockedOr(reinterpret_cast<long volatile *>(in), 1 << offset);
}
template <>
inline auline long AuAtomicUtils<long>::Set(long *in, AuUInt8 offset)
{
return _InterlockedOr(reinterpret_cast<long volatile *>(in), 1 << offset);
}
template <>
inline auline unsigned long AuAtomicUtils<unsigned long>::Set(unsigned long *in, AuUInt8 offset)
{
return _InterlockedOr(reinterpret_cast<long volatile *>(in), 1 << offset);
}
template <>
inline auline AuInt16 AuAtomicUtils<AuInt16>::Set(AuInt16 *in, AuUInt8 offset)
{
return _InterlockedOr16(reinterpret_cast<short volatile *>(in), 1 << offset);
}
#elif defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC)
template <class T>
inline auline T AuAtomicUtils<T>::CompareExchange(T *in, T replace, T compare)
{
return __sync_val_compare_and_swap(in, compare, replace);
}
template <class T>
inline auline T AuAtomicUtils<T>::Add(T *in, T addend)
{
return __sync_add_and_fetch(in, addend);
}
template <class T>
inline auline T AuAtomicUtils<T>::Sub(T *in, T minuend)
{
return __sync_sub_and_fetch(in, minuend);
}
template <class T>
inline auline T AuAtomicUtils<T>::Set(T *in, AuUInt8 offset)
{
return __sync_fetch_and_or(in, T(1) << offset);
}
#endif
template <class T>
inline auline bool AuAtomicUtils<T>::TestAndSet(T *in, const AuUInt8 offset)
{
return AuAtomicUtils<T>::Set(in, offset) & (1 << offset);
}
#if defined(AURORA_COMPILER_MSVC) && (defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86))
template <>
inline auline bool AuAtomicUtils<unsigned long>::TestAndSet(unsigned long *in, const AuUInt8 offset)
{
return _interlockedbittestandset(reinterpret_cast<volatile long *>(in), offset);
}
template <>
inline auline bool AuAtomicUtils<long>::TestAndSet(long *in, const AuUInt8 offset)
{
return _interlockedbittestandset(reinterpret_cast<volatile long *>(in), offset);
}
template <>
inline auline bool AuAtomicUtils<AuUInt32>::TestAndSet(AuUInt32 *in, const AuUInt8 offset)
{
return _interlockedbittestandset(reinterpret_cast<volatile long *>(in), offset);
}
template <>
inline auline bool AuAtomicUtils<AuInt32>::TestAndSet(AuInt32 *in, const AuUInt8 offset)
{
return _interlockedbittestandset(reinterpret_cast<volatile long *>(in), offset);
}
#if !defined(AURORA_IS_32BIT)
template <>
inline auline bool AuAtomicUtils<AuUInt64>::TestAndSet(AuUInt64 *in, const AuUInt8 offset)
{
return _interlockedbittestandset64(reinterpret_cast<volatile long long *>(in), offset);
}
template <>
inline auline bool AuAtomicUtils<AuInt64>::TestAndSet(AuInt64 *in, const AuUInt8 offset)
{
return _interlockedbittestandset64(reinterpret_cast<volatile long long *>(in), offset);
}
#endif
#endif
template <class T>
auline
T AuAtomicSet(T *in, AuUInt8 offset)
{
return AuAtomicUtils<T>::Set(in, offset);
}
template <class T>
auline
T AuAtomicAdd(T *in, T addend)
{
return AuAtomicUtils<T>::Add(in, addend);
}
template <class T>
auline
T AuAtomicSub(T *in, T minuend)
{
return AuAtomicUtils<T>::Sub(in, minuend);
}
template <class T>
auline
T AuAtomicCompareExchange(T *in, T replace, T compare)
{
return AuAtomicUtils<T>::CompareExchange(in, replace, compare);
}
template <class T>
auline
bool AuAtomicTestAndSet(T *in, AuUInt8 offset)
{
return AuAtomicUtils<T>::TestAndSet(in, offset);
}

View File

@ -1,17 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auBST.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_AU_BST)
#define AURORA_RUNTIME_AU_BST std::map
#endif
#include "auHashUtils.hpp"
template <class T, typename Z, typename LessThan_t = AuHash::less<T>>
using AuBST = AURORA_RUNTIME_AU_BST<T, Z, LessThan_t>;

View File

@ -1,222 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auBitsUtils.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
template <class T>
static auline bool AuTestBit(T value, AuUInt8 idx)
{
return value & (T(1) << T(idx));
}
template <class T>
static auline void AuSetBit(T &value, AuUInt8 idx)
{
value |= T(1) << T(idx);
}
template <class T>
static auline void AuClearBit(T &value, AuUInt8 idx)
{
value &= ~(T(1) << T(idx));
}
template <class T>
static auline bool AuBitScanForward(AuUInt8 &index, T value)
{
unsigned long ret;
bool success;
success = false;
index = 0;
#if defined(AURORA_COMPILER_MSVC)
if constexpr (sizeof(T) == sizeof(AuUInt64))
#if defined(AURORA_IS_32BIT)
if (!_BitScanForward(&ret, static_cast<AuUInt32>(value & 0xffffffff)))
{
if (!_BitScanForward(&ret, static_cast<AuUInt32>((value >> 32) & 0xffffffff)))
{
return false;
}
ret += 32;
}
#else
success = _BitScanForward64(&ret, static_cast<AuUInt64>(value));
#endif
else success = _BitScanForward(&ret, static_cast<unsigned long>(value));
#elif defined(AURORA_COMPILER_GCC) || defined(AURORA_COMPILER_CLANG)
if (value == 0)
{
return false;
}
if constexpr (sizeof(T) == sizeof(AuUInt64))
{
#if defined(AURORA_IS_32BIT)
auto lower = static_cast<AuUInt32>(value & 0xffffffff));
if (lower == 0)
{
ret = __builtin_ctzl(static_cast<AuUInt32>((value >> 32) & 0xffffffff));
ret += 32;
}
else
{
ret = __builtin_ctzl(static_cast<AuUInt32>(lower));
}
#else
ret = __builtin_ctzll(static_cast<AuUInt64>(value));
#endif
}
else if constexpr (sizeof(T) == sizeof(unsigned long))
{
ret = __builtin_ctzl(static_cast<unsigned long>(value));
}
else if constexpr (sizeof(T) == sizeof(unsigned int))
{
ret = __builtin_ctz(static_cast<unsigned int>(value));
}
success = true;
#endif
index = ret;
return success;
}
template <class T>
struct AuHalfWord
{
using ReturnType_t = AuConditional_t<AuIsSame_v<T, AuUInt64>, AuUInt32, AuConditional_t<AuIsSame_v<T, AuUInt32>, AuUInt32, AuConditional_t<AuIsSame_v<T, AuUInt16>, AuUInt8, AuFalseType>>>;
static ReturnType_t ToLower(T in)
{
if constexpr (AuIsSame_v<T, AuUInt64>)
{
return in & AuUInt64(0xFFFFFFFF);
}
else if constexpr (AuIsSame_v<T, AuUInt32>)
{
return in & 0xFFFF;
}
else if constexpr (AuIsSame_v<T, AuUInt16>)
{
return in & 0xFF;
}
else
{
return {};
}
}
static ReturnType_t ToHigher(T in)
{
if constexpr (AuIsSame_v<T, AuUInt64>)
{
return (in >> AuUInt64(32)) & AuUInt64(0xFFFFFFFF);
}
else if constexpr (AuIsSame_v<T, AuUInt32>)
{
return (in >> 16) & 0xFFFF;
}
else if constexpr (AuIsSame_v<T, AuUInt16>)
{
return (in >> 8) & 0xFF;
}
else
{
return {};
}
}
};
template <class T>
static auto AuBitsToLower(T in)
{
return AuHalfWord<T>::ToLower(in);
}
template <class T>
static auto AuBitsToHigher(T in)
{
return AuHalfWord<T>::ToHigher(in);
}
template <class T>
static AuUInt8 AuPopCnt(T in)
{
#if defined(AURORA_COMPILER_MSVC)
#if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86)
#if defined(AURORA_ARCH_X64)
if constexpr (sizeof(T) == sizeof(AuUInt64))
{
return _mm_popcnt_u64(static_cast<AuUInt64>(in));
}
else
#endif
if constexpr (sizeof(T) == sizeof(unsigned int))
{
return __popcnt(static_cast<unsigned int>(in));
}
else if constexpr (sizeof(T) <= sizeof(AuUInt16))
{
return __popcnt16(static_cast<AuUInt16>(in));
}
#endif
#else
if constexpr (sizeof(T) == sizeof(unsigned long long))
{
return __builtin_popcountll(static_cast<unsigned long long>(in));
}
else if constexpr (sizeof(T) == sizeof(unsigned long))
{
return __builtin_popcountl(static_cast<unsigned long>(in));
}
else if constexpr (sizeof(T) == sizeof(unsigned int))
{
return __builtin_popcount(static_cast<unsigned int>(in));
}
#endif
#if defined(AU_CPU_ENDIAN_LITTLE)
if constexpr (sizeof(T) == sizeof(AuUInt64))
{
const AuUInt64 m1 = 0x5555555555555555ll;
const AuUInt64 m2 = 0x3333333333333333ll;
const AuUInt64 m4 = 0x0F0F0F0F0F0F0F0Fll;
const AuUInt64 h01 = 0x0101010101010101ll;
in -= (in >> 1) & m1;
in = (in & m2) + ((in >> 2) & m2);
in = (in + (in >> 4)) & m4;
return (in * h01) >> 56;
}
else if constexpr (sizeof(T) == sizeof(AuUInt32))
{
const AuUInt32 m1 = 0x55555555l;
const AuUInt32 m2 = 0x33333333l;
const AuUInt32 m4 = 0x0F0F0F0Fl;
const AuUInt32 h01 = 0x01010101l;
in -= (in >> 1) & m1;
in = (in & m2) + ((in >> 2) & m2);
in = (in + (in >> 4)) & m4;
return (in * h01) >> 24;
}
#endif
if constexpr ((sizeof(T) == sizeof(AuUInt16)) ||
(sizeof(T) == sizeof(AuUInt8)))
{
return AuPopCnt<AuUInt32>(AuUInt32(in));
}
return {};
}
// TODO: AuBitScanReverse

View File

@ -1,136 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auCastUtils.hpp
Date: 2022-2-10
Author: Reece
***/
#pragma once
template <class T, class Z>
static constexpr AuSPtr<T> AuStaticCast(const AuSPtr<Z> &other)
{
return AuSPtr<T>(other, static_cast<T *>(other.get()));
}
template <class T, class Z>
static constexpr AuSPtr<T> AuStaticCast(AuSPtr<Z> &&other)
{
return AuSPtr<T>(AuMove(other), static_cast<T *>(other.get()));
}
template <class T, class Z>
static constexpr AuConditional_t<AuIsPointer_v<T>, T, T *> AuStaticCast(Z *other)
{
return static_cast<AuConditional_t<AuIsPointer_v<T>, T, T *>>(other);
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &> AuStaticCast(Z &other)
{
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(AuForward(other));
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &&> AuStaticCast(Z &&other)
{
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(AuMove(other));
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsPointer_v<T> && !AuIsPointer_v<Z>)>
static constexpr T AuStaticCast(Z other)
{
return static_cast<T>(other);
}
template <class T, class Z>
static constexpr AuConditional_t<AuIsPointer_v<T>, T, T *> AuConstCast(Z *other)
{
return const_cast<AuConditional_t<AuIsPointer_v<T>, T, T *>>(other);
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &> AuConstCast(Z &other)
{
return const_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(AuForward(other));
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &&> AuConstCast(Z &&other)
{
return const_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(AuMove(other));
}
template <class T, class Z>
static constexpr AuSPtr<T> AuConstCast(const AuSPtr<Z> &other)
{
return AuSPtr<T>(other, const_cast<T *>(other.get()));
}
template <class T, class Z>
static constexpr AuSPtr<T> AuConstCast(AuSPtr<Z> &&other)
{
return AuSPtr<T>(AuMove(other), const_cast<T *>(other.get()));
}
template <class T, class Z>
static constexpr AuConditional_t<AuIsClass_v<T> && !AuIsPointer_v<T> && AuIsPointer_v<Z>, T *, T> AuReinterpretCast(Z other)
{
return reinterpret_cast<AuConditional_t<AuIsClass_v<T> && !AuIsPointer_v<T> &&AuIsPointer_v<Z>, T *, T>>(other);
}
template <class T, class Z>
static constexpr AuSPtr<T> AuReinterpretCast(const AuSPtr<Z> &other)
{
return AuSPtr<T>(other, reinterpret_cast<T *>(other.get()));
}
template <class T, class Z>
static constexpr AuSPtr<T> AuReinterpretCast(AuSPtr<Z> &&other)
{
return AuSPtr<T>(AuMove(other), reinterpret_cast<T *>(other.get()));
}
template <class T, class Z>
static T *AuDynamicCast(Z *other)
{
return dynamic_cast<T *>(other);
}
template <class T, class Z>
static AuSPtr<T> AuDynamicCast(const AuSPtr<Z> &other)
{
return AuSPtr<T>(other, dynamic_cast<T *>(other.get()));
}
template <class T, class Z>
static AuSPtr<T> AuDynamicCast(AuSPtr<Z> &&other)
{
return AuSPtr<T>(AuMove(other), dynamic_cast<T *>(other.get()));
}
template <class T, typename Z>
static AuOptional<AuSPtr<T>> AuOptionalSharedDynamicCast(AuOptional<AuSPtr<Z>> &in)
{
if (!in.has_value()) return {};
return AuDynamicCast<T>(in.value());
}
template <class T, typename Z>
static AuOptional<AuSPtr<T>> AuOptionalSharedStaticCast(AuOptional<AuSPtr<Z>> &in)
{
if (!in.has_value()) return {};
return AuStaticPointerCast<T>(in.value());
}
template <class T, class T2>
static AuSPtr<T> AuStaticPointerCast(const AuSPtr<T2> &other) noexcept
{
return AuSPtr<T>(other, static_cast<typename AuSPtr<T>::element_type *>(other.get()));
}
template <class T, class T2>
static AuSPtr<T> AuStaticPointerCast(AuSPtr<T2> &&other) noexcept
{
return AuSPtr<T>(AuMove(other), static_cast<typename AuSPtr<T>::element_type *>(other.get()));
}

View File

@ -1,589 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auContainerUtils.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#include <auROXTL/auTupleUtils.hpp>
namespace __audetail
{
template <class T>
struct AuHascapacity
{
template <class C> static constexpr AuTrueType Test(decltype(&C::capacity));
template <class C> static constexpr AuFalseType Test(...);
using type = decltype(Test<T>(0));
};
template <class T>
constexpr inline bool AuHascapacity_v = AuHascapacity<T>::type::value;
template <class T>
struct AuHasreserve
{
template <class C> static constexpr AuTrueType Test(decltype(&C::reserve));
template <class C> static constexpr AuFalseType Test(...);
using type = decltype(Test<T>(0));
};
template <class T>
constexpr inline bool AuHasreserve_v = AuHasreserve<T>::type::value;
template <class T>
constexpr inline bool AuIsPreallocatable_v = AuHascapacity_v<T> && AuHasreserve_v<T>;
template <class T>
struct AuHastry_emplace
{
template <class C> static constexpr AuTrueType Test(decltype(&C::try_emplace));
template <class C> static constexpr AuFalseType Test(...);
using type = decltype(Test<T>(0));
};
template <class T>
constexpr inline bool AuHastry_emplace_v = false;// <T>::type::value;
template <class T>
struct AuHasemplace
{
template <class C> static constexpr AuTrueType Test(decltype(&C::emplace));
template <class C> static constexpr AuFalseType Test(...);
using type = decltype(Test<T>(0));
};
template <class T>
constexpr inline bool AuHasemplace_v = true;//AuHasemplace<T>::type::value;
template <class T>
struct AuHasfind
{
template <class C> static constexpr AuTrueType Test(decltype(static_cast<C::const_iterator(C:: *)(const C::key_type &) const>(&C::find)));
template <class C> static constexpr AuTrueType Test(decltype(static_cast<C::const_iterator(C:: *)(const C::element_type &) const>(&C::find)));
template <class C> static constexpr AuFalseType Test(...);
using type = decltype(Test<T>(0));
};
template <class T>
constexpr inline bool AuHasfind_v = AuHasfind<T>::type::value;
template <class T>
struct AuHasend
{
template <class C> static constexpr AuTrueType Test(decltype(static_cast<C::const_iterator(C:: *)() const>(&C::end)));
template <class C> static constexpr AuFalseType Test(...);
using type = decltype(Test<T>(0));
};
template <class T>
constexpr inline bool AuHasend_v = AuHasend<T>::type::value;
}
template <class T, bool all>
inline bool _AuRemoveIfBase(T &in, const AuPredicate<const AuToValueType_t<T> &> &predicate);
template <class T>
inline bool AuRemoveAllIf(T &in, const AuPredicate<const AuToValueType_t<T> &> &predicate)
{
return _AuRemoveIfBase<T, true>(in, predicate);
}
template <class T>
inline bool AuRemoveIf(T &in, const AuPredicate<const AuToValueType_t<T> &> &predicate)
{
return _AuRemoveIfBase<T, false>(in, predicate);
}
template <class T, typename Z>
inline void AuRemove(T &in, const Z &type)
{
auto itr = in.find(type);
if (itr == in.end())
{
return;
}
in.erase(itr);
}
template <class T>
inline void AuRemoveRange(T &in, AuUInt index, AuUInt length)
{
if (index + length > in.size())
{
return;
}
auto begin = in.begin();
auto end = begin;
std::advance(begin, index);
std::advance(end, index + length);
while (begin != end)
{
in.erase(begin++);
}
}
template <class T>
inline bool AuTryRemoveRange(T &in, AuUInt index, AuUInt length)
{
AUROXTL_COMMODITY_TRY
{
if (index + length > in.size())
{
return false;
}
auto begin = in.begin();
auto end = begin;
std::advance(begin, index);
std::advance(end, index + length);
while (begin != end)
{
in.erase(begin++);
}
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
return true;
}
template <class Map, class Key, class Value, AU_TEMPLATE_ENABLE_WHEN(__audetail::AuHasfind_v<Map> && !AuIsPointer_v<Map>)>
inline bool AuTryFind(Map &map, const Key &key, Value *&ptr)
{
auto itr = map.find(key);
if (itr != map.end())
{
ptr = &itr->second;
return true;
}
else
{
ptr = nullptr;
return false;
}
}
template <class Map, class Key, typename Value>
inline bool AuTryFind(Map *map, const Key &key, Value *&ptr)
{
return AuTryFind(*map, key, ptr);
}
template <AuUInt N, typename List, class Key>
inline auto AuTryFindByTupleN(List &list, const Key &key)
{
for (auto itr = list.begin(); itr != list.end(); )
{
if (AuGet<N>(*itr) == key)
{
return itr;
}
else
{
itr++;
}
}
return list.end();
}
template <class Range, class Key, AU_TEMPLATE_ENABLE_WHEN(!__audetail::AuHasfind_v<Range> && !AuIsPointer_v<Range>)>
inline bool AuExists(const Range &a, const Key &key)
{
return std::find(a.begin(), a.end(), key) != a.end();
}
template <class Map, class Key, AU_TEMPLATE_ENABLE_WHEN(__audetail::AuHasfind_v<Map> && !AuIsPointer_v<Map>)>
inline bool AuExists(const Map &map, const Key &key)
{
auto itr = map.find(key);
if (itr != map.end())
{
return true;
}
else
{
return false;
}
}
template <class Map, class Key>
inline bool AuExists(const Map *map, const Key &key)
{
return AuExists(*map, key);
}
template <class Container>
inline bool AuTryClear(Container &container)
{
container.clear();
return true;
}
template <class Range, class Key, AU_TEMPLATE_ENABLE_WHEN(!__audetail::AuHasfind_v<Range> && !AuIsPointer_v<Range>)>
inline bool AuTryRemove(Range &list, const Key &key)
{
auto itr = std::find(list.begin(), list.end(), key);
if (itr != list.end())
{
list.erase(itr);
return true;
}
else
{
return false;
}
}
template <class Map, class Key, AU_TEMPLATE_ENABLE_WHEN(__audetail::AuHasfind_v<Map> && !AuIsPointer_v<Map>)>
inline bool AuTryRemove(Map &map, const Key &key)
{
auto itr = map.find(key);
if (itr != map.end())
{
map.erase(itr);
return true;
}
else
{
return false;
}
}
template <class Map, class Key>
inline bool AuTryRemove(Map *map, const Key &key)
{
return AuTryRemove(*map, key);
}
template <AuUInt N, typename List, class Key>
inline bool AuTryRemoveByTupleN(List &list, const Key &key)
{
for (auto itr = list.begin(); itr != list.end(); )
{
if (AuGet<N>(*itr) == key)
{
itr = list.erase(itr);
return true;
}
else
{
itr++;
}
}
return false;
}
template <class Container, typename Key_t, typename Type_t>
inline bool AuTryInsert(Container &container, Key_t &&key, Type_t &&value, bool overwriteMode = true)
{
AUROXTL_COMMODITY_TRY
{
auto itr = container.find(key);
if (itr == container.end())
{
#if defined(_AURORA_NULLEXPT_USE_TRY_EMPLACE_AFTER_FIND)
if constexpr (__audetail::AuHastry_emplace_v<Container>)
{
auto [iterator, success] = container.try_emplace(AuMove(key), AuMove(value));
return success;
}
else
#endif
if constexpr (__audetail::AuHasemplace_v<Container>)
{
container.emplace(AuMove(key), AuMove(value));
return true;
}
else
{
container.insert(AuMakePair(AuMove(key), AuMove(value)));
}
}
else
{
if (!overwriteMode)
{
return false;
}
itr->second = AuMove(value);
}
return true;
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class Container, typename Key_t, typename Type_t>
inline bool AuTryInsert(Container &container, const Key_t &key, Type_t &&value, bool overwriteMode = true)
{
AUROXTL_COMMODITY_TRY
{
auto itr = container.find(key);
if (itr == container.end())
{
#if defined(_AURORA_NULLEXPT_USE_TRY_EMPLACE_AFTER_FIND)
if constexpr (__audetail::AuHastry_emplace_v<Container>)
{
auto [iterator, success] = container.try_emplace(key, AuMove(value));
return success;
}
else
#endif
if constexpr (__audetail::AuHasemplace_v<Container>)
{
container.emplace(key, AuMove(value));
return true;
}
else
{
container.insert(AuMakePair(key, AuMove(value)));
}
}
else
{
if (!overwriteMode)
{
return false;
}
itr->second = AuMove(value);
}
return true;
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class Container>
inline bool AuContainerExpandOne(Container &container)
{
auto required = container.size() + 1;
if (container.capacity() >= required)
{
return true;
}
container.reserve(required);
return container.capacity() >= required;
}
template <class Container>
inline bool AuContainerExpandOne(Container *container)
{
return AuContainerExpandOne(*container);
}
template <class Container, typename Value, AU_TEMPLATE_ENABLE_WHEN(!__audetail::AuHasend_v<Container> && !AuIsPointer_v<Container>)>
inline bool AuTryInsert(Container &container, const Value &value)
{
AUROXTL_COMMODITY_TRY
{
if constexpr (__audetail::AuIsPreallocatable_v<AuRemoveReference_t<Container>>)
{
if (!AuContainerExpandOne(container))
{
return false;
}
}
container.insert(AuReference(value));
return true;
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class Container, typename Value, AU_TEMPLATE_ENABLE_WHEN(!__audetail::AuHasend_v<Container> && !AuIsPointer_v<Container>)>
inline bool AuTryInsert(Container &container, Value &&value)
{
AUROXTL_COMMODITY_TRY
{
if constexpr (__audetail::AuIsPreallocatable_v<AuRemoveReference_t<Container>>)
{
if (!AuContainerExpandOne(container))
{
return false;
}
}
container.insert(AuMove(value));
return true;
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class Container, typename Value, AU_TEMPLATE_ENABLE_WHEN(__audetail::AuHasend_v<Container> && !AuIsPointer_v<Container>)>
inline bool AuTryInsert(Container &container, Value &&value)
{
AUROXTL_COMMODITY_TRY
{
if constexpr (__audetail::AuIsPreallocatable_v<AuRemoveReference_t<Container>>)
{
if (!AuContainerExpandOne(container))
{
return false;
}
}
container.insert(container.end(), AuMove(value));
return true;
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class Container, typename Value, AU_TEMPLATE_ENABLE_WHEN(__audetail::AuHasend_v<Container> && !AuIsPointer_v<Container>)>
inline bool AuTryInsert(Container &container, const Value &value)
{
AUROXTL_COMMODITY_TRY
{
if constexpr (__audetail::AuIsPreallocatable_v<AuRemoveReference_t<Container>>)
{
if (!AuContainerExpandOne(container))
{
return false;
}
}
container.insert(container.end(), value);
return true;
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class Map, class Key, class Value>
inline bool AuTryInsert(Map *map, Key &&key, Value &&value, bool overwriteMode = true)
{
return AuTryInsert(*map, AuMove(key), AuMove(value), overwriteMode);
}
template <class Map, class Key, class Value>
inline bool AuTryInsert(Map *map, const Key &key, Value &&value, bool overwriteMode = true)
{
return AuTryInsert(*map, AuReference(key), AuMove(value), overwriteMode);
}
template <class Map, class Value>
inline bool AuTryInsert(Map *map, Value &&value)
{
return AuTryInsert(*map, AuMove(value));
}
template <class Map, class Value>
inline bool AuTryInsert(Map *map, const Value &value)
{
return AuTryInsert(*map, value);
}
namespace Aurora::Memory
{
struct ByteBuffer;
}
template <class T>
inline bool AuTryResize(T &list, AuUInt length)
{
AUROXTL_COMMODITY_TRY
{
if constexpr (AuIsSame_v<T, Aurora::Memory::ByteBuffer>)
{
return list.Resize(length);
}
else
{
list.resize(length);
return true;
}
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class T>
inline bool AuTryDownsize(T &list, AuUInt length)
{
AUROXTL_COMMODITY_TRY
{
if constexpr (AuIsSame_v<T, Aurora::Memory::ByteBuffer>)
{
if (!list.Resize(length))
{
return false;
}
list.GC();
return true;
}
else
{
list.resize(length);
list.shrink_to_fit();
return true;
}
}
AUROXTL_COMMODITY_CATCH
{
return false;
}
}
template <class T, bool all>
inline bool _AuRemoveIfBase(T &in, const AuPredicate<const AuToValueType_t<T> &> &predicate)
{
bool retOne {};
for (auto itr = in.begin(); itr != in.end(); )
{
if (predicate(*itr))
{
itr = in.erase(itr);
if constexpr (!all)
{
return true;
}
retOne = true;
}
else
{
itr++;
}
}
// optimization hint
if constexpr (all) return retOne;
return {};
}

View File

@ -1,58 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auCopyMoveUtils.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
/**
* @brief Upcasts R-Value upcastable @param arg.
* For an L-Value equivalent hint, use AuReference
* @tparam T
* @param arg
* @return
*/
template <class T>
auline constexpr AuRemoveReference_t<T> &&AuMove(T &&arg) noexcept
{
return static_cast<AuRemoveReference_t<T> &&>(arg);
}
/**
* @brief Upcasts L-Value upcastable @param arg.
* For an R-Value equivalent hint, use AuMove
* @tparam T An expression to implicitly upcast to an L-value
* @param arg
* @return
*/
template <class T>
auline constexpr T &AuReference(T &arg) noexcept
{
return static_cast<T &>(arg);
}
/**
* @brief Preserves R or L value without reducing; implicit AuMove or AuReference
* @tparam T An expression to implicitly upcast to an R-value
* @param arg
* @return
*/
template <class T>
auline constexpr T &&AuForward(AuRemoveReference_t<T> &arg) noexcept
{
return static_cast<T &&>(arg);
}
/**
* @brief Preserves R or L value without reducing; implicit AuMove or AuReference
* @tparam T
* @param arg
* @return
*/
template <class T>
auline constexpr T &&AuForward(AuRemoveReference_t<T> &&arg) noexcept
{
return static_cast<T &&>(arg);
}

View File

@ -1,94 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auEndianness.hpp
Date: 2022-2-6
Author: Reece
***/
#pragma once
template <class T>
struct AuEndianUtils
{
static T Swap(T in);
};
template <class T>
inline T AuEndianUtils<T>::Swap(T in)
{
if constexpr (sizeof(T) == 8)
return (T(in) & 0xFF) << T(56) |
(T(in >> T(8)) & T(0xFF)) << T(48) |
(T(in >> T(16)) & T(0xFF)) << T(40) |
(T(in >> T(24)) & T(0xFF)) << T(32) |
(T(in >> T(32)) & T(0xFF)) << T(24) |
(T(in >> T(40)) & T(0xFF)) << T(16) |
(T(in >> T(48)) & T(0xFF)) << T(8) |
(T(in >> T(56)) & T(0xFF));
if constexpr (sizeof(T) == 4)
return T(in & 0xFF) << 24 |
(T(in >> 8) & 0xFF) << 16 |
(T(in >> 16) & 0xFF) << 8 |
(T(in >> 24) & 0xFF);
if constexpr (sizeof(T) == 2)
return (in & 0xFF) << 8 |
((in >> 8) & 0xFF);
return in;
}
#if defined(AURORA_COMPILER_MSVC)
template <>
inline AuUInt64 AuEndianUtils<AuUInt64>::Swap(AuUInt64 in)
{
return _byteswap_uint64(in);
}
template <>
inline AuUInt32 AuEndianUtils<AuUInt32>::Swap(AuUInt32 in)
{
return _byteswap_ulong(in);
}
template <>
inline unsigned long AuEndianUtils<unsigned long>::Swap(unsigned long in)
{
return _byteswap_ulong(in);
}
template <>
inline AuUInt16 AuEndianUtils<AuUInt16>::Swap(AuUInt16 in)
{
return _byteswap_ushort(in);
}
#elif defined(AURORA_COMPILER_CLANG)
template <>
inline AuUInt64 AuEndianUtils<AuUInt64>::Swap(AuUInt64 in)
{
return __builtin_bswap64(in);
}
template <>
inline AuUInt32 AuEndianUtils<AuUInt32>::Swap(AuUInt32 in)
{
return __builtin_bswap32(in);
}
template <>
inline AuUInt16 AuEndianUtils<AuUInt16>::Swap(AuUInt16 in)
{
return __builtin_bswap16(in);
}
#endif
template <class Type_t>
inline auline Type_t AuFlipEndian(Type_t in)
{
return AuEndianUtils<Type_t>::Swap(in);
}

View File

@ -1,86 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auFNV1Utils.hpp
Date: 2022-3-23
File: fnv1.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
#include "auTypeUtils.hpp"
// Note: we're too early for AuroraEnv.hpp w/ AuroraEnums
#if defined(AURORA_IS_32BIT)
#define _AU_FNV1_32 1
#else
#define _AU_FNV1_32 0
#endif
constexpr AuUInt64 kFnv1MagicVal64 = 0xcbf29ce484222325;
constexpr AuUInt64 kFnv1MagicPrime64 = 0x100000001b3;
constexpr AuUInt32 kFnv1MagicVal32 = 0x811c9dc5;
constexpr AuUInt32 kFnv1MagicPrime32 = 0x01000193;
constexpr auto kFnv1MagicValPlatform = _AU_FNV1_32 ? kFnv1MagicVal32 : kFnv1MagicVal64;
constexpr auto kFnv1MagicPrimePlatform = _AU_FNV1_32 ? kFnv1MagicPrime32 : kFnv1MagicPrime64;
inline constexpr AuUInt64 AuFnv1a64(const char *const str, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
return (str[0] == '\0') ? value : AuFnv1a64(&str[1], (value ^ AuUInt64(str[0])) * kFnv1MagicPrime64);
}
inline constexpr AuUInt32 AuFnv1aTrunc(const char *const str) noexcept
{
return static_cast<AuUInt32>(AuFnv1a64(str));
}
inline constexpr AuUInt32 AuFnv1a32(const char *const str, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
return (str[0] == '\0') ? value : AuFnv1a32(&str[1], (value ^ AuUInt32(str[0])) * kFnv1MagicPrime32);
}
inline constexpr AuUInt AuFnv1aType(const char *type, AuUInt size, AuUInt index, const AuUInt value) noexcept
{
return (index == size) ? value : AuFnv1aType(type + 1, size, index + 1, (value ^ AuUInt(*type) * kFnv1MagicPrimePlatform));
}
template <class T>
inline constexpr AuUInt AuFnv1aType(const T &type, const AuUInt value = kFnv1MagicValPlatform) noexcept
{
return AuFnv1aType(((const char *)&type) + 1, sizeof(T), 1, (value ^ AuUInt(*(const char *)&type) * kFnv1MagicPrimePlatform));
}
inline constexpr auto AuFnv1a(const char *const str) noexcept
{
return _AU_FNV1_32 ? AuFnv1a32(str) : AuFnv1a64(str);
}
inline AuUInt32 AuFnv1a32Runtime(const void *base, AuUInt length) noexcept
{
AuUInt32 result {kFnv1MagicVal32};
AuUInt i {};
for (; i < length; i++)
{
result ^= AuUInt(AuReadU8(base, i)) * kFnv1MagicPrime32;
}
return result;
}
inline AuUInt64 AuFnv1a64Runtime(const void *base, AuUInt length) noexcept
{
AuUInt64 result {kFnv1MagicVal64};
AuUInt i {};
for (; i < length; i++)
{
result ^= AuUInt64(AuReadU8(base, i)) * kFnv1MagicPrime64;
}
return result;
}
#undef _AU_FNV1_32

View File

@ -1,29 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auFunctional.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_AU_FUNC)
#define AURORA_RUNTIME_AU_FUNC std::function
#endif
template <class T>
using AuFunction = AURORA_RUNTIME_AU_FUNC<T>;
template <class ...T>
using AuPredicate = AuFunction<bool(T...)>;
using AuVoidFunc = AuFunction<void(void)>;
template <class ...T>
using AuConsumer = AuFunction<void(T...)>;
template <class T>
using AuSupplier = AuFunction<T(void)>;
template <class T, typename ...Args>
using AuSupplierConsumer = AuFunction<T(Args...)>;

View File

@ -1,17 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auHashMap.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_AU_HASH_MAP)
#define AURORA_RUNTIME_AU_HASH_MAP std::unordered_map
#endif
#include "auHashUtils.hpp"
template <class T, class Z, class Hash_t = AuHash::hash<T>, class Equal_t = AuHash::equal<T>>
using AuHashMap = AURORA_RUNTIME_AU_HASH_MAP<T, Z, Hash_t, Equal_t>;

View File

@ -1,143 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auHashUtils.hpp
Date: 2022-3-23
Author: Reece
***/
#pragma once
#include "auFNV1Utils.hpp"
#define _AU_HASH_UTILS_HAS_STD
template <class T>
struct AuHasHashCode
{
template <class C> static constexpr AuTrueType Test(decltype(&C::HashCode));
template <class C> static constexpr AuFalseType Test(...);
using type = decltype(Test<T>(0));
};
template <class T>
constexpr inline bool AuHasHashCode_v = AuHasHashCode<T>::type::value;
namespace AuHash
{
template <class Key>
struct hash
{
#if defined(_AU_HASH_UTILS_HAS_STD)
AuConditional_t<AuHasHashCode_v<Key>, AuUInt8, std::hash<Key>> trashHasher;
#endif
AuUInt operator()(const Key &ref) const
{
if constexpr (AuHasHashCode_v<Key>)
{
return ref.HashCode();
}
#if defined(_AU_HASH_UTILS_HAS_STD)
else
{
return trashHasher(ref);
}
#endif
}
};
#define _HASH_F_CPP(type) \
template <> \
struct hash<type> \
{ \
constexpr AuUInt operator ()(const type b) const \
{ \
return AuFnv1aType<type>(b); \
} \
};
_HASH_F_CPP(bool);
_HASH_F_CPP(char);
_HASH_F_CPP(signed char);
_HASH_F_CPP(unsigned char);
_HASH_F_CPP(char8_t);
_HASH_F_CPP(char16_t);
_HASH_F_CPP(char32_t);
_HASH_F_CPP(wchar_t);
_HASH_F_CPP(short);
_HASH_F_CPP(unsigned short);
_HASH_F_CPP(int);
_HASH_F_CPP(unsigned int);
_HASH_F_CPP(long);
_HASH_F_CPP(long long);
_HASH_F_CPP(unsigned long);
_HASH_F_CPP(unsigned long long);
_HASH_F_CPP(float);
_HASH_F_CPP(double);
_HASH_F_CPP(long double);
_HASH_F_CPP(std::nullptr_t);
#undef _HASH_F_CPP
template <class T> struct hash<T *>
{
AuUInt operator ()(T *ptr) const
{
#if defined(AURORA_IS_32BIT)
return AuFnv1a32Runtime(&ptr, sizeof(T *));
#else
return AuFnv1a64Runtime(&ptr, sizeof(T *));
#endif
}
};
template <class T>
struct less
{
constexpr bool operator()(const T &lhs, const T &rhs) const
{
if constexpr (AuHasHashCode_v<T>)
{
return lhs.HashCode() < rhs.HashCode();
}
else
{
return lhs < rhs;
}
}
};
template <class T>
struct equal
{
constexpr bool operator()(const T &lhs, const T &rhs) const
{
return lhs == rhs;
}
};
}
template <class T, AU_TEMPLATE_ENABLE_WHEN(AuHasHashCode_v<T>)>
inline AuUInt AuHashCode(const T &ref)
{
return ref.HashCode();
}
template <class T, AU_TEMPLATE_ENABLE_WHEN(!AuHasHashCode_v<T>)>
inline AuUInt AuHashCode(const T &ref)
{
return AuHash::hash<T>()(ref);
}
template <class T>
struct AuEnableHashCodeOnData
{
AuUInt HashCode() const
{
#if defined(AURORA_IS_32BIT)
return AuFnv1a32Runtime(AuStaticCast<AuAddConst_t<T>>(this), sizeof(T));
#else
return AuFnv1a64Runtime(AuStaticCast<AuAddConst_t<T>>(this), sizeof(T));
#endif
}
};

View File

@ -1,35 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auIntegerSequence.hpp
Date: 2022-3-25
Author: Reece
***/
#pragma once
template <class T, T... Args>
struct AuIntegerSequence
{
using value_type = T;
inline constexpr AuUInt size()
{
return sizeof...(Args);
}
};
template <class T, T Num>
#if defined(AURORA_COMPILER_GCC)
using AuMakeIntegerSequence = std::make_integer_sequence<T, Num>;
#else
using AuMakeIntegerSequence = __make_integer_seq<AuIntegerSequence, T, Num>;
#endif
template <AuUInt Num>
using AuMakeIndexSequence = AuMakeIntegerSequence<AuUInt, Num>;
template <AuUInt... Args>
using AuIndexSequence = AuIntegerSequence<AuUInt, Args...>;
template <class... Args>
using AuIndexSequenceFor = AuMakeIndexSequence<sizeof...(Args)>;

View File

@ -1,31 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auList.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_AU_LIST)
#define AURORA_RUNTIME_AU_LIST std::vector
#endif
#include "auMemoryModel.hpp"
#if defined(AURORA_ROXTL_CONTAINERS_USE_PURE)
template <class T>
using AuList = AURORA_RUNTIME_AU_LIST<T>;
#else
template <class T>
using AuList = AURORA_RUNTIME_AU_LIST<T,
AuConditional_t<AuIsClass_v<T>,
Aurora::Memory::ClassArrayAllocator<T>,
Aurora::Memory::PrimitiveArrayAllocator<T>
>
>;
#endif

View File

@ -1,22 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auListUtils.hpp
Date: 2022-3-27
Author: Reece
***/
#pragma once
template <typename T, typename ... Args>
constexpr bool AuListFromArgs(T &list, Args && ... args)
{
constexpr auto end = sizeof...(Args);
if (!AuTryResize(list, end))
{
return false;
}
AuUInt i = 0;
(..., (list[i++] = AuMove(args)));
return true;
}

View File

@ -1,66 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auMagicUtils.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
/**
* @brief
* @param buffer
* @return A non-determinstic/platform specific magic number that once written with respect to endianness emits the tag
*/
static constexpr auline AuUInt32 AuConvertMagicTag32(const char buffer[4])
{
AuUInt32 magic {};
if (Aurora::Build::kCurrentEndian == Aurora::Build::ECPUEndian::eCPULittle)
{
magic |= AuUInt32(buffer[0]);
magic |= AuUInt32(buffer[1]) << 8;
magic |= AuUInt32(buffer[2]) << 16;
magic |= AuUInt32(buffer[3]) << 24;
}
else
{
magic |= AuUInt32(buffer[4]);
magic |= AuUInt32(buffer[2]) << 8;
magic |= AuUInt32(buffer[1]) << 16;
magic |= AuUInt32(buffer[0]) << 24;
}
return magic;
}
/**
* @brief
* @param buffer
* @return A non-determinstic/platform specific magic number that once written with respect to endianness emits the tag
*/
static constexpr auline AuUInt64 AuConvertMagicTag64(const char buffer[8])
{
AuUInt64 magic {};
if (Aurora::Build::kCurrentEndian == Aurora::Build::ECPUEndian::eCPULittle)
{
magic |= AuUInt64(buffer[0]);
magic |= AuUInt64(buffer[1]) << 8;
magic |= AuUInt64(buffer[2]) << 16;
magic |= AuUInt64(buffer[3]) << 24;
magic |= AuUInt64(buffer[4]) << 32;
magic |= AuUInt64(buffer[5]) << 40;
magic |= AuUInt64(buffer[6]) << 48;
magic |= AuUInt64(buffer[7]) << 56;
}
else
{
magic |= AuUInt64(buffer[7]);
magic |= AuUInt64(buffer[6]) << 8;
magic |= AuUInt64(buffer[5]) << 16;
magic |= AuUInt64(buffer[4]) << 24;
magic |= AuUInt64(buffer[3]) << 32;
magic |= AuUInt64(buffer[2]) << 40;
magic |= AuUInt64(buffer[1]) << 48;
magic |= AuUInt64(buffer[0]) << 56;
}
return magic;
}

View File

@ -1,221 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auMemoryModel.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#include "auTypes.hpp"
#if !defined(AURORA_RUNTIME_AU_SHARED_PTR)
#define AURORA_RUNTIME_AU_SHARED_PTR std::shared_ptr
#endif
#if !defined(AURORA_RUNTIME_AU_WEAK_PTR)
#define AURORA_RUNTIME_AU_WEAK_PTR std::weak_ptr
#endif
template <class T>
using AuWPtr = AURORA_RUNTIME_AU_WEAK_PTR<T>;
#if !defined(AURORA_RUNTIME_AU_UNIQUE_PTR)
#define AURORA_RUNTIME_AU_UNIQUE_PTR std::unique_ptr
#endif
#if !defined(AURORA_RUNTIME_AU_DEFAULT_DELETER)
#define AURORA_RUNTIME_AU_DEFAULT_DELETER std::default_delete
#endif
template <class T>
using AuDefaultDeleter = AURORA_RUNTIME_AU_DEFAULT_DELETER<T>;
#include "STLShims/ExtendStlLikeSharedPtr.hpp"
template <class T>
using AuSPtr = typename Aurora::Memory::ExSharedPtr<T, AURORA_RUNTIME_AU_SHARED_PTR<T>>;
template <class T, typename Deleter_t>
using AuUPtr = AURORA_RUNTIME_AU_UNIQUE_PTR<T, Deleter_t>;
#if !defined(AU_AuEnableSharedFromThis)
#define AU_AuEnableSharedFromThis
template <class X>
struct AuEnableSharedFromThis : Aurora::Memory::ExSharedFromThis<X, std::enable_shared_from_this<X>>
{};
#endif
#if !defined(AURORA_RUNTIME_MAKE_SHARED)
#define AURORA_RUNTIME_MAKE_SHARED std::make_shared
#endif
template <class T, typename... Args>
static auline AuSPtr<T> AuMakeShared(Args&&... args)
{
try
{
return AURORA_RUNTIME_MAKE_SHARED<T>(AuForward<Args>(args)...);
}
catch (...)
{
return {};
}
}
namespace __audetail
{
struct Dummy
{
char a;
};
inline AuSPtr<Dummy> GetDummyDeleter()
{
static AuSPtr<Dummy> d;
if (!d)
{
#if defined(AURORA_COMPILER_MSVC)
return d;
#endif
d = AuMakeShared<Dummy>();
}
return d;
}
}
template <class T>
static auline AuSPtr<T> AuMakeSharedArray(AuUInt count)
{
try
{
#if defined(AU_LANG_CPP_20) && 0
return AURORA_RUNTIME_AU_SHARED_PTR<T[]>(count);
#else
return AURORA_RUNTIME_AU_SHARED_PTR<T>(new T[count], AuDefaultDeleter<T[]>());
#endif
}
catch (...)
{
return {};
}
}
template <class T>
static AuSPtr<T> AuUnsafeRaiiToShared(T *in)
{
return AuSPtr<T>(__audetail::GetDummyDeleter(), in);
}
template <class T, class Z>
static AuSPtr<T> AuUnsafeRaiiToShared(const AuUPtr<T, Z> &in)
{
return AuUnsafeRaiiToShared(in.get());
}
template <class T, AuUInt Z>
static constexpr int AuArraySize(const T(&array)[Z])
{
return Z;
}
#if defined(DEBUG) || defined(STAGING)
template <class ... T>
static auline void AU_NORETURN SysPanic(T... args);
template <class Z, typename T>
static void auline AuSafeDelete(T *in)
{
static_assert(AuIsBaseOf_v<T, AuRemovePointer_t<Z>>, "Couldn't not safe delete from type T because it is not derived from Z");
if (in == nullptr)
{
Z re;
SysPanic("Tried to free: 0x{:x}, type \"{}\" / \"{}\"", AuUInt(in), typeid(in).name(), typeid(re).name());
}
delete static_cast<Z>(in);
}
#else
template <class Z, typename T>
static void auline AuSafeDelete(T *in)
{
static_assert(AuIsBaseOf_v<T, AuRemovePointer_t<Z>>, "Couldn't not safe delete from type T because it is not derived from Z");
delete static_cast<Z>(in);
}
#endif
namespace Aurora::Memory
{
#if defined(AURORA_ROXTL_ALLOCATORS_USE_STD)
template<typename T>
using PrimitiveArrayAllocator = std::allocator<T>;
template<typename T>
using ClassArrayAllocator = std::allocator<T>;
template<typename T>
using StringAllocator = std::allocator<T>;
#else
static void *__FAlloc(Types::size_t length, Types::size_t align);
static void __Free(void *buffer);
template <class T>
struct BaseAuroraRuntimeAllocator
{
typedef T value_type;
AU_COPY_MOVE(BaseAuroraRuntimeAllocator)
constexpr BaseAuroraRuntimeAllocator()
{}
template <class U> constexpr BaseAuroraRuntimeAllocator(const BaseAuroraRuntimeAllocator <U> &) noexcept
{
}
inline [[nodiscard]] constexpr T* allocate(Types::size_t n)
{
if (auto p = (__FAlloc(n * sizeof(T), alignof(T))))
{
return AuReinterpretCast<T*>(p);
}
throw std::bad_alloc();
}
inline constexpr void deallocate(T *p, std::size_t n) noexcept
{
__Free(p);
}
inline bool operator==(const BaseAuroraRuntimeAllocator &op)
{
return true;
}
};
template<typename T>
using PrimitiveArrayAllocator = BaseAuroraRuntimeAllocator<T>;
template<typename T>
using ClassArrayAllocator = BaseAuroraRuntimeAllocator<T>;
template<typename T>
using StringAllocator = BaseAuroraRuntimeAllocator<T>;
#endif
}

View File

@ -1,47 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auMemoryUtils.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_MEMCMP)
#define AURORA_RUNTIME_MEMCMP std::memcmp
#endif
static auline int AuMemcmp(const void *dest, const void *src, size_t n)
{
return AURORA_RUNTIME_MEMCMP(dest, src, n);
}
#if !defined(AURORA_RUNTIME_MEMSET)
#define AURORA_RUNTIME_MEMSET std::memset
#endif
static auline void *AuMemset(void *dest, AuUInt8 c, size_t n)
{
return AURORA_RUNTIME_MEMSET(dest, c, n);
}
#if !defined(AURORA_RUNTIME_MEMCPY)
#define AURORA_RUNTIME_MEMCPY std::memcpy
#endif
static auline void *AuMemcpy(void *dest, const void *src, size_t n)
{
return AURORA_RUNTIME_MEMCPY(dest, src, n);
}
#if !defined(AURORA_RUNTIME_MEMMOVE)
#define AURORA_RUNTIME_MEMMOVE std::memmove
#endif
static auline void *AuMemmove(void *dest, const void *src, size_t n)
{
return AURORA_RUNTIME_MEMMOVE(dest, src, n);
}

View File

@ -1,38 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auNumberUtils.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
template <class T>
constexpr const T &AuMin(const T &a, const T &b)
{
return a < b ? a : b;
}
template <class T>
constexpr const T &AuMax(const T &a, const T &b)
{
return a < b ? b : a;
}
template <class T>
constexpr const T AuConstPow(const T base, const AuUInt8 exponent)
{
return exponent ? base * AuConstPow(base, exponent - 1) : 1;
}
template <class T>
constexpr const T AuPageRoundUp(const T value, const T pageSize)
{
return (value + (pageSize - 1)) & ~(pageSize - 1);
}
template <class T>
constexpr const T AuPageRound(const T value, const T pageSize)
{
return value & ~(pageSize - 1);
}

View File

@ -1,131 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auNumericLimits.hpp
Date: 2022-2-19
Author: Reece
***/
#pragma once
template <class T, T Min, T Max, T Epsilon, bool IsSigned = false, bool IsInteger = false>
struct _AuNonStdLimits
{
using Type = T;
static const bool is_signed = IsSigned;
static const bool is_integer = IsInteger;
static constexpr Type min()
{
return Min;
}
static constexpr Type max()
{
return Max;
}
static constexpr Type epsilon()
{
return Epsilon;
}
};
template <class T>
struct AuNumericLimits;
#define _AU_LIMITS_ADD(bits) \
\
template <> \
struct AuNumericLimits<AuUInt ## bits> : _AuNonStdLimits<AuUInt ## bits, 0, static_cast<AuUInt ## bits>(AuInt ## bits(-1)), 1, false, true> \
{ \
\
}; \
\
template <> \
struct AuNumericLimits<AuInt ## bits> : _AuNonStdLimits<AuInt ## bits, AuInt ## bits(AuUInt ## bits(0) - AuInt ## bits(AuConstPow<AuUInt ## bits>(2, bits - 1) - 1)) - 1, AuInt ## bits(AuConstPow<AuUInt ## bits>(2, bits - 1) - 1), 1, true, true> \
{ \
\
};
_AU_LIMITS_ADD(8)
_AU_LIMITS_ADD(16)
_AU_LIMITS_ADD(32)
_AU_LIMITS_ADD(64)
#undef _AU_LIMITS_ADD
#if defined(AURORA_COMPILER_MSVC)
template <>
struct AuNumericLimits<long> : AuNumericLimits<int>
{};
template <>
struct AuNumericLimits<unsigned long> : AuNumericLimits<unsigned int>
{};
#endif
// TODO: clang x86 and x64 will need different hacks for [unsigned] long long
template <>
struct AuNumericLimits<bool> : _AuNonStdLimits<bool, false, true, true>
{};
template <>
struct AuNumericLimits<char16_t> : AuNumericLimits<AuUInt16>
{};
template <>
struct AuNumericLimits<char32_t> : AuNumericLimits<AuUInt32>
{};
template <class T>
struct _AuNonStdLimitsFP
{
using Type = T;
static const bool is_signed = true;
static const bool is_integer = false;
};
template <>
struct AuNumericLimits<float> : _AuNonStdLimitsFP<float>
{
static double max()
{
return 340282346638528859811704183484516925440.0000000000000000;
}
static double min()
{
return -340282346638528859811704183484516925440.0000000000000000;
}
static constexpr double epsilon()
{
return 0.000000000000000111;
}
};
template <>
struct AuNumericLimits<double> : _AuNonStdLimitsFP<double>
{
static double max()
{
return 1.7976931348623157e+308;
}
static double min()
{
return -2.2250738585072014e-308;
}
static constexpr double epsilon()
{
return 0.000000000000000111;
}
};

View File

@ -1,15 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auOptional.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_AU_OPTIONAL)
#define AURORA_RUNTIME_AU_OPTIONAL std::optional
#endif
template <class T>
using AuOptional = AURORA_RUNTIME_AU_OPTIONAL<T>;

View File

@ -1,91 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auOptionalEx.hpp
Date: 2022-3-23
Author: Reece
***/
#pragma once
#include "auCopyMoveUtils.hpp"
#include "auHashUtils.hpp"
template <class T>
struct AuOptionalEx
{
bool hasValue;
T type;
AuOptionalEx() : hasValue({})
{}
AuOptionalEx(T &value) : type(value), hasValue(true)
{}
AuOptionalEx(T &&value) : type(value), hasValue(true)
{}
T &Value()
{
return type;
}
const T &Value() const
{
return type;
}
template <class U>
constexpr T ValueOr(U &&defaultValue) const &
{
return bool(*this) ? value() : static_cast<T>(AuForward<U>(defaultValue));
}
template <class U>
constexpr T ValueOr(U &&defaultValue) &&
{
return bool(*this) ? AuMove(value()) : static_cast<T>(AuForward<U>(defaultValue));
}
bool HasValue() const
{
return this->hasValue;
}
operator bool() const
{
return this->hasValue;
}
T &value()
{
return this->type;
}
const T &value() const
{
return this->type;
}
bool has_value() const
{
return this->hasValue;
}
AuUInt HashCode() const
{
return AuHashCode(type);
}
void Reset()
{
this->type = {};
this->hasValue = {};
}
void Swap(AuOptionalEx &&ex)
{
AuSwap(this->type, ex.type);
AuSwap(this->hasValue, ex.hasValue);
}
};

View File

@ -1,9 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auPosixUtils.hpp
Date: 2022-2-6
Author: Reece
***/
#pragma once

View File

@ -1,67 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auResult.hpp
Date: 2022-3-23
Author: Reece
***/
#pragma once
#include "auCopyMoveUtils.hpp"
#include "auHashUtils.hpp"
template <class T>
struct AuResult
{
bool success;
T type;
AuResult() : success()
{}
AuResult(bool success) : success(success)
{}
AuResult(T &&value) : type(value), success(true)
{}
// I could be pulling this out of my ass, but i'd assume with callee provided stack space being provided through arg0 in most abis,
// and with the callers binary originating from a file in which contains the T declaration, i'd assume it would be faster to chuck
// the return value in the callers' stack **and** access it by reference in the callee, rather than assigning a value using move
// constructors/assignment operators whenever the data is available.
// Feels like a landmine of accidental allocates:
// ...what is the default constructor doing in the caller? (hopefully nothing)
// ...does the object even support move semantics? (would AuResult<T>(AuMove(t)) result in a copy no matter what?)
//
// generally recommend ::GetResult()
T &GetResult()
{
return type;
}
constexpr const T *operator->() const
{
return &type;
}
constexpr T *operator->()
{
return &type;
}
const T &GetResult() const
{
return type;
}
void Complete()
{
this->success = true;
}
operator bool() const
{
return this->success;
}
};

View File

@ -1,28 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auString.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
//#include "tinyutf8.h"
//#define AU_STRING_IS_TINYUTF_EXPERIMENT
#if defined(AURORA_ROXTL_CONTAINERS_USE_PURE)
using AuString = std::string;
#elif defined(AURORA_ROXTL_STRING_USE_STR_ALLOCATOR)
template <class Base_t = std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>>
struct _AuStdExString : Base_t
{
using Base_t::Base_t;
_AuStdExString(const std::string &str) : Base_t(str.begin(), str.end())
{}
};
using AuString = _AuStdExString<>;
#else
using AuString = std::string;
#endif

View File

@ -1,123 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auStringUtils.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
static auline bool AuStringContains(const AuString &value, const AuString &subpattern)
{
return value.find(subpattern) != AuString::npos;
}
static auline bool AuEndsWith(AuString const &value, AuString const &ending)
{
if (ending.size() > value.size()) return false;
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
}
static auline bool AuStartsWith(AuString const &value, AuString const &starting)
{
#if defined(AU_STRING_IS_TINYUTF_EXPERIMENT)
return value.starts_with(starting);
#else
return value.rfind(starting, 0) == 0;
#endif
}
#if defined(AU_STRING_IS_TINYUTF_EXPERIMENT)
static AuString AuStringTransform(const AuString &in, const AuSupplierConsumer<AuUInt32, AuUInt32> &out)
{
AuString cpy = in;
for (int i = 0; i < cpy.length(); i++)
{
cpy[i] = out(cpy[i]);
}
return cpy;
}
static auline AuString AuToUpper(const AuString &in)
{
return AuStringTransform(in, std::toupper);
}
static auline AuString AuToLower(const AuString &in)
{
return AuStringTransform(in, std::toupper);
}
#else
template <class T>
static auline AuString AuToStringASCIIOp(T op, const AuString &in)
{
AuString ret;
ret.resize(in.size());
std::transform(in.begin(), in.end(), ret.begin(), [=](const char &c)
{
return op(c);
});
return ret;
}
static auline AuString AuToLower(const AuString &in)
{
return AuToStringASCIIOp<int(*)(int)>(std::tolower, in);
}
static auline AuString AuToUpper(const AuString &in)
{
return AuToStringASCIIOp<int(*)(int)>(std::toupper, in);
}
#endif
static auline AuString AuReplaceAll(AuString &str, const AuString &from, const AuString &to)
{
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos)
{
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
}
return str; // :(
}
// i told myself not to copy this, required a split function twice, now here we are :D
static auline AuList<AuString> AuSplitString(const AuString &str, const AuString &delim, bool ignoreEmpty = true)
{
AuList<AuString> tokens;
AuUInt prev = 0, pos = 0;
do
{
pos = str.find(delim, prev);
if (pos == AuString::npos) pos = str.length();
auto token = str.substr(prev, pos - prev);
if ((!token.empty()) && ignoreEmpty) tokens.push_back(token);
prev = pos + delim.length();
}
while (pos < str.length() && prev < str.length());
return tokens;
}
#if !defined(AURORA_RUNTIME_TO_STRING)
#define AURORA_RUNTIME_TO_STRING std::to_string
#endif
template <class T>
static auline AuString AuToString(const T &obj)
{
#if defined(_AUHAS_FMT)
// locale independent and better optimized!
return fmt::format("{}", obj);
#else
// TODO: to_chars (locale independent)
return AURORA_RUNTIME_TO_STRING(obj);
#endif
}

View File

@ -1,24 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auSwapExchangeUtils.hpp
Date: 2022-3-27
Author: Reece
***/
#pragma once
template <class T, class U = T>
inline T AuExchange(T &obj, U &&newValue)
{
T oldValue = AuMove(obj);
obj = AuForward<U>(newValue);
return oldValue;
}
#if !defined(AURORA_RUNTIME_SWAP)
#define AURORA_RUNTIME_SWAP std::swap
#endif
template <class T>
inline void AuSwap(T &a, T &b)
{
AURORA_RUNTIME_SWAP(a, b);
}

View File

@ -1,341 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTemplateMeta.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once
template <bool v>
struct AuBoolType
{
static constexpr bool value = v;
using value_type = bool;
using type = AuBoolType;
constexpr operator value_type() const noexcept
{
return value;
}
constexpr value_type operator()() const noexcept
{
return value;
}
};
using AuFalseType = AuBoolType<false>;
using AuTrueType = AuBoolType<true>;
#include "auTemplateMetaIsFunction.hpp"
template <class T>
using AuToValueType_t = typename T::value_type;
template <class T>
using AuToElementType_t = typename T::element_type;
template <class T>
using AuToIterator_t = typename T::iterator;
template <class T, class U>
struct AuIsSame : AuFalseType
{};
template <class T>
struct AuIsSame<T, T> : AuTrueType
{};
template <class T, class U>
inline constexpr bool AuIsSame_v = AuIsSame<T, U>::value;
namespace _audetail
{
template <class T>
AuBoolType<!__is_union(T)> IsClass(int T:: *);
template <class>
AuFalseType IsClass(...);
template <class B>
AuTrueType TestIsPtrConvertible(const volatile B *);
template <class>
AuFalseType TestIsPtrConvertible(const volatile void *);
template <class, typename>
auto TestIsBaseOf(...)->AuTrueType;
template <class B, typename D>
auto TestIsBaseOf(int) -> decltype(TestIsPtrConvertible<B>(static_cast<D *>(nullptr)));
}
template <class T>
struct AuIsClass : decltype(_audetail::IsClass<T>(nullptr))
{};
template <class T>
inline constexpr bool AuIsClass_v = AuIsClass<T>::value;
template <class Base, typename Derived>
struct AuIsBaseOf :
AuBoolType<
AuIsClass_v<Base> &&
AuIsClass_v<Derived> &&
decltype(_audetail::TestIsBaseOf<Base, Derived>(0))::value
>
{};
template <class Base, typename Derived>
inline constexpr bool AuIsBaseOf_v = AuIsBaseOf<Base, Derived>::value;
template <class>
inline constexpr bool AuIsPointer_v = false;
template <class T>
inline constexpr bool AuIsPointer_v<T *> = true;
template <class T>
inline constexpr bool AuIsPointer_v<T *const> = true;
template <class T>
inline constexpr bool AuIsPointer_v<T *volatile> = true;
template <class T>
inline constexpr bool AuIsPointer_v<T *const volatile> = true;
template <class>
inline constexpr bool AuIsReference_v = false;
template <class T>
inline constexpr bool AuIsReference_v<T &> = true;
template <class T>
inline constexpr bool AuIsReference_v<T &&> = true;
template <class>
inline constexpr bool AuIsLValueReference_v = false;
template <class T>
inline constexpr bool AuIsLValueReference_v<T &> = true;
template <class>
inline constexpr bool AuIsRValueReference_v = false;
template <class T>
inline constexpr bool AuIsRValueReference_v<T &&> = true;
template <class T>
struct AuRemovePointer
{
typedef T type;
};
template <class T>
struct AuRemovePointer<T *>
{
typedef T type;
};
template <class T>
struct AuRemovePointer<T *const>
{
typedef T type;
};
template <class T>
struct AuRemovePointer<T *volatile>
{
typedef T type;
};
template <class T>
struct AuRemovePointer<T *const volatile>
{
typedef T type;
};
template <class T>
using AuRemovePointer_t = typename AuRemovePointer<T>::type;
template <class T>
using AuIsVoid = AuIsSame<void, T>;
template <class T>
inline constexpr bool AuIsVoid_v = AuIsVoid<T>::value;
template <class T>
struct AuRemoveReference
{
using type = T;
};
template <class T>
struct AuRemoveReference<T &>
{
using type = T;
};
template <class T>
struct AuRemoveReference<T &&>
{
using type = T;
};
template <class T>
using AuRemoveReference_t = typename AuRemoveReference<T>::type;
template <class T>
struct AuRemoveConst
{
typedef T type;
};
template <class T>
struct AuRemoveConst<const T>
{
typedef T type;
};
template <class T>
using AuRemoveConst_t = typename AuRemoveConst<T>::type;
template <bool Test, class T = void>
struct AuEnableIf
{};
template <class T>
struct AuEnableIf<true, T>
{
using type = T;
};
template <class T>
struct AuAddPointer
{
using type = AuRemoveReference_t<T> *;
};
template <class T>
using AuAddPointer_t = typename AuAddPointer<T>::type;
template <class T>
struct AuAddLReference
{
using type = AuRemoveReference_t<T> &;
};
template <class T>
using AuAddLReference_t = typename AuAddLReference<T>::type;
template <class T>
struct AuAddRReference
{
using type = AuRemoveReference_t<T> &&;
};
template <class T>
using AuAddRReference_t = typename AuAddRReference<T>::type;
template <class T>
AuAddRReference_t<T> AuDeclVal();
template <class T>
struct AuAddConst
{
using type = const T;
};
template <class T>
using AuAddConst_t = typename AuAddConst<T>::type;
template <class T>
using AuAddRemoveCV_t = AuRemoveConst_t<AuRemoveReference_t<T>>;
template <class T>
struct AuRemoveExtent
{
using type = T;
};
template <class T>
struct AuRemoveExtent<T[]>
{
using type = T;
};
template <class T, AuUInt Len>
struct AuRemoveExtent<T[Len]>
{
using type = T;
};
template <class T>
using AuRemoveExtent_t = typename AuRemoveExtent<T>::type;
template <class>
constexpr inline bool AuIsArray_v = false;
template <class T, size_t Len>
inline constexpr bool AuIsArray_v<T[Len]> = true;
template <class T>
inline constexpr bool AuIsArray_v<T[]> = true;
template <bool Test, class T = void>
using AuEnableIf_t = typename AuEnableIf<Test, T>::type;
template <class T, class ... Args>
struct AuIsConstructible
{
template <class T, class ... Args> static constexpr AuTrueType Test(decltype(T(AuDeclVal<Args>()...)));
template <class T, class ... Args> static constexpr AuFalseType Test(...);
using type = decltype(Test<T, Args...>(0));
};
template <class T, class ... Args>
using AuIsConstructible_t = typename AuIsConstructible<T, Args ...>::type;
template <class T, class ... Args>
inline constexpr bool AuIsConstructible_v = AuIsConstructible_t<T, Args ...>::value;
template <bool Test, class T, class T2>
struct AuConditional
{
using type = T;
};
template <class T, class T2>
struct AuConditional<false, T, T2>
{
using type = T2;
};
template <bool Test, class T, class T2>
using AuConditional_t = typename AuConditional<Test, T, T2>::type;
template <class T>
using AuDecay_t = AuConditional_t<
AuIsArray_v<T>,
AuAddPointer_t<AuRemoveExtent_t<T>>,
AuConditional_t<
AuIsFunction_v<T>,
AuAddPointer_t<T>,
AuAddRemoveCV_t<T>
>
>;
template <template <class...> class Base, typename Derived>
struct AuIsBaseOfTemplateImpl
{
template <class... Ts>
static constexpr AuTrueType Test(const Base<Ts...> *);
static constexpr AuFalseType Test(...);
using type = decltype(Test(AuDeclVal<AuRemoveReference_t<Derived> *>()));
};
template <template <class...> class Base, typename Derived>
using AuIsBaseOfTemplate = typename AuIsBaseOfTemplateImpl<Base, Derived>::type;
template <template <class...> class Base, typename Derived>
inline constexpr bool AuIsBaseOfTemplate_v = AuIsBaseOfTemplateImpl<Base, Derived>::type::value;

View File

@ -1,172 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTemplateMetaIsFunction.hpp
Date: 2022-3-28
Author: Reece
Copy/pasted: https://en.cppreference.com/w/cpp/types/AuIsFunction
***/
#pragma once
// primary
template <class>
struct AuIsFunction : AuFalseType { };
// specialization for regular functions
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...)> : AuTrueType {};
// specialization for variadic functions such as std::printf
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......)> : AuTrueType {};
// specialization for function types that have cv-qualifiers
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile> : AuTrueType {};
// specialization for function types that have ref-qualifiers
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile &&> : AuTrueType {};
// specializations for noexcept versions of all the above (C++17 and later)
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile && noexcept> : AuTrueType {};
template <class T>
inline constexpr bool AuIsFunction_v = AuIsFunction<T>::value;

View File

@ -1,8 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTransform.hpp
Date: 2022-2-1
Author: Reece
***/
#pragma once

View File

@ -1,37 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTryConstruct.hpp
Date: 2022-3-25
Author: Reece
***/
#pragma once
struct AuCtorErrorTag
{
/*
Thy shall fulfill the following requirements:
operator bool() const;
static constexpr AuCtorErrorTag Failed ();
static constexpr AuCtorErrorTag Success();
*/
};
struct AuCtorCode_t : AuCtorErrorTag
{
bool value;
inline constexpr AuCtorCode_t()
{};
inline constexpr AuCtorCode_t(bool val) : value(val)
{};
operator bool() const
{
return value;
}
static constexpr AuCtorCode_t Failed () { return AuCtorCode_t {false}; }
static constexpr AuCtorCode_t Success() { return AuCtorCode_t {true}; }
};

View File

@ -1,94 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTryConstruct.hpp
Date: 2022-3-25
Author: Reece
***/
#pragma once
#define _AU_TRYCONTRUST_CHECKCODE AU_TEMPLATE_ENABLE_WHEN(AuIsBaseOf_v<AuCtorErrorTag, CtorCode_t>)
template <class T, class CtorCode_t = AuCtorCode_t, typename ... Args, _AU_TRYCONTRUST_CHECKCODE>
inline T AuTryConstruct(CtorCode_t &status, Args&& ... args)
{
if constexpr (AuIsConstructible_v<T, CtorCode_t &, Args ...>)
{
status = CtorCode_t::Failed();
return T(AuReference(status), AuForward<Args>(args)...);
}
else if constexpr (AuIsConstructible_v<T, Args ..., CtorCode_t &>)
{
status = CtorCode_t::Failed();
return T(AuForward<Args>(args)..., AuReference(status));
}
else
{
try
{
status = CtorCode_t::Success();
return T(AuForward<Args>(args)...);
}
catch (...)
{
status = CtorCode_t::Failed();
return T();
}
}
}
template <class T, class CtorCode_t = AuCtorCode_t, typename ... Args, _AU_TRYCONTRUST_CHECKCODE>
inline AuPair<CtorCode_t, T> AuTryConstructPair(Args&& ... args)
{
CtorCode_t code;
T object = AuTryConstruct<T, CtorCode_t, Args...>(AuReference(code), AuForward<Args>(args)...);
return AuMakePair(AuMove(code), AuMove(object));
}
template <class T, class CtorCode_t = AuCtorCode_t, typename ... Args, _AU_TRYCONTRUST_CHECKCODE>
inline T AuTryConstructWithDefault(CtorCode_t &status, T &&def, Args&& ... args)
{
if constexpr (AuIsConstructible_v<T, CtorCode_t &, Args ...>)
{
status = CtorCode_t::Failed();
T returnValue = T(AuReference(status), AuForward<Args>(args)...);
if (!status)
{
return AuMove(def);
}
return returnValue;
}
else if constexpr (AuIsConstructible_v<T, Args ..., CtorCode_t &>)
{
status = CtorCode_t::Failed();
T returnValue = T(AuForward<Args>(args)..., AuReference(status));
if (!status)
{
return AuMove(def);
}
return returnValue;
}
else
{
try
{
status = CtorCode_t::Success();
return T(AuForward<Args>(args)...);
}
catch (...)
{
status = CtorCode_t::Failed();
return AuMove(def);
}
}
}
template <class T, class CtorCode_t = AuCtorCode_t, typename ... Args, _AU_TRYCONTRUST_CHECKCODE>
inline AuPair<CtorCode_t, T> AuTryConstructWithDefaultPair(T &&def, Args&& ... args)
{
CtorCode_t code;
T object = AuTryConstructWithDefault<T, CtorCode_t, Args...>(AuReference(code), AuFoward(def), AuForward<Args>(args)...);
return AuMakePair(AuMove(code), AuMove(object));
}
#undef _AU_TRYCONTRUST_CHECKCODE

View File

@ -1,25 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTuple.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTIME_AU_PAIR)
#define AURORA_RUNTIME_AU_PAIR std::pair
#endif
template <class A_t, typename B_t>
using AuPair = AURORA_RUNTIME_AU_PAIR<A_t, B_t>;
#if !defined(AURORA_RUNTIME_AU_TUPLE)
#define AURORA_RUNTIME_AU_TUPLE std::tuple
#endif
template <class... Types>
using AuTuple = AURORA_RUNTIME_AU_TUPLE<Types...>;

View File

@ -1,180 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTupleUtils.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#include "auIntegerSequence.hpp"
#if !defined(AURORA_RUNTIME_MAKE_PAIR)
#define AURORA_RUNTIME_MAKE_PAIR std::make_pair
#endif
#if !defined(AURORA_RUNTIME_MAKE_TUPLE)
#define AURORA_RUNTIME_MAKE_TUPLE std::make_tuple
#endif
#if !defined(AURORA_RUNTIME_GET_TUPLE)
#define AURORA_RUNTIME_GET_TUPLE std::get
#endif
#if !defined(AURORA_RUNTIME_TUPLE_CAT)
#define AURORA_RUNTIME_TUPLE_CAT std::tuple_cat
#endif
#if !defined(AURORA_RUNTIME_TUPLE_SIZE)
#define AURORA_RUNTIME_TUPLE_SIZE std::tuple_size
#endif
#if !defined(AURORA_RUNTIME_APPLY)
#define AURORA_RUNTIME_APPLY std::apply
#endif
template <class... Args>
static auto AuMakePair(Args&&... args)
{
return AURORA_RUNTIME_MAKE_PAIR(AuForward<Args>(args)...);
}
template <class... Args>
static auto AuMakeTuple(Args&&... args)
{
return AURORA_RUNTIME_MAKE_TUPLE(AuForward<Args>(args)...);
}
template <AuUInt N, typename... Args>
static auto &AuGet(Args&&... args)
{
return AURORA_RUNTIME_GET_TUPLE<N>(AuForward<Args>(args)...);
}
template <class... Args>
static auto AuTupleCat(Args&&... args)
{
return AURORA_RUNTIME_TUPLE_CAT(AuForward<Args>(args)...);
}
template <class F, class Tuple>
static auto AuTupleApply(F &&f, Tuple &&t)
{
return AURORA_RUNTIME_APPLY(f, t);
}
template <class T>
inline constexpr AuUInt AuTupleCountOf_v = AURORA_RUNTIME_TUPLE_SIZE<AuRemoveConst_t<AuRemoveReference_t<T>>>::value;
namespace __audetail
{
template <AuUInt Offset, class Tuple, AuUInt... Is>
static auto AuTuplePopImpl(const Tuple &tuple, AuIndexSequence<Is...>)
{
return AURORA_RUNTIME_MAKE_TUPLE(AuGet<Is + Offset>(tuple)...);
}
}
template <class... Ts>
static auto AuTuplePopFront(const AuTuple<Ts...> &tuple)
{
return __audetail::AuTuplePopImpl<1>(tuple, AuMakeIndexSequence<AuTupleCountOf_v<decltype(tuple)> -1>());
}
template <class... Ts>
static auto AuTuplePopBack(const AuTuple<Ts...> &tuple)
{
return __audetail::AuTuplePopImpl<0>(tuple, AuMakeIndexSequence<AuTupleCountOf_v<decltype(tuple)> - 1>());
}
template <class T, class... Ts>
static auto AuTuplePushFront(const AuTuple<Ts...> &tuple, const T &t)
{
return AURORA_RUNTIME_TUPLE_CAT(AURORA_RUNTIME_MAKE_TUPLE(t), tuple);
}
template <class T, class... Ts>
static auto AuTuplePushFront(const AuTuple<Ts...> &tuple, T &&t)
{
return AURORA_RUNTIME_TUPLE_CAT(AURORA_RUNTIME_MAKE_TUPLE(t), tuple);
}
template <class T, class... Ts>
static auto AuTuplePushBack(const AuTuple<Ts...> &tuple, const T &t)
{
return AURORA_RUNTIME_TUPLE_CAT(tuple, AURORA_RUNTIME_MAKE_TUPLE(t));
}
template <class T, class... Ts>
static auto AuTuplePushBack(const AuTuple<Ts...> &tuple, T &&t)
{
return AURORA_RUNTIME_TUPLE_CAT(tuple, AURORA_RUNTIME_MAKE_TUPLE(t));
}
template <AuUInt Start, AuUInt Length, class... Ts>
static auto AuTupleTakeRange(const AuTuple<Ts...> &tuple)
{
return __audetail::AuTuplePopImpl<Start>(tuple, AuMakeIndexSequence<Length>());
}
template <class Tuple, class Invokable>
static void AuTupleForEach(const Tuple &tuple, const Invokable &callback)
{
AURORA_RUNTIME_APPLY([callback](auto& ...x)
{
(..., callback(x));
}, tuple);
}
template <class ... Args>
static constexpr AuTuple<Args& ...> AuTupleTie(Args& ... args)
{
return AuTuple<Args&...>(args...);
}
template <class ... Args>
static constexpr AuTuple<Args&& ...> AuTupleForward(Args&& ... args)
{
return AuTuple<Args&&...>(AuForward<Args>(args)...);
}
// Stolen: https://codereview.stackexchange.com/questions/193420/apply-a-function-to-each-element-of-a-tuple-map-a-tuple
namespace __audetail
{
template <class Fn, typename Argument, AuUInt... Ns>
static auto AuTupleTransformImpl(const Fn &fn, Argument &&argument, AuIndexSequence<Ns...>)
{
if constexpr (sizeof...(Ns) == 0)
{
return AuTuple<>();
}
else if constexpr (AuIsSame_v<decltype(fn(AuGet<0>(argument))), void>)
{
(fn(AuGet<Ns>(argument)), ...);
return;
}
else if constexpr (AuIsLValueReference_v<decltype(fn(AuGet<0>(argument)))>)
{
return AuTupleTie(fn(AuGet<Ns>(argument))...);
}
else if constexpr (AuIsRValueReference_v<decltype(fn(AuGet<0>(argument)))>)
{
return AuTupleForward(fn(AuGet<Ns>(argument))...);
}
else
{
return AuTuple(fn(AuGet<Ns>(argument))...);
}
}
}
template <class Invokable, typename... Ts>
static auto AuTupleTransform(const AuTuple<Ts...> &tuple, const Invokable &translate)
{
return __audetail::AuTupleTransformImpl(translate,
tuple,
AuMakeIndexSequence<sizeof...(Ts)>());
}

View File

@ -1,386 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTypeUtils.hpp
Date: 2022-2-10
Author: Reece
***/
#pragma once
#include "auEndianness.hpp"
#if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86) || defined(AURORA_ARCH_ARM)
#define AURORA_PERMIT_ARBITRARY_REF
#endif
template <class T>
static auline T AuReadGenericLE(const void *ptr, int offset)
{
#if defined(AURORA_PERMIT_ARBITRARY_REF)
T temp = *reinterpret_cast<const T *>(reinterpret_cast<const AuUInt8 *>(ptr) + offset);
#else
T temp;
AuMemcpy(&temp, reinterpret_cast<const AuUInt8 *>(ptr) + offset, sizeof(temp));
#endif
if constexpr (sizeof(T) != 1)
{
#if !defined(AU_CPU_ENDIAN_LITTLE)
temp = AuFlipEndian(temp);
#endif
}
return temp;
}
template <class T>
static auline T AuReadGenericBE(const void *ptr, int offset)
{
#if defined(AURORA_PERMIT_ARBITRARY_REF)
T temp = *reinterpret_cast<const T *>(reinterpret_cast<const AuUInt8 *>(ptr) + offset);
#else
T temp;
AuMemcpy(&temp, reinterpret_cast<const AuUInt8 *>(ptr) + offset, sizeof(temp));
#endif
if constexpr (sizeof(T) != 1)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
temp = AuFlipEndian(temp);
#endif
}
return temp;
}
static auline AuUInt64 AuReadU64LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuUInt64>(ptr, offset);
}
static auline AuUInt32 AuReadU32LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuUInt32>(ptr, offset);
}
static auline AuUInt16 AuReadU16LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuUInt16>(ptr, offset);
}
static auline AuUInt8 AuReadU8LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuUInt8>(ptr, offset);
}
static auline AuInt64 AuReadS64LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuInt64>(ptr, offset);
}
static auline AuInt32 AuReadS32LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuInt32>(ptr, offset);
}
static auline AuInt16 AuReadS16LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuInt16>(ptr, offset);
}
static auline AuInt8 AuReadS8LE(const void *ptr, int offset)
{
return AuReadGenericLE<AuInt8>(ptr, offset);
}
static auline AuUInt64 AuReadU64BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuUInt64>(ptr, offset);
}
static auline AuUInt32 AuReadU32BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuUInt32>(ptr, offset);
}
static auline AuUInt16 AuReadU16BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuUInt16>(ptr, offset);
}
static auline AuUInt8 AuReadU8BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuUInt8>(ptr, offset);
}
static auline AuInt64 AuReadS64BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuInt64>(ptr, offset);
}
static auline AuInt32 AuReadS32BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuInt32>(ptr, offset);
}
static auline AuInt16 AuReadS16BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuInt16>(ptr, offset);
}
static auline AuInt8 AuReadS8BE(const void *ptr, int offset)
{
return AuReadGenericBE<AuInt8>(ptr, offset);
}
static auline AuUInt64 AuReadU64(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadU64LE(ptr, offset);
#else
return AuReadU64BE(ptr, offset);
#endif
}
static auline AuUInt32 AuReadU32(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadU32LE(ptr, offset);
#else
return AuReadU32BE(ptr, offset);
#endif
}
static auline AuUInt16 AuReadU16(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadU16LE(ptr, offset);
#else
return AuReadU16BE(ptr, offset);
#endif
}
static auline AuUInt8 AuReadU8(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadU8LE(ptr, offset);
#else
return AuReadU8BE(ptr, offset);
#endif
}
static auline AuInt64 AuReadS64(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadS64LE(ptr, offset);
#else
return AuReadS64BE(ptr, offset);
#endif
}
static auline AuInt32 AuReadS32(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadS32LE(ptr, offset);
#else
return AuReadS32BE(ptr, offset);
#endif
}
static auline AuInt16 AuReadS16(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadS16LE(ptr, offset);
#else
return AuReadS16BE(ptr, offset);
#endif
}
static auline AuInt8 AuReadS8(const void *ptr, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
return AuReadS8LE(ptr, offset);
#else
return AuReadS8BE(ptr, offset);
#endif
}
template <class T>
static auline void AuWriteGenericLE(void *ptr, int offset, T value)
{
#if !defined(AU_CPU_ENDIAN_LITTLE)
value = AuFlipEndian(value);
#endif
#if defined(AURORA_PERMIT_ARBITRARY_REF)
*reinterpret_cast<T *>(reinterpret_cast<AuUInt8 *>(ptr) + offset) = value;
#else
AuMemcpy(reinterpret_cast<AuUInt8 *>(ptr) + offset, &value, sizeof(value));
#endif
}
template <class T>
static auline void AuWriteGenericBE(void *ptr, T value, int offset)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
value = AuFlipEndian(value);
#endif
#if defined(AURORA_PERMIT_ARBITRARY_REF)
*reinterpret_cast<T *>(reinterpret_cast<AuUInt8 *>(ptr) + offset) = value;
#else
AuMemcpy(reinterpret_cast<AuUInt8 *>(ptr) + offset, &value, sizeof(value));
#endif
}
static auline void AuWriteU64LE(void *ptr, int offset, AuUInt64 value)
{
AuWriteGenericLE<AuUInt64>(ptr, offset, value);
}
static auline void AuWriteU32LE(void *ptr, int offset, AuUInt32 value)
{
AuWriteGenericLE<AuUInt32>(ptr, offset, value);
}
static auline void AuWriteU16LE(void *ptr, int offset, AuUInt16 value)
{
AuWriteGenericLE<AuUInt16>(ptr, offset, value);
}
static auline void AuWriteU8LE(void *ptr, int offset, AuUInt8 value)
{
AuWriteGenericLE<AuUInt8>(ptr, offset, value);
}
static auline void AuWriteS64LE(void *ptr, int offset, AuInt64 value)
{
AuWriteGenericLE<AuInt64>(ptr, offset, value);
}
static auline void AuWriteS32LE(void *ptr, int offset, AuInt32 value)
{
AuWriteGenericLE<AuInt32>(ptr, offset, value);
}
static auline void AuWriteS16LE(void *ptr, int offset, AuInt16 value)
{
AuWriteGenericLE<AuInt16>(ptr, offset, value);
}
static auline void AuWriteS8LE(void *ptr, int offset, AuInt8 value)
{
AuWriteGenericLE<AuInt8>(ptr, offset, value);
}
static auline void AuWriteU64BE(void *ptr, int offset, AuUInt64 value)
{
AuWriteGenericBE<AuUInt64>(ptr, offset, value);
}
static auline void AuWriteU32BE(void *ptr, int offset, AuUInt32 value)
{
AuWriteGenericBE<AuUInt32>(ptr, offset, value);
}
static auline void AuWriteU16BE(void *ptr, int offset, AuUInt16 value)
{
AuWriteGenericBE<AuUInt16>(ptr, offset, value);
}
static auline void AuWriteU8BE(void *ptr, int offset, AuUInt8 value)
{
AuWriteGenericBE<AuUInt8>(ptr, offset, value);
}
static auline void AuWriteS64BE(void *ptr, int offset, AuInt64 value)
{
AuWriteGenericBE<AuInt64>(ptr, offset, value);
}
static auline void AuWriteS32BE(void *ptr, int offset, AuInt32 value)
{
AuWriteGenericBE<AuInt32>(ptr, offset, value);
}
static auline void AuWriteS16BE(void *ptr, int offset, AuInt16 value)
{
AuWriteGenericBE<AuInt16>(ptr, offset, value);
}
static auline void AuWriteS8BE(void *ptr, int offset, AuInt8 value)
{
AuWriteGenericBE<AuInt8>(ptr, offset, value);
}
static auline void AuWriteU64(void *ptr, int offset, AuUInt64 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteU64LE(ptr, offset, value);
#else
AuWriteU64BE(ptr, offset, value);
#endif
}
static auline void AuWriteU32(void *ptr, int offset, AuUInt32 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteU32LE(ptr, offset, value);
#else
AuWriteU32BE(ptr, offset, value);
#endif
}
static auline void AuWriteU16(void *ptr, int offset, AuUInt16 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteU16LE(ptr, offset, value);
#else
AuWriteU16BE(ptr, offset, value);
#endif
}
static auline void AuWriteU8(void *ptr, int offset, AuUInt8 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteU8LE(ptr, offset, value);
#else
AuWriteU8BE(ptr, offset, value);
#endif
}
static auline void AuWriteS64(void *ptr, int offset, AuInt64 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteS64LE(ptr, offset, value);
#else
AuWriteS64BE(ptr, offset, value);
#endif
}
static auline void AuWriteS32(void *ptr, int offset, AuInt32 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteS32LE(ptr, offset, value);
#else
AuWriteS32BE(ptr, offset, value);
#endif
}
static auline void AuWriteS16(void *ptr, int offset, AuInt16 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteS16LE(ptr, offset, value);
#else
AuWriteS16BE(ptr, offset, value);
#endif
}
static auline void AuWriteS8(void *ptr, int offset, AuInt8 value)
{
#if defined(AU_CPU_ENDIAN_LITTLE)
AuWriteS8LE(ptr, offset, value);
#else
AuWriteS8BE(ptr, offset, value);
#endif
}

View File

@ -1,30 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTypes.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
using AuUInt64 = Aurora::Types::uint64_t;
using AuUInt32 = Aurora::Types::uint32_t;
using AuUInt16 = Aurora::Types::uint16_t;
using AuUInt8 = Aurora::Types::uint8_t;
using AuInt64 = Aurora::Types::int64_t;
using AuInt32 = Aurora::Types::int32_t;
using AuInt16 = Aurora::Types::int16_t;
#if defined(_CPPSHARP)
using AuInt8 = Aurora::Types::uint8_t;
#else
using AuInt8 = Aurora::Types::int8_t;
#endif
using AuMach = Aurora::Types::size_t;
using AuSMach = Aurora::Types::ssize_t;
using AuSInt = AuSMach;
using AuUInt = AuMach;

View File

@ -1,7 +0,0 @@
#pragma once
// TODO:
using AuUTF8StringView = std::string_view;
using AuU8View = AuUTF8StringView;

View File

@ -1,112 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auUnitUtils.hpp
Date: 2022-3-13
Author: Reece
***/
#pragma once
/**
It is not unusual for one to desire a unit-conversion constant when the developer understands
[*] An FPU isn't available
[*] Using a framework to normalize to a base unit(?), apply a translation, and return the desired reuslt is considered overkill
These functions are not to be converted into such a convoluted templated potentially-constexpr castable mess
The intention is to keep these utility functions as simple as the dumb operations they implement
*/
template <class Inch, class Precision = Inch, class Feet>
constexpr const Inch AuFeetToInch(Feet feet)
{
return Inch(Precision(feet) * Precision(12));
}
template <class Feet, class Precision = Feet, class Inch>
constexpr const Feet AuInchToFeet(Inch inch)
{
return Feet(Precision(inch) / Precision(12));
}
template <class Inch, class CM>
constexpr const Inch AuCMToInch(CM cm)
{
return Inch(Inch(cm) * Inch(100) / Inch(254));
}
template <class CM, class Inch>
constexpr const CM AuInchToCM(Inch inch)
{
return CM(Inch(inch) * Inch(254) / Inch(100));
}
template <class M, class CM>
constexpr const M AuCMToM(CM cm)
{
return M(CM(cm) / CM(100));
}
template <class CM, class M>
constexpr const CM AuMToCM(M m)
{
return CM(CM(m) * CM(100));
}
template <class CM, class MM>
constexpr const CM AuMMToCM(MM mm)
{
return CM(MM(mm) / MM(10));
}
template <class MM, class CM>
constexpr const MM AuCMToMM(CM cm)
{
return MM(MM(cm) * MM(10));
}
template <class S, class MS>
constexpr const S AuMSToS(MS ms)
{
return S(MS(ms) / MS(1'000));
}
template <class MS, class S>
constexpr const MS AuSToMS(S s)
{
return MS(MS(s) * MS(1'000));
}
template <class MS, class NS>
constexpr const MS AuNSToMS(NS ns)
{
return MS(NS(ns) / NS(1'000'000));
}
template <class NS, class MS>
constexpr const NS AuMSToNS(MS ms)
{
return NS(NS(ms) * NS(1'000'000));
}
template <class F, class Precision = AuInt16, class C>
constexpr const F AuCToF(C c)
{
return F(Precision((Precision(c) * Precision(100)) / Precision(5) * Precision(9) + Precision(3200)) / Precision(100));
}
template <class C, class Precision = AuInt16, class F>
constexpr const C AuFToC(F f)
{
return C(((Precision(f) * Precision(100)) - Precision(3200)) * Precision(5) / Precision(9) / Precision(100));
}
template <class K, class Precision = AuInt16, class C>
constexpr const K AuCToK(C c)
{
return C(Precision(c) + Precision(273.15));
}
template <class C, class Precision = AuInt16, class K>
constexpr const C AuKToC(K k)
{
return C(Precision(k) - Precision(273.15));
}

View File

@ -1,50 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auVector.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#if defined(__has_include) && !defined(_AUHAS_GLM) && defined(_AU_DETECT_GLM)
#if __has_include(<glm/glm.hpp>)
#define _AUHAS_GLM
#endif
#endif
#if !defined(_AUHAS_GLM)
static int AuMemcmp(const void *dest, const void *src, size_t n);
template <int N>
struct AuFVec
{
float elements[N];
inline bool operator ==(const AuFVec &other) const
{
return AuMemcmp(other.elements, elements, sizeof(elements)) == 0;
}
inline float operator [](AuUInt idx) const
{
return elements[idx];
}
inline float &operator [](AuUInt idx)
{
return elements[idx];
}
};
using AuVec3 = AuFVec<3>;
using AuVec4 = AuFVec<4>;
#else
#include <glm/glm.hpp>
using AuVec3 = glm::vec3;
using AuVec4 = glm::vec4;
#endif

View File

@ -1,26 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auWin32Utils.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#if defined(AURORA_IS_MODERNNT_DERIVED) && (defined(_WINDOWS_) || defined(_OTHER_MS_MAIN_HEADER_GUARDS_HERE))
#define _AU_SAW_WIN32_EARLY
static auline void AuWin32CloseHandle(HANDLE &handle)
{
HANDLE local;
if ((local = AuExchange(handle, INVALID_HANDLE_VALUE)) != INVALID_HANDLE_VALUE)
{
CloseHandle(local);
}
}
#endif

View File

@ -1,63 +0,0 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auROXTLTypes.hpp
Date: 2022-2-2
Author: Reece
***/
#pragma once
#if !defined(AURORA_RUNTINE_TYPEDEFS_INCLUDE)
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <array>
#include <algorithm>
#include <unordered_map>
#include <memory>
#include <optional>
#include <functional>
#else
#if defined(AURORA_RUNTINE_TYPEDEFS_INCLUDE_HEADER)
#include <AURORA_RUNTINE_TYPEDEFS_INCLUDE_HEADER>
#endif
#endif
#include <auROXTL/auTypes.hpp>
#include <auROXTL/auTryConstruct.hpp>
#include <auROXTL/auTemplateMeta.hpp>
#include <auROXTL/auResult.hpp>
#include <auROXTL/auMemoryModel.hpp>
#include <auROXTL/auOptionalEx.hpp>
#include <auROXTL/auString.hpp>
#include <auROXTL/auUTF8StringView.hpp>
#include <auROXTL/auFunctional.hpp>
#include <auROXTL/auArray.hpp>
#include <auROXTL/auList.hpp>
#include <auROXTL/auHashMap.hpp>
#include <auROXTL/auBST.hpp>
#include <auROXTL/auTuple.hpp>
#include <auROXTL/auOptional.hpp>
#include <auROXTL/auVector.hpp>
namespace Aurora::Memory
{
inline void ThrowNullException()
{
AU_THROW_STRING("ExSharedPointer Null Access Violation");
}
}
#if defined(AURORA_COMPILER_MSVC)
using AuAtomicInt = long;
#else
using AuAtomicInt = int;
#endif
using AuStreamReadWrittenPair_t = AuPair<AuUInt32, AuUInt32>;
using AuThreadId_t = AuUInt64;
static const AuThreadId_t kThreadIdSpecialMask = AuThreadId_t(1) << AuThreadId_t(63);

View File

@ -1,77 +0,0 @@
/***
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
#include <auROXTL/auMemoryUtils.hpp>
#include <auROXTL/auCopyMoveUtils.hpp>
#include <auROXTL/auSwapExchangeUtils.hpp>
#include <auROXTL/auContainerUtils.hpp>
#include <auROXTL/auListUtils.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>
#include <auROXTL/auFNV1Utils.hpp>
#include <auROXTL/auHashUtils.hpp>
#include <auROXTL/auTryConstructUtils.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();
}
}
};