Skip to content

Commit c7f58b1

Browse files
committed
heteregenous string maps
#feat
1 parent 3cc36a9 commit c7f58b1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// This is a derivative work. originally part of the LLVM Project.
3+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
// Copyright (c) 2025 Alan de Freitas ([email protected])
8+
//
9+
// Official repository: https://github.com/cppalliance/mrdocs
10+
//
11+
12+
#ifndef MRDOCS_API_ADT_UNORDEREDSTRINGMAP_HPP
13+
#define MRDOCS_API_ADT_UNORDEREDSTRINGMAP_HPP
14+
15+
#include <unordered_map>
16+
#include <string>
17+
18+
namespace clang::mrdocs {
19+
20+
struct string_hash
21+
{
22+
using hash_type = std::hash<std::string_view>;
23+
using is_transparent = void;
24+
std::size_t operator()(const char* str) const { return hash_type{}(str); }
25+
std::size_t operator()(std::string_view str) const { return hash_type{}(str); }
26+
std::size_t operator()(std::string const& str) const { return hash_type{}(str); }
27+
};
28+
29+
template <class T>
30+
using UnorderedStringMap = std::unordered_map<std::string, T, string_hash, std::equal_to<>>;
31+
32+
} // clang::mrdocs
33+
34+
#endif

0 commit comments

Comments
 (0)