1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef XPCOM_DS_NSTHASHMAP_H_
8 #define XPCOM_DS_NSTHASHMAP_H_
10 #include "mozilla/Attributes.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/UniquePtr.h"
13 #include "nsBaseHashtable.h"
15 #include "nsHashKeys.h"
16 #include "nsHashtablesFwd.h"
17 #include <type_traits>
19 namespace mozilla::detail
{
20 template <class KeyType
>
22 KeyType
, std::enable_if_t
<sizeof(KeyType
) &&
23 std::is_base_of_v
<PLDHashEntryHdr
, KeyType
>>> {
27 template <typename KeyType
>
28 struct nsKeyClass
<KeyType
*> {
29 using type
= nsPtrHashKey
<KeyType
>;
33 struct nsKeyClass
<nsCString
> {
34 using type
= nsCStringHashKey
;
37 // This uses the case-sensitive hash key class, if you want the
38 // case-insensitive hash key, use nsStringCaseInsensitiveHashKey explicitly.
40 struct nsKeyClass
<nsString
> {
41 using type
= nsStringHashKey
;
44 template <typename KeyType
>
45 struct nsKeyClass
<KeyType
, std::enable_if_t
<std::is_integral_v
<KeyType
> ||
46 std::is_enum_v
<KeyType
>>> {
47 using type
= nsIntegralHashKey
<KeyType
>;
51 struct nsKeyClass
<nsCOMPtr
<nsISupports
>> {
52 using type
= nsISupportsHashKey
;
56 struct nsKeyClass
<RefPtr
<T
>> {
57 using type
= nsRefPtrHashKey
<T
>;
61 struct nsKeyClass
<nsID
> {
62 using type
= nsIDHashKey
;
65 } // namespace mozilla::detail
67 // The actual definition of nsTHashMap is in nsHashtablesFwd.h, since it is a
70 #endif // XPCOM_DS_NSTHASHMAP_H_