EnTT  3.5.0
ctx.hpp
1 #ifndef ENTT_META_CTX_HPP
2 #define ENTT_META_CTX_HPP
3 
4 
5 #include "../core/attribute.h"
6 #include "../config/config.h"
7 
8 
9 namespace entt {
10 
11 
18 namespace internal {
19 
20 
21 struct meta_type_node;
22 
23 
24 struct ENTT_API meta_context {
25  // we could use the lines below but VS2017 returns with an ICE if combined with ENTT_API despite the code being valid C++
26  // inline static meta_type_node *local = nullptr;
27  // inline static meta_type_node **global = &local;
28 
29  [[nodiscard]] static meta_type_node * & local() ENTT_NOEXCEPT {
30  static meta_type_node *chain = nullptr;
31  return chain;
32  }
33 
34  [[nodiscard]] static meta_type_node ** & global() ENTT_NOEXCEPT {
35  static meta_type_node **chain = &local();
36  return chain;
37  }
38 };
39 
40 
41 }
42 
43 
51 struct meta_ctx {
56  static void bind(meta_ctx other) ENTT_NOEXCEPT {
57  internal::meta_context::global() = other.ctx;
58  }
59 
60 private:
61  internal::meta_type_node **ctx{&internal::meta_context::local()};
62 };
63 
64 
65 }
66 
67 
68 #endif
entt::meta_ctx::bind
static void bind(meta_ctx other) noexcept
Binds the meta system to a given context.
Definition: ctx.hpp:56
entt
EnTT default namespace.
Definition: algorithm.hpp:13
entt::meta_ctx
Opaque container for a meta context.
Definition: ctx.hpp:51