jubilant-funicular
utilities
utils
typemap
TypeMap.cpp
1
#include "TypeMap.h"
2
3
namespace
utils {
4
void
*
TypeMap::find
(
const
TypeInfo
& info)
const
{
5
auto
it = m_map.find(info);
6
return
it == m_map.end() ? nullptr : it->second;
7
}
8
void
TypeMap::destroy(
const
TypeInfo
& info) {
9
if
(info.
is_reference
()) {
10
info.
destructor
(m_map[info]);
11
}
else
if
(info.
is_small
()) {
12
info.
destructor
(&m_map[info]);
13
}
else
{
14
info.
destructor
(m_map[info]);
15
operator
delete
(m_map[info]);
16
}
17
}
18
void
TypeMap::erase(
const
TypeInfo& info) {
19
if
(m_map.find(info) == m_map.end())
return
;
20
destroy(info);
21
m_map.erase(info);
22
}
23
void
TypeMap::clear() {
24
for
(
auto
& pair : m_map) {
25
destroy(pair.first);
26
}
27
m_map.clear();
28
}
29
}
utils::TypeMap::find
std::add_lvalue_reference< T >::type find() const
Definition:
TypeMap.h:133
utils::TypeInfo::destructor
std::function< void(void *)> destructor
The type's destructor.
Definition:
TypeMap.h:57
utils::TypeInfo::is_reference
bool is_reference() const
Is this a reference type.
Definition:
TypeMap.h:48
utils::TypeInfo
Struct for storing basic information about a type used by TypeMap.
Definition:
TypeMap.h:11
utils::TypeInfo::is_small
bool is_small() const
Returns false if this type is more bytes than a pointer.
Definition:
TypeMap.h:44
Generated by
1.8.17