[+] Early reimplementation of string views

This commit is contained in:
Reece Wilson 2024-07-16 01:34:56 +01:00 committed by J Reece Wilson
parent 16b3c024c8
commit d2200907da
3 changed files with 1191 additions and 48 deletions

View File

@ -290,6 +290,17 @@ namespace AuHash
}
};
template <>
struct equal<AuROString>
{
using is_transparent = void;
bool operator()(std::string_view lhs, std::string_view rhs) const
{
return lhs == rhs;
}
};
template <>
struct equal<std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>>
{
@ -366,6 +377,30 @@ namespace AuHash
}
};
template <>
struct hash<AuROString>
{
using is_transparent = void;
using transparent_key_equal = equal<std::string>;
size_t operator()(AuROString txt) const
{
return hash<std::string_view>{}(txt);
}
};
template <>
struct hash<AuRONString>
{
using is_transparent = void;
using transparent_key_equal = equal<std::string>;
size_t operator()(AuROString txt) const
{
return hash<std::string_view>{}(txt);
}
};
template <>
struct hash<std::basic_string<char, std::char_traits<char>, Aurora::Memory::StringAllocator<char>>>
{
@ -426,6 +461,19 @@ namespace AuHash
{
bool operator()(AuRONString lhs, AuRONString rhs) const
{
#if 0
return AuFnv1aRuntime(lhs.data(), lhs.size()) < AuFnv1aRuntime(rhs.data(), rhs.size());
#else
return hash<std::string_view>{}(AuROString(lhs)) < hash<std::string_view>{}(AuROString(lhs));
#endif
}
};
template <>
struct less<AuROString>
{
bool operator()(AuROString lhs, AuROString rhs) const
{
#if 0
return AuFnv1aRuntime(lhs.data(), lhs.size()) < AuFnv1aRuntime(rhs.data(), rhs.size());
#else

View File

@ -14,10 +14,18 @@
#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_MEMCMP_) && AURORA_RUNTIME_MEMCMP_ == 1
#define AuMemcmp AURORA_RUNTIME_MEMCMP
#else
static auline int AuMemcmp(const void *dest, const void *src, size_t n)
{
return AURORA_RUNTIME_MEMCMP(dest, src, n);
}
#endif
#if !defined(AURORA_RUNTIME_MEMSET)
#define AURORA_RUNTIME_MEMSET std::memset

File diff suppressed because it is too large Load Diff