EnTT  3.5.2
meta.hpp
1 #ifndef ENTT_META_META_HPP
2 #define ENTT_META_META_HPP
3 
4 
5 #include <algorithm>
6 #include <array>
7 #include <cstddef>
8 #include <iterator>
9 #include <functional>
10 #include <type_traits>
11 #include <utility>
12 #include "../config/config.h"
13 #include "../core/fwd.hpp"
14 #include "../core/utility.hpp"
15 #include "ctx.hpp"
16 #include "internal.hpp"
17 #include "range.hpp"
18 #include "type_traits.hpp"
19 
20 
21 namespace entt {
22 
23 
24 class meta_type;
25 class meta_any;
26 
27 
30  template<typename>
31  struct meta_sequence_container_proxy;
32 
33  class meta_iterator;
34 
35 public:
37  using size_type = std::size_t;
40 
42  meta_sequence_container() ENTT_NOEXCEPT
43  : instance{nullptr}
44  {}
45 
51  template<typename Type>
52  meta_sequence_container(Type *container) ENTT_NOEXCEPT
53  : value_type_fn{&meta_sequence_container_proxy<Type>::value_type},
54  size_fn{&meta_sequence_container_proxy<Type>::size},
55  resize_fn{&meta_sequence_container_proxy<Type>::resize},
56  clear_fn{&meta_sequence_container_proxy<Type>::clear},
57  begin_fn{&meta_sequence_container_proxy<Type>::begin},
58  end_fn{&meta_sequence_container_proxy<Type>::end},
59  insert_fn{&meta_sequence_container_proxy<Type>::insert},
60  erase_fn{&meta_sequence_container_proxy<Type>::erase},
61  get_fn{&meta_sequence_container_proxy<Type>::get},
62  instance{container}
63  {}
64 
65  [[nodiscard]] inline meta_type value_type() const ENTT_NOEXCEPT;
66  [[nodiscard]] inline size_type size() const ENTT_NOEXCEPT;
67  inline bool resize(size_type) const;
68  inline bool clear();
69  [[nodiscard]] inline iterator begin();
70  [[nodiscard]] inline iterator end();
71  inline std::pair<iterator, bool> insert(iterator, meta_any);
72  inline std::pair<iterator, bool> erase(iterator);
73  [[nodiscard]] inline meta_any operator[](size_type);
74  [[nodiscard]] inline explicit operator bool() const ENTT_NOEXCEPT;
75 
76 private:
77  meta_type(* value_type_fn)() ENTT_NOEXCEPT;
78  size_type(* size_fn)(const void *) ENTT_NOEXCEPT;
79  bool(* resize_fn)(void *, size_type);
80  bool(* clear_fn)(void *);
81  iterator(* begin_fn)(void *);
82  iterator(* end_fn)(void *);
83  std::pair<iterator, bool>(* insert_fn)(void *, iterator, meta_any);
84  std::pair<iterator, bool>(* erase_fn)(void *, iterator);
85  meta_any(* get_fn)(void *, size_type);
86  void *instance;
87 };
88 
89 
92  template<typename>
93  struct meta_associative_container_proxy;
94 
95  class meta_iterator;
96 
97 public:
99  using size_type = std::size_t;
102 
105  : instance{nullptr}
106  {}
107 
113  template<typename Type>
114  meta_associative_container(Type *container) ENTT_NOEXCEPT
115  : key_only_container{is_key_only_meta_associative_container_v<Type>},
116  key_type_fn{&meta_associative_container_proxy<Type>::key_type},
117  mapped_type_fn{&meta_associative_container_proxy<Type>::mapped_type},
118  value_type_fn{&meta_associative_container_proxy<Type>::value_type},
119  size_fn{&meta_associative_container_proxy<Type>::size},
120  clear_fn{&meta_associative_container_proxy<Type>::clear},
121  begin_fn{&meta_associative_container_proxy<Type>::begin},
122  end_fn{&meta_associative_container_proxy<Type>::end},
123  insert_fn{&meta_associative_container_proxy<Type>::insert},
124  erase_fn{&meta_associative_container_proxy<Type>::erase},
125  find_fn{&meta_associative_container_proxy<Type>::find},
126  instance{container}
127  {}
128 
129  [[nodiscard]] inline bool key_only() const ENTT_NOEXCEPT;
130  [[nodiscard]] inline meta_type key_type() const ENTT_NOEXCEPT;
131  [[nodiscard]] inline meta_type mapped_type() const ENTT_NOEXCEPT;
132  [[nodiscard]] inline meta_type value_type() const ENTT_NOEXCEPT;
133  [[nodiscard]] inline size_type size() const ENTT_NOEXCEPT;
134  inline bool clear();
135  [[nodiscard]] inline iterator begin();
136  [[nodiscard]] inline iterator end();
137  inline bool insert(meta_any, meta_any);
138  inline bool erase(meta_any);
139  [[nodiscard]] inline iterator find(meta_any);
140  [[nodiscard]] inline explicit operator bool() const ENTT_NOEXCEPT;
141 
142 private:
143  bool key_only_container;
144  meta_type(* key_type_fn)() ENTT_NOEXCEPT;
145  meta_type(* mapped_type_fn)() ENTT_NOEXCEPT;
146  meta_type(* value_type_fn)() ENTT_NOEXCEPT;
147  size_type(* size_fn)(const void *) ENTT_NOEXCEPT;
148  bool(* clear_fn)(void *);
149  iterator(* begin_fn)(void *);
150  iterator(* end_fn)(void *);
151  bool(* insert_fn)(void *, meta_any, meta_any);
152  bool(* erase_fn)(void *, meta_any);
153  iterator(* find_fn)(void *, meta_any);
154  void *instance;
155 };
156 
157 
164 class meta_any {
165  using dereference_operator_type = meta_any(meta_any &);
166 
167  template<typename Type>
168  [[nodiscard]] static meta_any dereference_operator(meta_any &any) {
169  if constexpr(is_meta_pointer_like_v<Type>) {
170  using pointed_type = std::remove_reference_t<decltype(*std::declval<Type>())>;
171 
172  if constexpr(std::is_const_v<pointed_type> && std::is_copy_constructible_v<pointed_type>) {
173  return std::as_const(*any.cast<Type>());
174  } else if constexpr(!std::is_const_v<pointed_type>) {
175  return std::ref(*any.cast<Type>());
176  } else {
177  return {};
178  }
179  } else {
180  return {};
181  }
182  }
183 
184  template<typename Type>
185  [[nodiscard]] static meta_sequence_container meta_sequence_container_factory([[maybe_unused]] void *container) ENTT_NOEXCEPT {
186  if constexpr(has_meta_sequence_container_traits_v<Type>) {
187  return static_cast<Type *>(container);
188  } else {
189  return {};
190  }
191  }
192 
193  template<typename Type>
194  [[nodiscard]] static meta_associative_container meta_associative_container_factory([[maybe_unused]] void *container) ENTT_NOEXCEPT {
195  if constexpr(has_meta_associative_container_traits_v<Type>) {
196  return static_cast<Type *>(container);
197  } else {
198  return {};
199  }
200  }
201 
202 public:
204  meta_any() ENTT_NOEXCEPT
205  : storage{},
206  node{},
207  deref{nullptr},
208  seq_factory{nullptr},
209  assoc_factory{nullptr}
210  {}
211 
218  template<typename Type, typename... Args>
219  explicit meta_any(std::in_place_type_t<Type>, [[maybe_unused]] Args &&... args)
220  : storage(std::in_place_type<Type>, std::forward<Args>(args)...),
221  node{internal::meta_info<Type>::resolve()},
222  deref{&dereference_operator<Type>},
223  seq_factory{&meta_sequence_container_factory<Type>},
224  assoc_factory{&meta_associative_container_factory<Type>}
225  {}
226 
232  template<typename Type>
233  meta_any(std::reference_wrapper<Type> value)
234  : storage{value},
235  node{internal::meta_info<Type>::resolve()},
236  deref{&dereference_operator<Type>},
237  seq_factory{&meta_sequence_container_factory<Type>},
238  assoc_factory{&meta_associative_container_factory<Type>}
239  {}
240 
246  template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_any>>>
247  meta_any(Type &&value)
248  : meta_any{std::in_place_type<std::remove_cv_t<std::remove_reference_t<Type>>>, std::forward<Type>(value)}
249  {}
250 
255  meta_any(const meta_any &other) = default;
256 
262  : meta_any{}
263  {
264  swap(*this, other);
265  }
266 
269  if(node && node->dtor) {
270  node->dtor(storage.data());
271  }
272  }
273 
280  swap(other, *this);
281  return *this;
282  }
283 
288  [[nodiscard]] inline meta_type type() const ENTT_NOEXCEPT;
289 
294  [[nodiscard]] const void * data() const ENTT_NOEXCEPT {
295  return storage.data();
296  }
297 
299  [[nodiscard]] void * data() ENTT_NOEXCEPT {
300  return storage.data();
301  }
302 
313  template<typename... Args>
314  meta_any invoke(const id_type id, Args &&... args) const;
315 
327  template<typename Type>
328  bool set(const id_type id, Type &&value) const;
329 
335  [[nodiscard]] meta_any get(const id_type id) const;
336 
342  template<typename Type>
343  [[nodiscard]] const Type * try_cast() const {
344  if(node) {
345  if(const auto type_id = internal::meta_info<Type>::resolve()->type_id; node->type_id == type_id) {
346  return static_cast<const Type *>(storage.data());
347  } else if(const auto *base = internal::find_if<&internal::meta_type_node::base>([type_id](const auto *curr) { return curr->type()->type_id == type_id; }, node); base) {
348  return static_cast<const Type *>(base->cast(storage.data()));
349  }
350  }
351 
352  return nullptr;
353  }
354 
356  template<typename Type>
357  [[nodiscard]] Type * try_cast() {
358  return const_cast<Type *>(std::as_const(*this).try_cast<Type>());
359  }
360 
375  template<typename Type>
376  [[nodiscard]] const Type & cast() const {
377  auto * const actual = try_cast<Type>();
378  ENTT_ASSERT(actual);
379  return *actual;
380  }
381 
383  template<typename Type>
384  [[nodiscard]] Type & cast() {
385  return const_cast<Type &>(std::as_const(*this).cast<Type>());
386  }
387 
394  template<typename Type>
395  [[nodiscard]] meta_any convert() const {
396  if(node) {
397  if(const auto type_id = internal::meta_info<Type>::resolve()->type_id; node->type_id == type_id) {
398  return *this;
399  } else if(const auto * const conv = internal::find_if<&internal::meta_type_node::conv>([type_id](const auto *curr) { return curr->type()->type_id == type_id; }, node); conv) {
400  return conv->conv(storage.data());
401  }
402  }
403 
404  return {};
405  }
406 
412  template<typename Type>
413  bool convert() {
414  bool valid = (node && node->type_id == internal::meta_info<Type>::resolve()->type_id);
415 
416  if(!valid) {
417  if(auto any = std::as_const(*this).convert<Type>(); any) {
418  swap(any, *this);
419  valid = true;
420  }
421  }
422 
423  return valid;
424  }
425 
432  template<typename Type, typename... Args>
433  void emplace(Args &&... args) {
434  *this = meta_any{std::in_place_type<Type>, std::forward<Args>(args)...};
435  }
436 
441  [[nodiscard]] meta_any ref() const ENTT_NOEXCEPT {
442  meta_any other{};
443  other.node = node;
444  other.storage = storage.ref();
445  other.deref = deref;
446  other.seq_factory = seq_factory;
447  other.assoc_factory = assoc_factory;
448  return other;
449  }
450 
455  [[nodiscard]] meta_sequence_container as_sequence_container() ENTT_NOEXCEPT {
456  return seq_factory(storage.data());
457  }
458 
463  [[nodiscard]] meta_associative_container as_associative_container() ENTT_NOEXCEPT {
464  return assoc_factory(storage.data());
465  }
466 
472  [[nodiscard]] meta_any operator*() ENTT_NOEXCEPT {
473  return deref(*this);
474  }
475 
480  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
481  return !(node == nullptr);
482  }
483 
489  [[nodiscard]] bool operator==(const meta_any &other) const {
490  return (!node && !other.node) || (node && other.node && node->type_id == other.node->type_id && node->compare(storage.data(), other.storage.data()));
491  }
492 
498  friend void swap(meta_any &lhs, meta_any &rhs) {
499  using std::swap;
500  swap(lhs.storage, rhs.storage);
501  swap(lhs.node, rhs.node);
502  swap(lhs.deref, rhs.deref);
503  swap(lhs.seq_factory, rhs.seq_factory);
504  swap(lhs.assoc_factory, rhs.assoc_factory);
505  }
506 
507 private:
508  internal::meta_storage storage;
509  internal::meta_type_node *node;
510  dereference_operator_type *deref;
511  meta_sequence_container(* seq_factory)(void *);
512  meta_associative_container(* assoc_factory)(void *);
513 };
514 
515 
522 [[nodiscard]] inline bool operator!=(const meta_any &lhs, const meta_any &rhs) ENTT_NOEXCEPT {
523  return !(lhs == rhs);
524 }
525 
526 
534 struct meta_handle {
536  meta_handle() = default;
537 
543  template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_handle>>>
544  meta_handle(Type &&value) ENTT_NOEXCEPT
545  : meta_handle{}
546  {
547  if constexpr(std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_any>) {
548  any = value.ref();
549  } else {
550  static_assert(std::is_lvalue_reference_v<Type>, "Lvalue reference required");
551  any = std::ref(value);
552  }
553  }
554 
559  [[nodiscard]] meta_any operator*() const {
560  return any;
561  }
562 
567  [[nodiscard]] meta_any * operator->() {
568  return &any;
569  }
570 
571 private:
572  meta_any any;
573 };
574 
575 
577 struct meta_prop {
579  using node_type = internal::meta_prop_node;
580 
585  meta_prop(const node_type *curr = nullptr) ENTT_NOEXCEPT
586  : node{curr}
587  {}
588 
593  [[nodiscard]] meta_any key() const {
594  return node->key();
595  }
596 
601  [[nodiscard]] meta_any value() const {
602  return node->value();
603  }
604 
609  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
610  return !(node == nullptr);
611  }
612 
613 private:
614  const node_type *node;
615 };
616 
617 
619 struct meta_base {
621  using node_type = internal::meta_base_node;
622 
624  meta_base(const node_type *curr = nullptr) ENTT_NOEXCEPT
625  : node{curr}
626  {}
627 
632  [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
633 
635  [[nodiscard]] inline meta_type type() const ENTT_NOEXCEPT;
636 
642  [[nodiscard]] const void * cast(const void *instance) const ENTT_NOEXCEPT {
643  return node->cast(instance);
644  }
645 
650  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
651  return !(node == nullptr);
652  }
653 
654 private:
655  const node_type *node;
656 };
657 
658 
660 struct meta_conv {
662  using node_type = internal::meta_conv_node;
663 
665  meta_conv(const node_type *curr = nullptr) ENTT_NOEXCEPT
666  : node{curr}
667  {}
668 
670  [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
671 
673  [[nodiscard]] inline meta_type type() const ENTT_NOEXCEPT;
674 
680  [[nodiscard]] meta_any convert(const void *instance) const {
681  return node->conv(instance);
682  }
683 
688  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
689  return !(node == nullptr);
690  }
691 
692 private:
693  const node_type *node;
694 };
695 
696 
698 struct meta_ctor {
700  using node_type = internal::meta_ctor_node;
702  using size_type = typename node_type::size_type;
703 
705  meta_ctor(const node_type *curr = nullptr) ENTT_NOEXCEPT
706  : node{curr}
707  {}
708 
710  [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
711 
716  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
717  return node->size;
718  }
719 
725  [[nodiscard]] meta_type arg(size_type index) const ENTT_NOEXCEPT;
726 
738  [[nodiscard]] meta_any invoke(meta_any * const args, const std::size_t sz) const {
739  return sz == size() ? node->invoke(args) : meta_any{};
740  }
741 
751  template<typename... Args>
752  [[nodiscard]] meta_any invoke([[maybe_unused]] Args &&... args) const {
753  std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
754  return invoke(arguments.data(), sizeof...(Args));
755  }
756 
761  [[nodiscard]] meta_range<meta_prop> prop() const ENTT_NOEXCEPT {
762  return node->prop;
763  }
764 
770  [[nodiscard]] meta_prop prop(meta_any key) const {
771  internal::meta_range range{node->prop};
772  return std::find_if(range.begin(), range.end(), [&key](const auto &curr) { return curr.key() == key; }).operator->();
773  }
774 
779  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
780  return !(node == nullptr);
781  }
782 
783 private:
784  const node_type *node;
785 };
786 
787 
789 struct meta_data {
791  using node_type = internal::meta_data_node;
792 
794  meta_data(const node_type *curr = nullptr) ENTT_NOEXCEPT
795  : node{curr}
796  {}
797 
799  [[nodiscard]] id_type id() const ENTT_NOEXCEPT {
800  return node->id;
801  }
802 
804  [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
805 
810  [[nodiscard]] bool is_const() const ENTT_NOEXCEPT {
811  return (node->set == nullptr);
812  }
813 
818  [[nodiscard]] bool is_static() const ENTT_NOEXCEPT {
819  return node->is_static;
820  }
821 
823  [[nodiscard]] inline meta_type type() const ENTT_NOEXCEPT;
824 
839  template<typename Type>
840  bool set(meta_handle instance, Type &&value) const {
841  return node->set && node->set(std::move(instance), std::forward<Type>(value));
842  }
843 
853  [[nodiscard]] meta_any get(meta_handle instance) const {
854  return node->get(std::move(instance));
855  }
856 
858  [[nodiscard]] meta_range<meta_prop> prop() const ENTT_NOEXCEPT {
859  return node->prop;
860  }
861 
867  [[nodiscard]] meta_prop prop(meta_any key) const {
868  internal::meta_range range{node->prop};
869  return std::find_if(range.begin(), range.end(), [&key](const auto &curr) { return curr.key() == key; }).operator->();
870  }
871 
876  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
877  return !(node == nullptr);
878  }
879 
880 private:
881  const node_type *node;
882 };
883 
884 
886 struct meta_func {
888  using node_type = internal::meta_func_node;
890  using size_type = typename node_type::size_type;
891 
893  meta_func(const node_type *curr = nullptr) ENTT_NOEXCEPT
894  : node{curr}
895  {}
896 
898  [[nodiscard]] id_type id() const ENTT_NOEXCEPT {
899  return node->id;
900  }
901 
903  [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;
904 
909  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
910  return node->size;
911  }
912 
917  [[nodiscard]] bool is_const() const ENTT_NOEXCEPT {
918  return node->is_const;
919  }
920 
925  [[nodiscard]] bool is_static() const ENTT_NOEXCEPT {
926  return node->is_static;
927  }
928 
933  [[nodiscard]] inline meta_type ret() const ENTT_NOEXCEPT;
934 
940  [[nodiscard]] inline meta_type arg(size_type index) const ENTT_NOEXCEPT;
941 
957  meta_any invoke(meta_handle instance, meta_any * const args, const std::size_t sz) const {
958  return sz == size() ? node->invoke(instance, args) : meta_any{};
959  }
960 
971  template<typename... Args>
972  meta_any invoke(meta_handle instance, Args &&... args) const {
973  std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
974  return invoke(instance, arguments.data(), sizeof...(Args));
975  }
976 
978  [[nodiscard]] meta_range<meta_prop> prop() const ENTT_NOEXCEPT {
979  return node->prop;
980  }
981 
987  [[nodiscard]] meta_prop prop(meta_any key) const {
988  internal::meta_range range{node->prop};
989  return std::find_if(range.begin(), range.end(), [&key](const auto &curr) { return curr.key() == key; }).operator->();
990  }
991 
996  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
997  return !(node == nullptr);
998  }
999 
1000 private:
1001  const node_type *node;
1002 };
1003 
1004 
1006 class meta_type {
1007  template<typename... Args, std::size_t... Indexes>
1008  [[nodiscard]] auto ctor(std::index_sequence<Indexes...>) const {
1009  internal::meta_range range{node->ctor};
1010 
1011  return std::find_if(range.begin(), range.end(), [](const auto &candidate) {
1012  return candidate.size == sizeof...(Args) && ([](auto *from, auto *to) {
1013  return (from->type_id == to->type_id)
1014  || internal::find_if<&node_type::base>([to](const auto *curr) { return curr->type()->type_id == to->type_id; }, from)
1015  || internal::find_if<&node_type::conv>([to](const auto *curr) { return curr->type()->type_id == to->type_id; }, from);
1016  }(internal::meta_info<Args>::resolve(), candidate.arg(Indexes)) && ...);
1017  }).operator->();
1018  }
1019 
1020 public:
1022  using node_type = internal::meta_type_node;
1024  using size_type = typename node_type::size_type;
1025 
1027  meta_type(node_type *curr = nullptr) ENTT_NOEXCEPT
1028  : node{curr}
1029  {}
1030 
1035  [[nodiscard]] id_type type_id() const ENTT_NOEXCEPT {
1036  return node->type_id;
1037  }
1038 
1043  [[nodiscard]] id_type id() const ENTT_NOEXCEPT {
1044  return node->id;
1045  }
1046 
1051  [[nodiscard]] bool is_void() const ENTT_NOEXCEPT {
1052  return node->is_void;
1053  }
1054 
1059  [[nodiscard]] bool is_integral() const ENTT_NOEXCEPT {
1060  return node->is_integral;
1061  }
1062 
1068  [[nodiscard]] bool is_floating_point() const ENTT_NOEXCEPT {
1069  return node->is_floating_point;
1070  }
1071 
1076  [[nodiscard]] bool is_array() const ENTT_NOEXCEPT {
1077  return node->is_array;
1078  }
1079 
1084  [[nodiscard]] bool is_enum() const ENTT_NOEXCEPT {
1085  return node->is_enum;
1086  }
1087 
1092  [[nodiscard]] bool is_union() const ENTT_NOEXCEPT {
1093  return node->is_union;
1094  }
1095 
1100  [[nodiscard]] bool is_class() const ENTT_NOEXCEPT {
1101  return node->is_class;
1102  }
1103 
1108  [[nodiscard]] bool is_pointer() const ENTT_NOEXCEPT {
1109  return node->is_pointer;
1110  }
1111 
1117  [[nodiscard]] bool is_function_pointer() const ENTT_NOEXCEPT {
1118  return node->is_function_pointer;
1119  }
1120 
1126  [[nodiscard]] bool is_member_object_pointer() const ENTT_NOEXCEPT {
1127  return node->is_member_object_pointer;
1128  }
1129 
1136  [[nodiscard]] bool is_member_function_pointer() const ENTT_NOEXCEPT {
1137  return node->is_member_function_pointer;
1138  }
1139 
1145  [[nodiscard]] bool is_pointer_like() const ENTT_NOEXCEPT {
1146  return node->is_pointer_like;
1147  }
1148 
1154  [[nodiscard]] bool is_sequence_container() const ENTT_NOEXCEPT {
1155  return node->is_sequence_container;
1156  }
1157 
1163  [[nodiscard]] bool is_associative_container() const ENTT_NOEXCEPT {
1164  return node->is_associative_container;
1165  }
1166 
1173  [[nodiscard]] size_type rank() const ENTT_NOEXCEPT {
1174  return node->rank;
1175  }
1176 
1184  [[nodiscard]] size_type extent(size_type dim = {}) const ENTT_NOEXCEPT {
1185  return node->extent(dim);
1186  }
1187 
1193  [[nodiscard]] meta_type remove_pointer() const ENTT_NOEXCEPT {
1194  return node->remove_pointer();
1195  }
1196 
1202  [[nodiscard]] meta_type remove_extent() const ENTT_NOEXCEPT {
1203  return node->remove_extent();
1204  }
1205 
1210  [[nodiscard]] meta_range<meta_base> base() const ENTT_NOEXCEPT {
1211  return node->base;
1212  }
1213 
1219  [[nodiscard]] meta_base base(const id_type id) const {
1220  return internal::find_if<&node_type::base>([id](const auto *curr) {
1221  return curr->type()->id == id;
1222  }, node);
1223  }
1224 
1231  [[nodiscard]] meta_range<meta_conv> conv() const ENTT_NOEXCEPT {
1232  return node->conv;
1233  }
1234 
1241  template<typename Type>
1242  [[nodiscard]] meta_conv conv() const {
1243  return internal::find_if<&node_type::conv>([type_id = internal::meta_info<Type>::resolve()->type_id](const auto *curr) {
1244  return curr->type()->type_id == type_id;
1245  }, node);
1246  }
1247 
1252  [[nodiscard]] meta_range<meta_ctor> ctor() const ENTT_NOEXCEPT {
1253  return node->ctor;
1254  }
1255 
1261  template<typename... Args>
1262  [[nodiscard]] meta_ctor ctor() const {
1263  return ctor<Args...>(std::index_sequence_for<Args...>{});
1264  }
1265 
1270  [[nodiscard]] meta_range<meta_data> data() const ENTT_NOEXCEPT {
1271  return node->data;
1272  }
1273 
1282  [[nodiscard]] meta_data data(const id_type id) const {
1283  return internal::find_if<&node_type::data>([id](const auto *curr) {
1284  return curr->id == id;
1285  }, node);
1286  }
1287 
1292  [[nodiscard]] meta_range<meta_func> func() const ENTT_NOEXCEPT {
1293  return node->func;
1294  }
1295 
1304  [[nodiscard]] meta_func func(const id_type id) const {
1305  return internal::find_if<&node_type::func>([id](const auto *curr) {
1306  return curr->id == id;
1307  }, node);
1308  }
1309 
1321  [[nodiscard]] meta_any construct(meta_any * const args, const std::size_t sz) const {
1322  meta_any any{};
1323 
1324  internal::find_if<&node_type::ctor>([args, sz, &any](const auto *curr) {
1325  return (curr->size == sz) && (any = curr->invoke(args));
1326  }, node);
1327 
1328  return any;
1329  }
1330 
1340  template<typename... Args>
1341  [[nodiscard]] meta_any construct(Args &&... args) const {
1342  std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
1343  return construct(arguments.data(), sizeof...(Args));
1344  }
1345 
1362  meta_any invoke(const id_type id, meta_handle instance, meta_any * const args, const std::size_t sz) const {
1363  auto const candidate = func(id);
1364  return candidate ? candidate.invoke(std::move(instance), args, sz) : meta_any{};
1365  }
1366 
1378  template<typename... Args>
1379  meta_any invoke(const id_type id, meta_handle instance, Args &&... args) const {
1380  std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
1381  return invoke(id, std::move(instance), arguments.data(), sizeof...(Args));
1382  }
1383 
1399  template<typename Type>
1400  bool set(const id_type id, meta_handle instance, Type &&value) const {
1401  auto const candidate = data(id);
1402  return candidate ? candidate.set(std::move(instance), std::forward<Type>(value)) : false;
1403  }
1404 
1415  [[nodiscard]] meta_any get(const id_type id, meta_handle instance) const {
1416  auto const candidate = data(id);
1417  return candidate ? candidate.get(std::move(instance)) : meta_any{};
1418  }
1419 
1424  [[nodiscard]] meta_range<meta_prop> prop() const ENTT_NOEXCEPT {
1425  return node->prop;
1426  }
1427 
1436  [[nodiscard]] meta_prop prop(meta_any key) const {
1437  return internal::find_if<&node_type::prop>([key = std::move(key)](const auto *curr) {
1438  return curr->key() == key;
1439  }, node);
1440  }
1441 
1446  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
1447  return !(node == nullptr);
1448  }
1449 
1456  [[nodiscard]] bool operator==(const meta_type &other) const ENTT_NOEXCEPT {
1457  return (!node && !other.node) || (node && other.node && node->type_id == other.node->type_id);
1458  }
1459 
1470  void reset() ENTT_NOEXCEPT {
1471  auto** it = internal::meta_context::global();
1472 
1473  while (*it && *it != node) {
1474  it = &(*it)->next;
1475  }
1476 
1477  if(*it) {
1478  *it = (*it)->next;
1479  }
1480 
1481  const auto unregister_all = y_combinator{
1482  [](auto &&self, auto **curr, auto... member) {
1483  while(*curr) {
1484  auto *prev = *curr;
1485  (self(&(prev->*member)), ...);
1486  *curr = prev->next;
1487  prev->next = nullptr;
1488  }
1489  }
1490  };
1491 
1492  unregister_all(&node->prop);
1493  unregister_all(&node->base);
1494  unregister_all(&node->conv);
1495  unregister_all(&node->ctor, &internal::meta_ctor_node::prop);
1496  unregister_all(&node->data, &internal::meta_data_node::prop);
1497  unregister_all(&node->func, &internal::meta_func_node::prop);
1498 
1499  node->id = {};
1500  node->dtor = nullptr;
1501  }
1502 
1503 private:
1504  node_type *node;
1505 };
1506 
1507 
1514 [[nodiscard]] inline bool operator!=(const meta_type &lhs, const meta_type &rhs) ENTT_NOEXCEPT {
1515  return !(lhs == rhs);
1516 }
1517 
1518 
1519 [[nodiscard]] inline meta_type meta_any::type() const ENTT_NOEXCEPT {
1520  return node;
1521 }
1522 
1523 
1524 template<typename... Args>
1525 meta_any meta_any::invoke(const id_type id, Args &&... args) const {
1526  return type().invoke(id, *this, std::forward<Args>(args)...);
1527 }
1528 
1529 
1530 template<typename Type>
1531 bool meta_any::set(const id_type id, Type &&value) const {
1532  return type().set(id, *this, std::forward<Type>(value));
1533 }
1534 
1535 
1536 [[nodiscard]] inline meta_any meta_any::get(const id_type id) const {
1537  return type().get(id, *this);
1538 }
1539 
1540 
1541 [[nodiscard]] inline meta_type meta_base::parent() const ENTT_NOEXCEPT {
1542  return node->parent;
1543 }
1544 
1545 
1546 [[nodiscard]] inline meta_type meta_base::type() const ENTT_NOEXCEPT {
1547  return node->type();
1548 }
1549 
1550 
1551 [[nodiscard]] inline meta_type meta_conv::parent() const ENTT_NOEXCEPT {
1552  return node->parent;
1553 }
1554 
1555 
1556 [[nodiscard]] inline meta_type meta_conv::type() const ENTT_NOEXCEPT {
1557  return node->type();
1558 }
1559 
1560 
1561 [[nodiscard]] inline meta_type meta_ctor::parent() const ENTT_NOEXCEPT {
1562  return node->parent;
1563 }
1564 
1565 
1566 [[nodiscard]] inline meta_type meta_ctor::arg(size_type index) const ENTT_NOEXCEPT {
1567  return index < size() ? node->arg(index) : nullptr;
1568 }
1569 
1570 
1571 [[nodiscard]] inline meta_type meta_data::parent() const ENTT_NOEXCEPT {
1572  return node->parent;
1573 }
1574 
1575 
1576 [[nodiscard]] inline meta_type meta_data::type() const ENTT_NOEXCEPT {
1577  return node->type();
1578 }
1579 
1580 
1581 [[nodiscard]] inline meta_type meta_func::parent() const ENTT_NOEXCEPT {
1582  return node->parent;
1583 }
1584 
1585 
1586 [[nodiscard]] inline meta_type meta_func::ret() const ENTT_NOEXCEPT {
1587  return node->ret();
1588 }
1589 
1590 
1591 [[nodiscard]] inline meta_type meta_func::arg(size_type index) const ENTT_NOEXCEPT {
1592  return index < size() ? node->arg(index) : nullptr;
1593 }
1594 
1595 
1600 
1601  template<typename It>
1602  static void incr(meta_any any) {
1603  ++any.cast<It>();
1604  }
1605 
1606  template<typename It>
1607  [[nodiscard]] static meta_any deref(meta_any any) {
1608  if constexpr(std::is_const_v<std::remove_reference_t<decltype(*std::declval<It>())>>) {
1609  return *any.cast<It>();
1610  } else {
1611  return std::ref(*any.cast<It>());
1612  }
1613  }
1614 
1615 public:
1617  using difference_type = std::ptrdiff_t;
1621  using pointer = void;
1625  using iterator_category = std::input_iterator_tag;
1626 
1628  meta_iterator() ENTT_NOEXCEPT = default;
1629 
1635  template<typename It>
1636  meta_iterator(It iter)
1637  : next_fn{&incr<It>},
1638  get_fn{&deref<It>},
1639  handle{std::move(iter)}
1640  {}
1641 
1643  meta_iterator & operator++() ENTT_NOEXCEPT {
1644  return next_fn(handle.ref()), *this;
1645  }
1646 
1648  meta_iterator operator++(int) ENTT_NOEXCEPT {
1649  meta_iterator orig = *this;
1650  return ++(*this), orig;
1651  }
1652 
1659  [[nodiscard]] bool operator==(const meta_iterator &other) const ENTT_NOEXCEPT {
1660  return handle == other.handle;
1661  }
1662 
1669  [[nodiscard]] bool operator!=(const meta_iterator &other) const ENTT_NOEXCEPT {
1670  return !(*this == other);
1671  }
1672 
1677  [[nodiscard]] reference operator*() const {
1678  return get_fn(handle.ref());
1679  }
1680 
1685  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
1686  return static_cast<bool>(handle);
1687  }
1688 
1689 private:
1690  void(* next_fn)(meta_any);
1691  meta_any(* get_fn)(meta_any);
1692  meta_any handle;
1693 };
1694 
1695 
1696 template<typename Type>
1697 struct meta_sequence_container::meta_sequence_container_proxy {
1698  using traits_type = meta_sequence_container_traits<Type>;
1699 
1700  [[nodiscard]] static meta_type value_type() ENTT_NOEXCEPT {
1701  return internal::meta_info<typename traits_type::value_type>::resolve();
1702  }
1703 
1704  [[nodiscard]] static size_type size(const void *container) ENTT_NOEXCEPT {
1705  return traits_type::size(*static_cast<const Type *>(container));
1706  }
1707 
1708  [[nodiscard]] static bool resize(void *container, size_type sz) {
1709  return traits_type::resize(*static_cast<Type *>(container), sz);
1710  }
1711 
1712  [[nodiscard]] static bool clear(void *container) {
1713  return traits_type::clear(*static_cast<Type *>(container));
1714  }
1715 
1716  [[nodiscard]] static iterator begin(void *container) {
1717  return iterator{traits_type::begin(*static_cast<Type *>(container))};
1718  }
1719 
1720  [[nodiscard]] static iterator end(void *container) {
1721  return iterator{traits_type::end(*static_cast<Type *>(container))};
1722  }
1723 
1724  [[nodiscard]] static std::pair<iterator, bool> insert(void *container, iterator it, meta_any value) {
1725  if(const auto *v_ptr = value.try_cast<typename traits_type::value_type>(); v_ptr || value.convert<typename traits_type::value_type>()) {
1726  auto ret = traits_type::insert(*static_cast<Type *>(container), it.handle.cast<typename traits_type::iterator>(), v_ptr ? *v_ptr : value.cast<typename traits_type::value_type>());
1727  return {iterator{std::move(ret.first)}, ret.second};
1728  }
1729 
1730  return {};
1731  }
1732 
1733  [[nodiscard]] static std::pair<iterator, bool> erase(void *container, iterator it) {
1734  auto ret = traits_type::erase(*static_cast<Type *>(container), it.handle.cast<typename traits_type::iterator>());
1735  return {iterator{std::move(ret.first)}, ret.second};
1736  }
1737 
1738  [[nodiscard]] static meta_any get(void *container, size_type pos) {
1739  return std::ref(traits_type::get(*static_cast<Type *>(container), pos));
1740  }
1741 };
1742 
1743 
1748 [[nodiscard]] inline meta_type meta_sequence_container::value_type() const ENTT_NOEXCEPT {
1749  return value_type_fn();
1750 }
1751 
1752 
1757 [[nodiscard]] inline meta_sequence_container::size_type meta_sequence_container::size() const ENTT_NOEXCEPT {
1758  return size_fn(instance);
1759 }
1760 
1761 
1768  return resize_fn(instance, sz);
1769 }
1770 
1771 
1777  return clear_fn(instance);
1778 }
1779 
1780 
1786  return begin_fn(instance);
1787 }
1788 
1789 
1797  return end_fn(instance);
1798 }
1799 
1800 
1808 inline std::pair<meta_sequence_container::iterator, bool> meta_sequence_container::insert(iterator it, meta_any value) {
1809  return insert_fn(instance, it, value.ref());
1810 }
1811 
1812 
1820 inline std::pair<meta_sequence_container::iterator, bool> meta_sequence_container::erase(iterator it) {
1821  return erase_fn(instance, it);
1822 }
1823 
1824 
1832  return get_fn(instance, pos);
1833 }
1834 
1835 
1840 [[nodiscard]] inline meta_sequence_container::operator bool() const ENTT_NOEXCEPT {
1841  return (instance != nullptr);
1842 }
1843 
1844 
1847  template<typename It>
1848  static void incr(meta_any any) {
1849  ++any.cast<It>();
1850  }
1851 
1852  template<bool KeyOnly, typename It>
1853  [[nodiscard]] static meta_any key(meta_any any) {
1854  if constexpr(KeyOnly) {
1855  return *any.cast<It>();
1856  } else {
1857  return any.cast<It>()->first;
1858  }
1859  }
1860 
1861  template<bool KeyOnly, typename It>
1862  [[nodiscard]] static meta_any value([[maybe_unused]] meta_any any) {
1863  if constexpr(KeyOnly) {
1864  return meta_any{};
1865  } else {
1866  return std::ref(any.cast<It>()->second);
1867  }
1868  }
1869 
1870 public:
1872  using difference_type = std::ptrdiff_t;
1874  using value_type = std::pair<meta_any, meta_any>;
1876  using pointer = void;
1880  using iterator_category = std::input_iterator_tag;
1881 
1883  meta_iterator() ENTT_NOEXCEPT = default;
1884 
1892  template<bool KeyOnly, typename It>
1893  meta_iterator(std::integral_constant<bool, KeyOnly>, It iter)
1894  : next_fn{&incr<It>},
1895  key_fn{&key<KeyOnly, It>},
1896  value_fn{&value<KeyOnly, It>},
1897  handle{std::move(iter)}
1898  {}
1899 
1901  meta_iterator & operator++() ENTT_NOEXCEPT {
1902  return next_fn(handle.ref()), *this;
1903  }
1904 
1906  meta_iterator operator++(int) ENTT_NOEXCEPT {
1907  meta_iterator orig = *this;
1908  return ++(*this), orig;
1909  }
1910 
1917  [[nodiscard]] bool operator==(const meta_iterator &other) const ENTT_NOEXCEPT {
1918  return handle == other.handle;
1919  }
1920 
1927  [[nodiscard]] bool operator!=(const meta_iterator &other) const ENTT_NOEXCEPT {
1928  return !(*this == other);
1929  }
1930 
1935  [[nodiscard]] reference operator*() const {
1936  return { key_fn(handle.ref()), value_fn(handle.ref()) };
1937  }
1938 
1943  [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
1944  return static_cast<bool>(handle);
1945  }
1946 
1947 private:
1948  void(* next_fn)(meta_any);
1949  meta_any(* key_fn)(meta_any);
1950  meta_any(* value_fn)(meta_any);
1951  meta_any handle;
1952 };
1953 
1954 
1955 template<typename Type>
1956 struct meta_associative_container::meta_associative_container_proxy {
1957  using traits_type = meta_associative_container_traits<Type>;
1958 
1959  [[nodiscard]] static meta_type key_type() ENTT_NOEXCEPT {
1960  return internal::meta_info<typename traits_type::key_type>::resolve();
1961  }
1962 
1963  [[nodiscard]] static meta_type mapped_type() ENTT_NOEXCEPT {
1964  if constexpr(is_key_only_meta_associative_container_v<Type>) {
1965  return meta_type{};
1966  } else {
1967  return internal::meta_info<typename traits_type::mapped_type>::resolve();
1968  }
1969  }
1970 
1971  [[nodiscard]] static meta_type value_type() ENTT_NOEXCEPT {
1972  return internal::meta_info<typename traits_type::value_type>::resolve();
1973  }
1974 
1975  [[nodiscard]] static size_type size(const void *container) ENTT_NOEXCEPT {
1976  return traits_type::size(*static_cast<const Type *>(container));
1977  }
1978 
1979  [[nodiscard]] static bool clear(void *container) {
1980  return traits_type::clear(*static_cast<Type *>(container));
1981  }
1982 
1983  [[nodiscard]] static iterator begin(void *container) {
1984  return iterator{is_key_only_meta_associative_container<Type>{}, traits_type::begin(*static_cast<Type *>(container))};
1985  }
1986 
1987  [[nodiscard]] static iterator end(void *container) {
1988  return iterator{is_key_only_meta_associative_container<Type>{}, traits_type::end(*static_cast<Type *>(container))};
1989  }
1990 
1991  [[nodiscard]] static bool insert(void *container, meta_any key, meta_any value) {
1992  if(const auto *k_ptr = key.try_cast<typename traits_type::key_type>(); k_ptr || key.convert<typename traits_type::key_type>()) {
1993  if constexpr(is_key_only_meta_associative_container_v<Type>) {
1994  return traits_type::insert(*static_cast<Type *>(container), k_ptr ? *k_ptr : key.cast<typename traits_type::key_type>());
1995  } else {
1996  if(auto *m_ptr = value.try_cast<typename traits_type::mapped_type>(); m_ptr || value.convert<typename traits_type::mapped_type>()) {
1997  return traits_type::insert(*static_cast<Type *>(container), k_ptr ? *k_ptr : key.cast<typename traits_type::key_type>(), m_ptr ? *m_ptr : value.cast<typename traits_type::mapped_type>());
1998  }
1999  }
2000  }
2001 
2002  return false;
2003  }
2004 
2005  [[nodiscard]] static bool erase(void *container, meta_any key) {
2006  if(const auto *k_ptr = key.try_cast<typename traits_type::key_type>(); k_ptr || key.convert<typename traits_type::key_type>()) {
2007  return traits_type::erase(*static_cast<Type *>(container), k_ptr ? *k_ptr : key.cast<typename traits_type::key_type>());
2008  }
2009 
2010  return false;
2011  }
2012 
2013  [[nodiscard]] static iterator find(void *container, meta_any key) {
2014  if(const auto *k_ptr = key.try_cast<typename traits_type::key_type>(); k_ptr || key.convert<typename traits_type::key_type>()) {
2015  return iterator{is_key_only_meta_associative_container<Type>{}, traits_type::find(*static_cast<Type *>(container), k_ptr ? *k_ptr : key.cast<typename traits_type::key_type>())};
2016  }
2017 
2018  return {};
2019  }
2020 };
2021 
2022 
2028 [[nodiscard]] inline bool meta_associative_container::key_only() const ENTT_NOEXCEPT {
2029  return key_only_container;
2030 }
2031 
2032 
2037 [[nodiscard]] inline meta_type meta_associative_container::key_type() const ENTT_NOEXCEPT {
2038  return key_type_fn();
2039 }
2040 
2041 
2046 [[nodiscard]] inline meta_type meta_associative_container::mapped_type() const ENTT_NOEXCEPT {
2047  return mapped_type_fn();
2048 }
2049 
2050 
2052 [[nodiscard]] inline meta_type meta_associative_container::value_type() const ENTT_NOEXCEPT {
2053  return value_type_fn();
2054 }
2055 
2056 
2059  return size_fn(instance);
2060 }
2061 
2062 
2065  return clear_fn(instance);
2066 }
2067 
2068 
2071  return begin_fn(instance);
2072 }
2073 
2074 
2077  return end_fn(instance);
2078 }
2079 
2080 
2088  return insert_fn(instance, key.ref(), value.ref());
2089 }
2090 
2091 
2098  return erase_fn(instance, key.ref());
2099 }
2100 
2101 
2109  return find_fn(instance, key.ref());
2110 }
2111 
2112 
2117 [[nodiscard]] inline meta_associative_container::operator bool() const ENTT_NOEXCEPT {
2118  return (instance != nullptr);
2119 }
2120 
2121 
2122 }
2123 
2124 
2125 #endif
entt::meta_data::type
meta_type type() const noexcept
Returns the meta type of the underlying object.
Definition: meta.hpp:1576
entt::meta_func::node_type
internal::meta_func_node node_type
Node type.
Definition: meta.hpp:888
entt::meta_associative_container::meta_iterator::value_type
std::pair< meta_any, meta_any > value_type
Type of elements returned by the iterator.
Definition: meta.hpp:1874
entt::meta_conv::node_type
internal::meta_conv_node node_type
Node type.
Definition: meta.hpp:662
entt::meta_type::is_array
bool is_array() const noexcept
Checks whether a type refers to an array type or not.
Definition: meta.hpp:1076
entt::meta_data::parent
meta_type parent() const noexcept
Returns the meta type to which a meta object belongs.
Definition: meta.hpp:1571
entt::meta_sequence_container::iterator
meta_iterator iterator
Meta iterator type.
Definition: meta.hpp:39
entt::meta_type::type_id
id_type type_id() const noexcept
Returns the type id of the underlying type.
Definition: meta.hpp:1035
entt::meta_any
Opaque wrapper for values of any type.
Definition: meta.hpp:164
entt::meta_type::rank
size_type rank() const noexcept
If a type refers to an array type, provides the number of dimensions of the array.
Definition: meta.hpp:1173
entt::meta_any::operator==
bool operator==(const meta_any &other) const
Checks if two wrappers differ in their content.
Definition: meta.hpp:489
entt::meta_sequence_container::meta_iterator::operator*
reference operator*() const
Indirection operator.
Definition: meta.hpp:1677
entt::meta_ctor::parent
meta_type parent() const noexcept
Returns the meta type to which a meta object belongs.
Definition: meta.hpp:1561
entt::meta_associative_container::meta_iterator::operator++
meta_iterator & operator++() noexcept
Pre-increment operator.
Definition: meta.hpp:1901
entt::meta_sequence_container
Proxy object for sequence containers.
Definition: meta.hpp:29
entt::meta_data
Opaque wrapper for meta data.
Definition: meta.hpp:789
entt::meta_ctor::node_type
internal::meta_ctor_node node_type
Node type.
Definition: meta.hpp:700
entt::meta_base::parent
meta_type parent() const noexcept
Returns the meta type to which a meta object belongs.
Definition: meta.hpp:1541
entt::meta_data::meta_data
meta_data(const node_type *curr=nullptr) noexcept
Constructs an instance from a given node.
Definition: meta.hpp:794
entt::meta_func::prop
meta_prop prop(meta_any key) const
Returns the property associated with a given key.
Definition: meta.hpp:987
entt::meta_type::size_type
typename node_type::size_type size_type
Unsigned integer type.
Definition: meta.hpp:1024
entt::meta_associative_container
Proxy object for associative containers.
Definition: meta.hpp:91
entt::meta_type::func
meta_func func(const id_type id) const
Returns the meta function associated with a given identifier.
Definition: meta.hpp:1304
entt::meta_associative_container::meta_iterator::difference_type
std::ptrdiff_t difference_type
Signed integer type.
Definition: meta.hpp:1872
entt::meta_func::id
id_type id() const noexcept
Returns the identifier assigned to a meta object.
Definition: meta.hpp:898
entt::meta_sequence_container::meta_iterator
Opaque iterator for meta sequence containers.
Definition: meta.hpp:1597
entt::get
constexpr get_t< Type... > get
Variable template for lists of observed components.
Definition: utility.hpp:40
entt::basic_handle
Non-owning handle to an entity.
Definition: handle.hpp:19
entt::meta_func::invoke
meta_any invoke(meta_handle instance, Args &&... args) const
Invokes the underlying function, if possible.
Definition: meta.hpp:972
entt::meta_type::is_function_pointer
bool is_function_pointer() const noexcept
Checks whether a type refers to a function pointer or not.
Definition: meta.hpp:1117
entt::meta_associative_container::find
iterator find(meta_any)
Returns an iterator to the element with key equivalent to a given one, if any.
Definition: meta.hpp:2108
entt::meta_conv::meta_conv
meta_conv(const node_type *curr=nullptr) noexcept
Constructs an instance from a given node.
Definition: meta.hpp:665
entt::meta_ctor::prop
meta_prop prop(meta_any key) const
Returns the property associated with a given key.
Definition: meta.hpp:770
entt::meta_associative_container::meta_iterator::meta_iterator
meta_iterator() noexcept=default
Default constructor.
entt::handle
basic_handle< entity > handle
Alias declaration for the most common use case.
Definition: fwd.hpp:68
entt::meta_associative_container::meta_iterator::iterator_category
std::input_iterator_tag iterator_category
Iterator category.
Definition: meta.hpp:1880
entt::meta_any::ref
meta_any ref() const noexcept
Aliasing constructor.
Definition: meta.hpp:441
entt::meta_type::ctor
meta_ctor ctor() const
Returns the meta constructor that accepts a given list of types of arguments.
Definition: meta.hpp:1262
entt::meta_data::is_static
bool is_static() const noexcept
Indicates whether a meta data is static or not.
Definition: meta.hpp:818
entt::meta_func::ret
meta_type ret() const noexcept
Returns the meta type of the return type of a meta function.
Definition: meta.hpp:1586
entt::meta_conv
Opaque wrapper for meta conversion functions.
Definition: meta.hpp:660
entt::meta_sequence_container::erase
std::pair< iterator, bool > erase(iterator)
Removes the specified element from the wrapped container.
Definition: meta.hpp:1820
entt::meta_prop::key
meta_any key() const
Returns the stored key.
Definition: meta.hpp:593
entt::meta_type::remove_pointer
meta_type remove_pointer() const noexcept
Provides the meta type for which the pointer is defined.
Definition: meta.hpp:1193
entt::meta_sequence_container::meta_iterator::operator==
bool operator==(const meta_iterator &other) const noexcept
Checks if two meta iterators refer to the same element.
Definition: meta.hpp:1659
entt::meta_any::meta_any
meta_any(meta_any &&other)
Move constructor.
Definition: meta.hpp:261
entt::meta_type::operator==
bool operator==(const meta_type &other) const noexcept
Checks if two meta objects refer to the same type.
Definition: meta.hpp:1456
entt::meta_prop
Opaque wrapper for meta properties of any type.
Definition: meta.hpp:577
entt::meta_any::meta_any
meta_any(const meta_any &other)=default
Copy constructor.
entt::meta_type::prop
meta_range< meta_prop > prop() const noexcept
Returns a range to use to visit top-level meta properties.
Definition: meta.hpp:1424
entt::meta_sequence_container::operator[]
meta_any operator[](size_type)
Returns a reference to the element at a specified location of the wrapped container (no bounds checki...
Definition: meta.hpp:1831
entt::meta_type::extent
size_type extent(size_type dim={}) const noexcept
If a type refers to an array type, provides the number of elements along the given dimension of the a...
Definition: meta.hpp:1184
entt::meta_associative_container::meta_iterator::operator*
reference operator*() const
Indirection operator.
Definition: meta.hpp:1935
entt::meta_ctor
Opaque wrapper for meta constructors.
Definition: meta.hpp:698
entt::meta_any::meta_any
meta_any(std::reference_wrapper< Type > value)
Constructs a meta any that holds an unmanaged object.
Definition: meta.hpp:233
entt::meta_any::operator=
meta_any & operator=(meta_any other)
Assignment operator.
Definition: meta.hpp:279
entt::meta_func::arg
meta_type arg(size_type index) const noexcept
Returns the meta type of the i-th argument of a meta function.
Definition: meta.hpp:1591
entt::meta_sequence_container::clear
bool clear()
Clears the content of the wrapped container.
Definition: meta.hpp:1776
entt::meta_func::prop
meta_range< meta_prop > prop() const noexcept
Returns a range to use to visit all meta properties.
Definition: meta.hpp:978
entt::meta_associative_container::meta_associative_container
meta_associative_container(Type *container) noexcept
Construct a proxy object for associative containers.
Definition: meta.hpp:114
entt::id_type
std::uint32_t id_type
Alias declaration for type identifiers.
Definition: fwd.hpp:12
entt::meta_type::meta_type
meta_type(node_type *curr=nullptr) noexcept
Constructs an instance from a given node.
Definition: meta.hpp:1027
entt::integral_constant
std::integral_constant< decltype(Value), Value > integral_constant
Wraps a static constant.
Definition: type_traits.hpp:38
entt::meta_any::operator*
meta_any operator*() noexcept
Indirection operator for dereferencing opaque objects.
Definition: meta.hpp:472
entt::meta_sequence_container::meta_iterator::operator!=
bool operator!=(const meta_iterator &other) const noexcept
Checks if two meta iterators refer to the same element.
Definition: meta.hpp:1669
entt::meta_range
Iterable range to use to iterate all types of meta objects.
Definition: range.hpp:16
entt::meta_any::as_sequence_container
meta_sequence_container as_sequence_container() noexcept
Returns a sequence container proxy.
Definition: meta.hpp:455
entt::meta_type::invoke
meta_any invoke(const id_type id, meta_handle instance, meta_any *const args, const std::size_t sz) const
Invokes the function with the given identifier, if possible.
Definition: meta.hpp:1362
entt::meta_any::invoke
meta_any invoke(const id_type id, Args &&... args) const
Invokes the underlying function, if possible.
Definition: meta.hpp:1525
entt::meta_associative_container::meta_iterator::pointer
void pointer
Pointer type, void on purpose.
Definition: meta.hpp:1876
entt::meta_func
Opaque wrapper for meta functions.
Definition: meta.hpp:886
entt::meta_type::func
meta_range< meta_func > func() const noexcept
Returns a range to use to visit top-level meta functions.
Definition: meta.hpp:1292
entt::sparse_set::data
const entity_type * data() const noexcept
Direct access to the internal packed array.
Definition: sparse_set.hpp:278
entt::meta_type::is_member_function_pointer
bool is_member_function_pointer() const noexcept
Checks whether a type refers to a pointer to member function or not.
Definition: meta.hpp:1136
entt::meta_any::convert
bool convert()
Tries to convert an instance to a given type.
Definition: meta.hpp:413
entt::meta_associative_container::meta_associative_container
meta_associative_container() noexcept
Default constructor.
Definition: meta.hpp:104
entt::meta_data::prop
meta_prop prop(meta_any key) const
Returns the property associated with a given key.
Definition: meta.hpp:867
entt::meta_func::is_const
bool is_const() const noexcept
Indicates whether a meta function is constant or not.
Definition: meta.hpp:917
entt::meta_any::set
bool set(const id_type id, Type &&value) const
Sets the value of a given variable.
Definition: meta.hpp:1531
entt::meta_type::node_type
internal::meta_type_node node_type
Node type.
Definition: meta.hpp:1022
entt::meta_any::meta_any
meta_any() noexcept
Default constructor.
Definition: meta.hpp:204
entt::meta_type::is_associative_container
bool is_associative_container() const noexcept
Checks whether a type refers to an associative container or not.
Definition: meta.hpp:1163
entt::meta_any::~meta_any
~meta_any()
Frees the internal storage, whatever it means.
Definition: meta.hpp:268
entt::meta_func::is_static
bool is_static() const noexcept
Indicates whether a meta function is static or not.
Definition: meta.hpp:925
entt::meta_any::emplace
void emplace(Args &&... args)
Replaces the contained object by creating a new instance directly.
Definition: meta.hpp:433
entt::meta_sequence_container::meta_sequence_container
meta_sequence_container(Type *container) noexcept
Construct a proxy object for sequence containers.
Definition: meta.hpp:52
entt::meta_ctor::meta_ctor
meta_ctor(const node_type *curr=nullptr) noexcept
Constructs an instance from a given node.
Definition: meta.hpp:705
entt::meta_associative_container::insert
bool insert(meta_any, meta_any)
Inserts an element (a key/value pair) into the wrapped container.
Definition: meta.hpp:2087
entt::meta_base::type
meta_type type() const noexcept
Returns the meta type of the underlying object.
Definition: meta.hpp:1546
entt::meta_any::try_cast
const Type * try_cast() const
Tries to cast an instance to a given type.
Definition: meta.hpp:343
entt::meta_handle::meta_handle
meta_handle(Type &&value) noexcept
Creates a handle that points to an unmanaged object.
Definition: meta.hpp:544
entt::meta_type::is_sequence_container
bool is_sequence_container() const noexcept
Checks whether a type refers to a sequence container or not.
Definition: meta.hpp:1154
entt::meta_type::ctor
meta_range< meta_ctor > ctor() const noexcept
Returns a range to use to visit top-level meta constructors.
Definition: meta.hpp:1252
entt::meta_associative_container::erase
bool erase(meta_any)
Removes the specified element from the wrapped container.
Definition: meta.hpp:2097
entt::meta_type::is_integral
bool is_integral() const noexcept
Checks whether a type refers to an integral type or not.
Definition: meta.hpp:1059
entt::meta_type::is_pointer
bool is_pointer() const noexcept
Checks whether a type refers to a pointer or not.
Definition: meta.hpp:1108
entt::meta_type::reset
void reset() noexcept
Resets a meta type and all its parts.
Definition: meta.hpp:1470
entt::meta_type::construct
meta_any construct(Args &&... args) const
Creates an instance of the underlying type, if possible.
Definition: meta.hpp:1341
entt::meta_prop::meta_prop
meta_prop(const node_type *curr=nullptr) noexcept
Constructs an instance from a given node.
Definition: meta.hpp:585
entt::meta_type::data
meta_range< meta_data > data() const noexcept
Returns a range to use to visit top-level meta data.
Definition: meta.hpp:1270
entt::meta_type::is_pointer_like
bool is_pointer_like() const noexcept
Checks whether a type is a pointer-like type or not.
Definition: meta.hpp:1145
entt::meta_any::convert
meta_any convert() const
Tries to convert an instance to a given type and returns it.
Definition: meta.hpp:395
entt::meta_sequence_container::begin
iterator begin()
Returns a meta iterator to the first element of the wrapped container.
Definition: meta.hpp:1785
entt::meta_conv::type
meta_type type() const noexcept
Returns the meta type of the underlying object.
Definition: meta.hpp:1556
entt::meta_sequence_container::meta_iterator::iterator_category
std::input_iterator_tag iterator_category
Iterator category.
Definition: meta.hpp:1625
entt::meta_any::type
meta_type type() const noexcept
Returns the meta type of the underlying object.
Definition: meta.hpp:1519
entt
EnTT default namespace.
Definition: algorithm.hpp:13
entt::meta_sequence_container::size_type
std::size_t size_type
Unsigned integer type.
Definition: meta.hpp:37
entt::meta_ctor::invoke
meta_any invoke(meta_any *const args, const std::size_t sz) const
Creates an instance of the underlying type, if possible.
Definition: meta.hpp:738
entt::meta_type::invoke
meta_any invoke(const id_type id, meta_handle instance, Args &&... args) const
Invokes the function with the given identifier, if possible.
Definition: meta.hpp:1379
entt::meta_type::prop
meta_prop prop(meta_any key) const
Returns the property associated with a given key.
Definition: meta.hpp:1436
entt::meta_sequence_container::size
size_type size() const noexcept
Returns the size of the wrapped container.
Definition: meta.hpp:1757
entt::meta_handle::operator*
meta_any operator*() const
Dereference operator for accessing the contained opaque object.
Definition: meta.hpp:559
entt::meta_any::meta_any
meta_any(Type &&value)
Constructs a meta any from a given value.
Definition: meta.hpp:247
entt::meta_associative_container::meta_iterator::operator!=
bool operator!=(const meta_iterator &other) const noexcept
Checks if two meta iterators refer to the same element.
Definition: meta.hpp:1927
entt::meta_ctor::invoke
meta_any invoke([[maybe_unused]] Args &&... args) const
Creates an instance of the underlying type, if possible.
Definition: meta.hpp:752
entt::meta_func::meta_func
meta_func(const node_type *curr=nullptr) noexcept
Constructs an instance from a given node.
Definition: meta.hpp:893
entt::y_combinator
Basic implementation of a y-combinator.
Definition: utility.hpp:71
entt::storage
Basic storage implementation.
Definition: storage.hpp:49
entt::meta_ctor::size_type
typename node_type::size_type size_type
Unsigned integer type.
Definition: meta.hpp:702
entt::meta_associative_container::key_type
meta_type key_type() const noexcept
Returns the key meta type of the wrapped container type.
Definition: meta.hpp:2037
entt::meta_sequence_container::resize
bool resize(size_type) const
Resizes the wrapped container to contain a given number of elements.
Definition: meta.hpp:1767
entt::meta_sequence_container::meta_iterator::operator++
meta_iterator operator++(int) noexcept
Post-increment operator.
Definition: meta.hpp:1648
entt::meta_sequence_container::value_type
meta_type value_type() const noexcept
Returns the value meta type of the wrapped container type.
Definition: meta.hpp:1748
entt::meta_associative_container_traits
Traits class template to be specialized to enable support for meta associative containers.
Definition: type_traits.hpp:24
entt::meta_type::construct
meta_any construct(meta_any *const args, const std::size_t sz) const
Creates an instance of the underlying type, if possible.
Definition: meta.hpp:1321
entt::meta_conv::parent
meta_type parent() const noexcept
Returns the meta type to which a meta object belongs.
Definition: meta.hpp:1551
entt::meta_any::meta_any
meta_any(std::in_place_type_t< Type >, [[maybe_unused]] Args &&... args)
Constructs a meta any by directly initializing the new object.
Definition: meta.hpp:219
entt::meta_func::parent
meta_type parent() const noexcept
Returns the meta type to which a meta object belongs.
Definition: meta.hpp:1581
entt::meta_base::node_type
internal::meta_base_node node_type
Node type.
Definition: meta.hpp:621
entt::invoke
void invoke(basic_registry< Entity > &reg, const Entity entt)
Helper to create a listener that directly invokes a member function.
Definition: helper.hpp:124
entt::meta_any::cast
Type & cast()
Tries to cast an instance to a given type.
Definition: meta.hpp:384
entt::meta_type
Opaque wrapper for meta types.
Definition: meta.hpp:1006
entt::meta_any::as_associative_container
meta_associative_container as_associative_container() noexcept
Returns an associative container proxy.
Definition: meta.hpp:463
entt::meta_associative_container::meta_iterator::reference
value_type reference
Reference type, it is not an actual reference.
Definition: meta.hpp:1878
entt::meta_sequence_container::meta_sequence_container
meta_sequence_container() noexcept
Default constructor.
Definition: meta.hpp:42
entt::meta_type::is_floating_point
bool is_floating_point() const noexcept
Checks whether a type refers to a floating-point type or not.
Definition: meta.hpp:1068
entt::meta_type::id
id_type id() const noexcept
Returns the identifier assigned to a meta object.
Definition: meta.hpp:1043
entt::meta_associative_container::clear
bool clear()
Clears the content of the wrapped container.
Definition: meta.hpp:2064
entt::meta_data::node_type
internal::meta_data_node node_type
Node type.
Definition: meta.hpp:791
entt::meta_type::is_union
bool is_union() const noexcept
Checks whether a type refers to an union or not.
Definition: meta.hpp:1092
entt::meta_associative_container::size
size_type size() const noexcept
Returns the size of the wrapped container.
Definition: meta.hpp:2058
entt::meta_data::get
meta_any get(meta_handle instance) const
Gets the value of a given variable.
Definition: meta.hpp:853
entt::meta_sequence_container::insert
std::pair< iterator, bool > insert(iterator, meta_any)
Inserts an element at a specified location of the wrapped container.
Definition: meta.hpp:1808
entt::meta_type::base
meta_base base(const id_type id) const
Returns the meta base associated with a given identifier.
Definition: meta.hpp:1219
entt::meta_sequence_container::meta_iterator::operator++
meta_iterator & operator++() noexcept
Pre-increment operator.
Definition: meta.hpp:1643
entt::meta_associative_container::mapped_type
meta_type mapped_type() const noexcept
Returns the mapped meta type of the wrapped container type.
Definition: meta.hpp:2046
entt::meta_associative_container::size_type
std::size_t size_type
Unsigned integer type.
Definition: meta.hpp:99
entt::meta_handle
Opaque pointers to instances of any type.
Definition: meta.hpp:534
entt::meta_data::prop
meta_range< meta_prop > prop() const noexcept
Returns a range to use to visit all meta properties.
Definition: meta.hpp:858
entt::meta_base::meta_base
meta_base(const node_type *curr=nullptr) noexcept
Constructs an instance from a given node.
Definition: meta.hpp:624
entt::meta_type::remove_extent
meta_type remove_extent() const noexcept
Provides the meta type for which the array is defined.
Definition: meta.hpp:1202
entt::meta_associative_container::meta_iterator::operator++
meta_iterator operator++(int) noexcept
Post-increment operator.
Definition: meta.hpp:1906
entt::meta_any::data
void * data() noexcept
Returns an opaque pointer to the contained instance.
Definition: meta.hpp:299
entt::meta_type::base
meta_range< meta_base > base() const noexcept
Returns a range to use to visit top-level meta bases.
Definition: meta.hpp:1210
entt::meta_sequence_container::meta_iterator::pointer
void pointer
Pointer type, void on purpose.
Definition: meta.hpp:1621
entt::meta_type::is_enum
bool is_enum() const noexcept
Checks whether a type refers to an enum or not.
Definition: meta.hpp:1084
entt::meta_sequence_container_traits
Traits class template to be specialized to enable support for meta sequence containers.
Definition: type_traits.hpp:16
entt::operator!=
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
Definition: hashed_string.hpp:227
entt::meta_type::get
meta_any get(const id_type id, meta_handle instance) const
Gets the value of a given variable.
Definition: meta.hpp:1415
entt::meta_type::data
meta_data data(const id_type id) const
Returns the meta data associated with a given identifier.
Definition: meta.hpp:1282
entt::meta_prop::value
meta_any value() const
Returns the stored value.
Definition: meta.hpp:601
entt::meta_prop::node_type
internal::meta_prop_node node_type
Node type.
Definition: meta.hpp:579
entt::meta_data::id
id_type id() const noexcept
Returns the identifier assigned to a meta object.
Definition: meta.hpp:799
entt::meta_associative_container::meta_iterator::operator==
bool operator==(const meta_iterator &other) const noexcept
Checks if two meta iterators refer to the same element.
Definition: meta.hpp:1917
entt::meta_type::conv
meta_range< meta_conv > conv() const noexcept
Returns a range to use to visit top-level meta conversion functions.
Definition: meta.hpp:1231
entt::meta_handle::meta_handle
meta_handle()=default
Default constructor.
entt::meta_type::is_class
bool is_class() const noexcept
Checks whether a type refers to a class or not.
Definition: meta.hpp:1100
entt::meta_any::cast
const Type & cast() const
Tries to cast an instance to a given type.
Definition: meta.hpp:376
entt::meta_associative_container::begin
iterator begin()
Returns a meta iterator to the first element of the wrapped container.
Definition: meta.hpp:2070
entt::meta_any::try_cast
Type * try_cast()
Tries to cast an instance to a given type.
Definition: meta.hpp:357
entt::meta_sequence_container::meta_iterator::meta_iterator
meta_iterator() noexcept=default
Default constructor.
entt::meta_ctor::prop
meta_range< meta_prop > prop() const noexcept
Returns a range to use to visit all meta properties.
Definition: meta.hpp:761
entt::meta_ctor::arg
meta_type arg(size_type index) const noexcept
Returns the meta type of the i-th argument of a meta constructor.
Definition: meta.hpp:1566
entt::meta_associative_container::meta_iterator
Opaque iterator for meta associative containers.
Definition: meta.hpp:1846
entt::meta_handle::operator->
meta_any * operator->()
Access operator for accessing the contained opaque object.
Definition: meta.hpp:567
entt::meta_type::set
bool set(const id_type id, meta_handle instance, Type &&value) const
Sets the value of a given variable.
Definition: meta.hpp:1400
entt::meta_type::is_void
bool is_void() const noexcept
Checks whether a type refers to void or not.
Definition: meta.hpp:1051
entt::meta_any::swap
friend void swap(meta_any &lhs, meta_any &rhs)
Swaps two meta any objects.
Definition: meta.hpp:498
entt::meta_sequence_container::meta_iterator::difference_type
std::ptrdiff_t difference_type
Signed integer type.
Definition: meta.hpp:1617
entt::meta_type::conv
meta_conv conv() const
Returns the meta conversion function associated with a given type.
Definition: meta.hpp:1242
entt::meta_any::get
meta_any get(const id_type id) const
Gets the value of a given variable.
Definition: meta.hpp:1536
entt::meta_func::size_type
typename node_type::size_type size_type
Unsigned integer type.
Definition: meta.hpp:890
entt::meta_associative_container::value_type
meta_type value_type() const noexcept
Returns the value meta type of the wrapped container type.
Definition: meta.hpp:2052
entt::meta_associative_container::key_only
bool key_only() const noexcept
Returns true if the associative container is also key-only, false otherwise.
Definition: meta.hpp:2028
entt::meta_type::is_member_object_pointer
bool is_member_object_pointer() const noexcept
Checks whether a type refers to a pointer to data member or not.
Definition: meta.hpp:1126
entt::meta_sequence_container::end
iterator end()
Returns a meta iterator that is past the last element of the wrapped container.
Definition: meta.hpp:1796
entt::meta_associative_container::end
iterator end()
Returns a meta iterator that is past the last element of the wrapped container.
Definition: meta.hpp:2076
entt::meta_base
Opaque wrapper for meta base classes.
Definition: meta.hpp:619