EnTT  3.10.0
ctx.hpp
1 #ifndef ENTT_META_CTX_HPP
2 #define ENTT_META_CTX_HPP
3 
4 #include "../config/config.h"
5 #include "../core/attribute.h"
6 
7 namespace entt {
8 
14 namespace internal {
15 
16 struct meta_type_node;
17 
18 struct ENTT_API meta_context {
19  // we could use the lines below but VS2017 returns with an ICE if combined with ENTT_API despite the code being valid C++
20  // inline static meta_type_node *local = nullptr;
21  // inline static meta_type_node **global = &local;
22 
23  [[nodiscard]] static meta_type_node *&local() ENTT_NOEXCEPT {
24  static meta_type_node *chain = nullptr;
25  return chain;
26  }
27 
28  [[nodiscard]] static meta_type_node **&global() ENTT_NOEXCEPT {
29  static meta_type_node **chain = &local();
30  return chain;
31  }
32 };
33 
34 } // namespace internal
35 
42 struct meta_ctx {
47  static void bind(meta_ctx other) ENTT_NOEXCEPT {
48  internal::meta_context::global() = other.ctx;
49  }
50 
51 private:
52  internal::meta_type_node **ctx{&internal::meta_context::local()};
53 };
54 
55 } // namespace entt
56 
57 #endif
EnTT default namespace.
Definition: dense_map.hpp:22
Opaque container for a meta context.
Definition: ctx.hpp:42
static void bind(meta_ctx other)
Binds the meta system to a given context.
Definition: ctx.hpp:47