[*] Finally enable independent string allocators
This commit is contained in:
parent
b3e0a6df31
commit
f2acc55b42
@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "auFNV1Utils.hpp"
|
||||
#include "auMemoryModel.hpp"
|
||||
|
||||
#define _AU_HASH_UTILS_HAS_STD
|
||||
|
||||
@ -256,6 +257,17 @@ namespace AuHash
|
||||
return lhs == rhs;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct equal<std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>>
|
||||
{
|
||||
using is_transparent = void;
|
||||
|
||||
bool operator()(std::string_view lhs, std::string_view rhs) const
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <class T, AU_TEMPLATE_ENABLE_WHEN(AuHasHashCode_v<T>)>
|
||||
@ -322,6 +334,18 @@ namespace AuHash
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>>
|
||||
{
|
||||
using is_transparent = void;
|
||||
using transparent_key_equal = equal<std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>>;
|
||||
|
||||
size_t operator()(std::string_view txt) const
|
||||
{
|
||||
return hash<std::string_view>{}(txt);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct less<std::string>
|
||||
{
|
||||
@ -337,6 +361,21 @@ namespace AuHash
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct less<std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>>
|
||||
{
|
||||
using is_transparent = void;
|
||||
|
||||
bool operator()(std::string_view lhs, std::string_view rhs) const
|
||||
{
|
||||
#if 0
|
||||
return AuFnv1aRuntime(lhs.data(), lhs.size()) < AuFnv1aRuntime(rhs.data(), rhs.size());
|
||||
#else
|
||||
return hash<std::string_view>{}(lhs) < hash<std::string_view>{}(rhs);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct less<std::string_view>
|
||||
{
|
||||
@ -380,4 +419,20 @@ struct AuEnableHashCodeOnData
|
||||
#if defined(_AU_HASH_RETARD_COMPILER)
|
||||
#undef _AU_HASH_RETARD_COMPILER
|
||||
#undef _AH_HAS_RETARD_CONSTEXPR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace AuHash
|
||||
{
|
||||
template <class T>
|
||||
struct hash<AuSPtr<T>>
|
||||
{
|
||||
AuUInt operator ()(const AuSPtr<T> &ptr) const
|
||||
{
|
||||
#if defined(AURORA_IS_32BIT)
|
||||
return ComputeUnseededHash(AuUInt(ptr.get()));
|
||||
#else
|
||||
return ComputeLongHash(AuUInt(ptr.get()));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
@ -309,20 +309,4 @@ namespace Aurora::Memory
|
||||
using StringAllocator = BaseAuroraRuntimeAllocator<T>;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace AuHash
|
||||
{
|
||||
template <class T>
|
||||
struct hash<AuSPtr<T>>
|
||||
{
|
||||
AuUInt operator ()(const AuSPtr<T> &ptr) const
|
||||
{
|
||||
#if defined(AURORA_IS_32BIT)
|
||||
return ComputeUnseededHash(AuUInt(ptr.get()));
|
||||
#else
|
||||
return ComputeLongHash(AuUInt(ptr.get()));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "auCopyMoveUtils.hpp"
|
||||
#include "auHashUtils.hpp"
|
||||
|
||||
template <class T>
|
||||
struct AuResult
|
||||
|
@ -15,5 +15,6 @@
|
||||
#elif defined(AURORA_ROXTL_STRING_USE_STR_ALLOCATOR)
|
||||
using AuString = std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>;
|
||||
#else
|
||||
using AuString = std::string;
|
||||
using AuString = std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>;
|
||||
//using AuString = std::string;
|
||||
#endif
|
||||
|
@ -1047,7 +1047,7 @@ static auline AuString AuToString(const T &obj)
|
||||
{
|
||||
#if defined(_AUHAS_FMT)
|
||||
// locale independent and better optimized!
|
||||
return fmt::format("{}", obj);
|
||||
return AuString(fmt::format("{}", obj));
|
||||
#else
|
||||
// TODO: to_chars (locale independent)
|
||||
return AURORA_RUNTIME_TO_STRING(obj);
|
||||
|
Loading…
Reference in New Issue
Block a user