[+] AuIsOptional_v
[+] other internal detail impls for internal usage [*] Begin moving `_AUROXTL_DETAIAL_HAS` block to its own file
This commit is contained in:
parent
703df2a515
commit
6894c75262
@ -12,71 +12,6 @@
|
||||
|
||||
#include <auROXTL/auTupleUtils.hpp>
|
||||
|
||||
namespace __audetail
|
||||
{
|
||||
#define _AUROXTL_DETAIAL_HAS(name) \
|
||||
template <class T> \
|
||||
struct AuHas ## name \
|
||||
{ \
|
||||
template <class C> static constexpr AuTrueType Test(decltype(&C::name)); \
|
||||
template <class C> static constexpr AuFalseType Test(...); \
|
||||
using type = decltype(Test<T>(0)); \
|
||||
}; \
|
||||
\
|
||||
template <class T> \
|
||||
constexpr inline bool AuHas ## name ## _v = AuHas ## name<T>::type::value;
|
||||
|
||||
_AUROXTL_DETAIAL_HAS(capacity)
|
||||
_AUROXTL_DETAIAL_HAS(reserve)
|
||||
|
||||
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<typename C::const_iterator(C:: *)(const typename C::key_type &) const>(&C::find)));
|
||||
template <class C> static constexpr AuTrueType Test(decltype(static_cast<typename C::const_iterator(C:: *)(const typename 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<typename 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);
|
||||
|
@ -18,3 +18,6 @@
|
||||
template <class T>
|
||||
using AuOptional = AURORA_RUNTIME_AU_OPTIONAL<T>;
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
constexpr inline bool AuIsOptional_v = __audetail::AuHashas_value_v<T>;
|
||||
|
@ -25,10 +25,126 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include <auROXTL/auTypes.hpp>
|
||||
#include <auROXTL/auTryConstruct.hpp>
|
||||
#include <auROXTL/auTryCall.hpp>
|
||||
#include <auROXTL/auTemplateMeta.hpp>
|
||||
|
||||
// TODO: move to header
|
||||
// this needs to be after template mater and before containers and optional
|
||||
namespace __audetail
|
||||
{
|
||||
#define _AUROXTL_DETAIAL_HAS(name) \
|
||||
template <class T> \
|
||||
struct AuHas ## name \
|
||||
{ \
|
||||
template <class C> static constexpr AuTrueType Test(decltype(&C::name)); \
|
||||
template <class C> static constexpr AuFalseType Test(...); \
|
||||
using type = decltype(Test<T>(0)); \
|
||||
}; \
|
||||
\
|
||||
template <class T> \
|
||||
constexpr inline bool AuHas ## name ## _v = AuHas ## name<T>::type::value;
|
||||
_AUROXTL_DETAIAL_HAS(has_value);
|
||||
_AUROXTL_DETAIAL_HAS(capacity)
|
||||
_AUROXTL_DETAIAL_HAS(reserve)
|
||||
|
||||
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<typename C::const_iterator(C:: *)(const typename C::key_type &) const>(&C::find)));
|
||||
template <class C> static constexpr AuTrueType Test(decltype(static_cast<typename C::const_iterator(C:: *)(const typename 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 AuHasFind
|
||||
{
|
||||
template <class C> static constexpr AuTrueType Test(decltype(static_cast<typename C::const_iterator(C:: *)(const typename C::key_type &) const>(&C::Find)));
|
||||
template <class C> static constexpr AuTrueType Test(decltype(static_cast<typename C::const_iterator(C:: *)(const typename 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<typename 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>
|
||||
struct AuHasEnd
|
||||
{
|
||||
template <class C> static constexpr AuTrueType Test(decltype(static_cast<typename 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>
|
||||
struct AuHasbegin
|
||||
{
|
||||
template <class C> static constexpr AuTrueType Test(decltype(static_cast<typename C::const_iterator(C:: *)() const>(&C::begin)));
|
||||
template <class C> static constexpr AuFalseType Test(...);
|
||||
using type = decltype(Test<T>(0));
|
||||
};
|
||||
|
||||
template <class T>
|
||||
constexpr inline bool AuHasbegin_v = AuHasbegin<T>::type::value;
|
||||
|
||||
template <class T>
|
||||
struct AuHasBegin
|
||||
{
|
||||
template <class C> static constexpr AuTrueType Test(decltype(static_cast<typename C::const_iterator(C:: *)() const>(&C::Begin)));
|
||||
template <class C> static constexpr AuFalseType Test(...);
|
||||
using type = decltype(Test<T>(0));
|
||||
};
|
||||
|
||||
template <class T>
|
||||
constexpr inline bool AuHasBegin_v = AuHasBegin<T>::type::value;
|
||||
}
|
||||
|
||||
#include <auROXTL/auResult.hpp>
|
||||
#include <auROXTL/auMemoryModel.hpp>
|
||||
#include <auROXTL/auOptionalEx.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user