Pangolin
Header-only C++20 plane computational geometry library
Toggle main menu visibility
Loading...
Searching...
No Matches
handle.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
core/forward.hpp
"
4
15
16
#include <cstddef>
17
#include <cstdint>
18
#include <functional>
19
20
namespace
pgl
{
21
22
namespace
detail {
23
41
template
<
class
Tag>
42
class
Handle {
43
public
:
45
using
IndexType = std::uint32_t;
46
48
constexpr
Handle() =
default
;
49
55
constexpr
explicit
Handle(IndexType index) : index_(index) {}
56
58
[[nodiscard]]
constexpr
IndexType index()
const
{
59
return
index_;
60
}
61
63
[[nodiscard]]
constexpr
bool
valid()
const
{
64
return
index_ != invalidIndex;
65
}
66
68
constexpr
explicit
operator
bool()
const
{
69
return
valid();
70
}
71
73
constexpr
bool
operator==(
const
Handle&)
const
=
default
;
74
81
constexpr
auto
operator<=>(
const
Handle&)
const
=
default
;
82
83
private
:
84
static
constexpr
IndexType invalidIndex = ~IndexType{};
85
IndexType index_ = invalidIndex;
86
};
87
88
}
// namespace detail
89
90
}
// namespace pgl
91
92
namespace
std {
93
95
template
<
class
Tag>
96
struct
hash<pgl::detail::Handle<Tag>> {
98
std::size_t operator()(
const
pgl::detail::Handle<Tag>& handle)
const
noexcept
{
99
return
std::hash<std::uint32_t>{}(handle.index());
100
}
101
};
102
103
}
// namespace std
forward.hpp
Forward declarations for core numeric and geometry types.
pgl
Definition
arrangement.hpp:67
include
core
handle.hpp
Generated by
1.17.0