diff --git a/Include/Aurora/Async/Async.hpp b/Include/Aurora/Async/Async.hpp index a593836c..9441550f 100644 --- a/Include/Aurora/Async/Async.hpp +++ b/Include/Aurora/Async/Async.hpp @@ -126,7 +126,7 @@ namespace Aurora::Async }; - #define ASYNC_ERROR(exp) { if constexpr (AuIsSame_v) { SysPushErrorGen(exp); return {}; } else { throw std::string(exp); } } + #define ASYNC_ERROR(exp) { if constexpr (AuIsSame_v) { SysPushErrorGen(exp); return {}; } else { throw AuString(exp); } } #define ASYNC_FINISH { if constexpr (AuIsSame_v) { return true; } } template || AuIsVoid_v)> diff --git a/Include/Aurora/Async/WorkBasic.hpp b/Include/Aurora/Async/WorkBasic.hpp index cb0f73a8..e4aefa2c 100644 --- a/Include/Aurora/Async/WorkBasic.hpp +++ b/Include/Aurora/Async/WorkBasic.hpp @@ -102,20 +102,20 @@ namespace Aurora::Async template static AuSPtr DispathSmartWork(const WorkerId_t &worker, AuSPtr owner, FunctorTask_t task, FuckYou_t job, Args ... in) { - return DispatchWork, Args...>, ReturnValue_t>(worker, - TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), - Async::JobFromTupleClazz, Args...>(job), - AuMakeTuple, Args...>(AU_FWD(owner), AuForward(in)...), - false); + return DispatchWork, Args...>, ReturnValue_t>(worker, + TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), + Async::JobFromTupleClazz, Args...>(job), + AuMakeTuple, Args...>(AU_FWD(owner), AuForward(in)...), + false); } template static AuSPtr DispathSmartWorkEx(const WorkerId_t &worker, AuSPtr owner, FunctorTask_t task, FuckYou_t success, FuckYou2_t failure, Args ... in) { - return DispatchWork, Args...>, ReturnValue_t>(worker, - TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), - Async::JobFromTupleClazzEx, Args...>(success, failure), - AuMakeTuple, Args...>(AU_FWD(owner), AuForward(in)...), - false); + return DispatchWork, Args...>, ReturnValue_t>(worker, + TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), + Async::JobFromTupleClazzEx, Args...>(success, failure), + AuMakeTuple, Args...>(AU_FWD(owner), AuForward(in)...), + false); } } \ No newline at end of file diff --git a/Include/AuroraMacros.hpp b/Include/AuroraMacros.hpp index 11eb69f8..ccee8db5 100644 --- a/Include/AuroraMacros.hpp +++ b/Include/AuroraMacros.hpp @@ -12,11 +12,11 @@ #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 (std::static_pointer_cast>(this->shared_from_this())) + #define AU_SHARED_FROM_THIS (AuStaticPointerCast>(this->shared_from_this())) #endif #if !defined(AU_WEAK_FROM_THIS) - #define AU_WEAK_FROM_THIS (AuWPtr>(std::static_pointer_cast>(this->shared_from_this()))) + #define AU_WEAK_FROM_THIS (AuWPtr>(AuStaticPointerCast>(this->shared_from_this()))) #endif #define AU_BRACKET_SCOPE(...) __VA_ARGS__ diff --git a/Include/AuroraTypedefs.hpp b/Include/AuroraTypedefs.hpp index aafd46c2..9af12109 100644 --- a/Include/AuroraTypedefs.hpp +++ b/Include/AuroraTypedefs.hpp @@ -61,16 +61,16 @@ namespace _audetail { template AuFalseType test(...); - template - std::true_type test_pre_ptr_convertible(const volatile B *); - template - std::false_type test_pre_ptr_convertible(const volatile void *); + template + AuTrueType test_pre_ptr_convertible(const volatile B *); + template + AuFalseType test_pre_ptr_convertible(const volatile void *); - template - auto test_pre_is_base_of(...)->std::true_type; - template - auto test_pre_is_base_of(int) -> - decltype(test_pre_ptr_convertible(static_cast(nullptr))); + template + auto test_pre_is_base_of(...) -> AuTrueType; + + template + auto test_pre_is_base_of(int) -> decltype(test_pre_ptr_convertible(static_cast(nullptr))); } template @@ -201,7 +201,6 @@ constexpr T &&AuForward(AuRemoveReference_t &&arg) noexcept return static_cast(arg); } - #if !defined(AURORA_RUNTIME_AU_LIST) #define AURORA_RUNTIME_AU_LIST std::vector #endif @@ -278,12 +277,27 @@ using AuWPtr = AURORA_RUNTIME_AU_WEAK_PTR; #define AURORA_RUNTIME_AU_UNIQUE_PTR std::unique_ptr #endif +template +using AuUPtr = AURORA_RUNTIME_AU_UNIQUE_PTR; + #if !defined(AURORA_RUNTIME_AU_DEFAULT_DELETER) -#define AURORA_RUNTIME_AU_DEFAULT_DELETER = std::default_delete +#define AURORA_RUNTIME_AU_DEFAULT_DELETER std::default_delete #endif -template -using AuUPtr = AURORA_RUNTIME_AU_UNIQUE_PTR; +template +using AuDefaultDeleter = AURORA_RUNTIME_AU_DEFAULT_DELETER; + +template +AuSPtr AuStaticPointerCast(const AuSPtr &other) noexcept +{ + return AuSPtr(other, static_cast::element_type *>(other.get())); +} + +template +AuSPtr AuStaticPointerCast(AuSPtr &&other) noexcept +{ + return AuSPtr(AuMove(other), static_cast::element_type *>(other.get())); +} #if !defined(AURORA_RUNTIME_AU_PAIR) #define AURORA_RUNTIME_AU_PAIR std::pair diff --git a/Include/AuroraUtils.hpp b/Include/AuroraUtils.hpp index b908686a..a377b01e 100644 --- a/Include/AuroraUtils.hpp +++ b/Include/AuroraUtils.hpp @@ -282,7 +282,7 @@ template static auline AuOptional> AuOptionalSharedStaticCast(AuOptional> &in) { if (!in.has_value()) return {}; - return std::static_pointer_cast(in.value()); + return AuStaticPointerCast(in.value()); } static auline bool AuEndsWith(AuString const &value, AuString const &ending) @@ -644,8 +644,8 @@ template class base,typename derived> struct is_base_of_template_impl_au { template - static constexpr std::true_type test(const base *); - static constexpr std::false_type test(...); + static constexpr AuTrueType test(const base *); + static constexpr AuFalseType test(...); using type = decltype(test(std::declval())); }; diff --git a/Source/Async/ThreadPool.cpp b/Source/Async/ThreadPool.cpp index b0d6bc2e..c0a06850 100644 --- a/Source/Async/ThreadPool.cpp +++ b/Source/Async/ThreadPool.cpp @@ -885,7 +885,7 @@ namespace Aurora::Async auto pid = GetCurrentWorkerPId(); if (pid.pool) { - std::static_pointer_cast(pid.pool)->ThisExiting(); + AuStaticPointerCast(pid.pool)->ThisExiting(); } })); diff --git a/Source/Async/WorkItem.cpp b/Source/Async/WorkItem.cpp index fa94dcd7..a6280507 100644 --- a/Source/Async/WorkItem.cpp +++ b/Source/Async/WorkItem.cpp @@ -332,7 +332,7 @@ namespace Aurora::Async static auto GetWorkerInternal(const AuSPtr &pool) { - return std::static_pointer_cast(pool).get(); + return AuStaticPointerCast(pool).get(); } static auto GetWorkerInternal() diff --git a/Source/Compression/BlockDecompressor.cpp b/Source/Compression/BlockDecompressor.cpp index f5a97058..ac5793f0 100644 --- a/Source/Compression/BlockDecompressor.cpp +++ b/Source/Compression/BlockDecompressor.cpp @@ -395,8 +395,8 @@ namespace Aurora::Compression auto bufferSize = meta.internalStreamSize / 2; - auto bufferIn = AuSPtr(new char[bufferSize], std::default_delete()); - auto bufferOut = AuSPtr(new char[bufferSize], std::default_delete()); + auto bufferIn = AuSPtr(new char[bufferSize], AuDefaultDeleter()); + auto bufferOut = AuSPtr(new char[bufferSize], AuDefaultDeleter()); while (inputStat < input) { diff --git a/Source/Compression/StreamCompression.cpp b/Source/Compression/StreamCompression.cpp index 6003441a..2170b78b 100644 --- a/Source/Compression/StreamCompression.cpp +++ b/Source/Compression/StreamCompression.cpp @@ -518,9 +518,9 @@ namespace Aurora::Compression pref.compressionLevel = info.compressionLevel; auto maxFrameSize = info.lz4BlockSize ? info.lz4BlockSize : 64 * 1024; - auto buffer = AuSPtr(new char[maxFrameSize], std::default_delete()); + auto buffer = AuSPtr(new char[maxFrameSize], AuDefaultDeleter()); auto maxOut = LZ4F_compressBound(maxFrameSize, &pref); - auto outBuffer = AuSPtr(new char[maxOut], std::default_delete());; + auto outBuffer = AuSPtr(new char[maxOut], AuDefaultDeleter());; auto err = LZ4F_createCompressionContext(&cctxPtr, LZ4F_getVersion()); if (LZ4F_isError(err)) @@ -598,8 +598,8 @@ namespace Aurora::Compression { return false; } - bufferIn = AuSPtr(new char[frameMaxSize / 2], std::default_delete()); - bufferOut = AuSPtr(new char[frameMaxSize / 2], std::default_delete()); + bufferIn = AuSPtr(new char[frameMaxSize / 2], AuDefaultDeleter()); + bufferOut = AuSPtr(new char[frameMaxSize / 2], AuDefaultDeleter()); while (true) { diff --git a/Source/Console/ConsoleMessage.cpp b/Source/Console/ConsoleMessage.cpp index f9a70f1c..ca281e96 100644 --- a/Source/Console/ConsoleMessage.cpp +++ b/Source/Console/ConsoleMessage.cpp @@ -10,7 +10,7 @@ namespace Aurora::Console { - static AuArray(EAnsiColor::eCount)> kAnsiCheats + static AuArray(EAnsiColor::eCount)> kAnsiCheats { "\033[0;31m", "\033[1;31m", diff --git a/Source/IO/FS/Async.NT.cpp b/Source/IO/FS/Async.NT.cpp index 8690e9f5..666f912a 100644 --- a/Source/IO/FS/Async.NT.cpp +++ b/Source/IO/FS/Async.NT.cpp @@ -299,7 +299,7 @@ namespace Aurora::IO::FS for (const auto & file : files) { - handles.push_back(std::static_pointer_cast(file)->GetHandle()); + handles.push_back(AuStaticPointerCast(file)->GetHandle()); } auto ret = WaitForMultipleObjectsEx(handles.size(), handles.data(), false, timeout ? timeout : INFINITE, TRUE); @@ -307,7 +307,7 @@ namespace Aurora::IO::FS #if 0 for (const auto &file : files) { - std::static_pointer_cast(file)->Complete(); + AuStaticPointerCast(file)->Complete(); } #endif diff --git a/Source/Memory/Heap.cpp b/Source/Memory/Heap.cpp index 82b5466d..414ee740 100644 --- a/Source/Memory/Heap.cpp +++ b/Source/Memory/Heap.cpp @@ -167,7 +167,7 @@ namespace Aurora::Memory if (!heap_) return nullptr; auto ptr = _FAlloc(length); if (!ptr) return nullptr; - std::memset(ptr, 0, length); + AuMemset(ptr, 0, length); return ptr; }