llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
core
adt
id.h
1
// This file if part of the llir-opt project.
2
// Licensing information can be found in the LICENSE file.
3
// (C) 2018 Nandor Licker. All rights reserved.
4
5
#pragma once
6
7
#include <cstdint>
8
9
#include <llvm/Support/raw_ostream.h>
10
11
#include "core/adt/hash.h"
12
13
14
18
template
<
typename
T>
19
class
ID
final {
20
public
:
22
ID
(uint32_t
id
) : id_(id) { }
23
25
operator
uint32_t ()
const
{
return
id_; }
26
27
private
:
29
uint32_t id_;
30
};
31
32
36
template
<
typename
T>
37
struct
std::hash<
ID
<T>> {
38
std::size_t operator()(
const
ID<T>
&p)
const
39
{
40
return
std::hash<uint32_t>{}(
static_cast<
uint32_t
>
(p));
41
}
42
};
43
44
48
template
<
typename
T>
49
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
const
ID<T>
&
id
)
50
{
51
os << static_cast<uint32_t>(
id
);
52
return
os;
53
}
ID
Definition:
id.h:19
ID::ID
ID(uint32_t id)
Creates a new item.
Definition:
id.h:22
Generated by
1.8.17