From 6894c75262f32d06365d935e835bbe283fed6715 Mon Sep 17 00:00:00 2001 From: Reece Date: Mon, 13 Mar 2023 17:11:01 +0000 Subject: [PATCH] [+] AuIsOptional_v [+] other internal detail impls for internal usage [*] Begin moving `_AUROXTL_DETAIAL_HAS` block to its own file --- Include/auROXTL/auContainerUtils.hpp | 65 --------------- Include/auROXTL/auOptional.hpp | 3 + Include/auROXTLTypes.hpp | 116 +++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 65 deletions(-) diff --git a/Include/auROXTL/auContainerUtils.hpp b/Include/auROXTL/auContainerUtils.hpp index a187d53..42a2a01 100644 --- a/Include/auROXTL/auContainerUtils.hpp +++ b/Include/auROXTL/auContainerUtils.hpp @@ -12,71 +12,6 @@ #include -namespace __audetail -{ -#define _AUROXTL_DETAIAL_HAS(name) \ - template \ - struct AuHas ## name \ - { \ - template static constexpr AuTrueType Test(decltype(&C::name)); \ - template static constexpr AuFalseType Test(...); \ - using type = decltype(Test(0)); \ - }; \ - \ - template \ - constexpr inline bool AuHas ## name ## _v = AuHas ## name::type::value; - - _AUROXTL_DETAIAL_HAS(capacity) - _AUROXTL_DETAIAL_HAS(reserve) - - template - constexpr inline bool AuIsPreallocatable_v = AuHascapacity_v && AuHasreserve_v; - - template - struct AuHastry_emplace - { - template static constexpr AuTrueType Test(decltype(&C::try_emplace)); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHastry_emplace_v = false;// ::type::value; - - template - struct AuHasemplace - { - template static constexpr AuTrueType Test(decltype(&C::emplace)); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHasemplace_v = true;//AuHasemplace::type::value; - - template - struct AuHasfind - { - template static constexpr AuTrueType Test(decltype(static_cast(&C::find))); - template static constexpr AuTrueType Test(decltype(static_cast(&C::find))); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHasfind_v = AuHasfind::type::value; - - template - struct AuHasend - { - template static constexpr AuTrueType Test(decltype(static_cast(&C::end))); - template static constexpr AuFalseType Test(...); - using type = decltype(Test(0)); - }; - - template - constexpr inline bool AuHasend_v = AuHasend::type::value; -} template inline bool _AuRemoveIfBase(T &in, const AuPredicate &> &predicate); diff --git a/Include/auROXTL/auOptional.hpp b/Include/auROXTL/auOptional.hpp index b123381..a80f988 100644 --- a/Include/auROXTL/auOptional.hpp +++ b/Include/auROXTL/auOptional.hpp @@ -18,3 +18,6 @@ template using AuOptional = AURORA_RUNTIME_AU_OPTIONAL; #endif + +template +constexpr inline bool AuIsOptional_v = __audetail::AuHashas_value_v; diff --git a/Include/auROXTLTypes.hpp b/Include/auROXTLTypes.hpp index c9aabd4..49ef2f0 100644 --- a/Include/auROXTLTypes.hpp +++ b/Include/auROXTLTypes.hpp @@ -25,10 +25,126 @@ #endif #endif + + #include #include #include #include + +// TODO: move to header +// this needs to be after template mater and before containers and optional +namespace __audetail +{ +#define _AUROXTL_DETAIAL_HAS(name) \ + template \ + struct AuHas ## name \ + { \ + template static constexpr AuTrueType Test(decltype(&C::name)); \ + template static constexpr AuFalseType Test(...); \ + using type = decltype(Test(0)); \ + }; \ + \ + template \ + constexpr inline bool AuHas ## name ## _v = AuHas ## name::type::value; + _AUROXTL_DETAIAL_HAS(has_value); + _AUROXTL_DETAIAL_HAS(capacity) + _AUROXTL_DETAIAL_HAS(reserve) + + template + constexpr inline bool AuIsPreallocatable_v = AuHascapacity_v && AuHasreserve_v; + + template + struct AuHastry_emplace + { + template static constexpr AuTrueType Test(decltype(&C::try_emplace)); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHastry_emplace_v = false;// ::type::value; + + template + struct AuHasemplace + { + template static constexpr AuTrueType Test(decltype(&C::emplace)); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHasemplace_v = true;//AuHasemplace::type::value; + + template + struct AuHasfind + { + template static constexpr AuTrueType Test(decltype(static_cast(&C::find))); + template static constexpr AuTrueType Test(decltype(static_cast(&C::find))); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHasfind_v = AuHasfind::type::value; + + template + struct AuHasFind + { + template static constexpr AuTrueType Test(decltype(static_cast(&C::Find))); + template static constexpr AuTrueType Test(decltype(static_cast(&C::Find))); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHasFind_v = AuHasFind::type::value; + + template + struct AuHasend + { + template static constexpr AuTrueType Test(decltype(static_cast(&C::end))); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHasend_v = AuHasend::type::value; + + template + struct AuHasEnd + { + template static constexpr AuTrueType Test(decltype(static_cast(&C::End))); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHasEnd_v = AuHasEnd::type::value; + + template + struct AuHasbegin + { + template static constexpr AuTrueType Test(decltype(static_cast(&C::begin))); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHasbegin_v = AuHasbegin::type::value; + + template + struct AuHasBegin + { + template static constexpr AuTrueType Test(decltype(static_cast(&C::Begin))); + template static constexpr AuFalseType Test(...); + using type = decltype(Test(0)); + }; + + template + constexpr inline bool AuHasBegin_v = AuHasBegin::type::value; +} + #include #include #include