EnTT 3.13.0
Loading...
Searching...
No Matches
monostate.hpp
1#ifndef ENTT_CORE_MONOSTATE_HPP
2#define ENTT_CORE_MONOSTATE_HPP
3
4#include "../config/config.h"
5#include "fwd.hpp"
6
7namespace entt {
8
20template<id_type>
21struct monostate {
27 template<typename Type>
28 void operator=(Type val) const noexcept {
29 value<Type> = val;
30 }
31
37 template<typename Type>
38 operator Type() const noexcept {
39 return value<Type>;
40 }
41
42private:
43 template<typename Type>
44 inline static ENTT_MAYBE_ATOMIC(Type) value{};
45};
46
51template<id_type Value>
53
54} // namespace entt
55
56#endif
EnTT default namespace.
Definition dense_map.hpp:21
monostate< Value > monostate_v
Helper variable template.
Definition monostate.hpp:52
Minimal implementation of the monostate pattern.
Definition monostate.hpp:21
void operator=(Type val) const noexcept
Assigns a value of a specific type to a given key.
Definition monostate.hpp:28