AngouriMath
Sources
Wrappers
AngouriMath.CPP.Importing
FieldCache.h
1
#pragma once
2
3
#include "TypeAliases.h"
4
#include <optional>
5
6
namespace
AngouriMath::Internal
7
{
8
template
<
typename
T>
9
class
FieldCache
10
{
11
private
:
12
std::optional<T> cached;
13
public
:
14
// TODO: make thread-safe
15
template
<
typename
Factory>
16
const
T& GetValue(Factory&& factory, EntityRef ref)
17
{
18
if
(!cached.has_value())
19
cached = factory(ref);
20
return
this->cached.value();
21
}
22
};
23
}
AngouriMath::Internal
Definition:
AngouriMath.cpp:20
AngouriMath::Internal::FieldCache
Definition:
FieldCache.h:9
Generated by
1.8.13