no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / xpcom / ds / nsTHashMap.h
blob37aefbba87fafccbad3f9cfdc43ee3d9d48e10b3
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"
14 #include "nsCOMPtr.h"
15 #include "nsHashKeys.h"
16 #include "nsAtomHashKeys.h"
17 #include "nsHashtablesFwd.h"
18 #include <type_traits>
20 namespace mozilla::detail {
21 template <class KeyType>
22 struct nsKeyClass<
23 KeyType, std::enable_if_t<sizeof(KeyType) &&
24 std::is_base_of_v<PLDHashEntryHdr, KeyType>>> {
25 using type = KeyType;
28 template <typename KeyType>
29 struct nsKeyClass<KeyType*> {
30 using type = nsPtrHashKey<KeyType>;
33 template <>
34 struct nsKeyClass<nsAtom*> {
35 using type = nsWeakAtomHashKey;
38 template <typename Ret, typename... Args>
39 struct nsKeyClass<Ret (*)(Args...)> {
40 using type = nsFuncPtrHashKey<Ret (*)(Args...)>;
43 template <>
44 struct nsKeyClass<nsCString> {
45 using type = nsCStringHashKey;
48 // This uses the case-sensitive hash key class, if you want the
49 // case-insensitive hash key, use nsStringCaseInsensitiveHashKey explicitly.
50 template <>
51 struct nsKeyClass<nsString> {
52 using type = nsStringHashKey;
55 template <typename KeyType>
56 struct nsKeyClass<KeyType, std::enable_if_t<std::is_integral_v<KeyType> ||
57 std::is_enum_v<KeyType>>> {
58 using type = nsIntegralHashKey<KeyType>;
61 template <>
62 struct nsKeyClass<nsCOMPtr<nsISupports>> {
63 using type = nsISupportsHashKey;
66 template <typename T>
67 struct nsKeyClass<RefPtr<T>> {
68 using type = nsRefPtrHashKey<T>;
71 template <>
72 struct nsKeyClass<RefPtr<nsAtom>> {
73 using type = nsAtomHashKey;
76 template <>
77 struct nsKeyClass<nsID> {
78 using type = nsIDHashKey;
81 } // namespace mozilla::detail
83 // The actual definition of nsTHashMap is in nsHashtablesFwd.h, since it is a
84 // type alias.
86 #endif // XPCOM_DS_NSTHASHMAP_H_