0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::js: Add an overload for hash(string) -> ircd::util::hash().

This commit is contained in:
Jason Volk 2016-11-24 18:40:35 -08:00
parent 3ec62bba09
commit 36a7ffba37

View file

@ -89,6 +89,8 @@ struct string
template<class T> constexpr bool is_string();
template<class A, class B> constexpr bool string_argument();
template<lifetime L> auto hash(const string<L> &s);
template<lifetime A, lifetime B> int cmp(const string<A> &a, const string<B> &b);
template<lifetime L> int cmp(const char *const &a, const string<L> &b);
template<lifetime L> int cmp(const string<L> &a, const char *const &b);
@ -127,6 +129,8 @@ using string = basic::string<lifetime::stack>;
using heap_string = basic::string<lifetime::heap>;
using persist_string = basic::string<lifetime::persist>;
using basic::hash;
//
// Implementation
//
@ -519,6 +523,14 @@ cmp(const string<A> &a,
return ret;
}
template<lifetime L>
auto
hash(const string<L> &s)
{
//TODO: optimize
return ircd::util::hash(std::u16string(s));
}
template<class A,
class B>
constexpr bool