context.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef ENTT_META_CTX_HPP
  2. #define ENTT_META_CTX_HPP
  3. #include "../container/dense_map.hpp"
  4. #include "../core/fwd.hpp"
  5. #include "../core/utility.hpp"
  6. namespace entt {
  7. class meta_ctx;
  8. /**
  9. * @cond TURN_OFF_DOXYGEN
  10. * Internal details not to be documented.
  11. */
  12. namespace internal {
  13. struct meta_type_node;
  14. struct meta_context {
  15. dense_map<id_type, meta_type_node, identity> value{};
  16. [[nodiscard]] inline static meta_context &from(meta_ctx &ctx);
  17. [[nodiscard]] inline static const meta_context &from(const meta_ctx &ctx);
  18. };
  19. } // namespace internal
  20. /**
  21. * Internal details not to be documented.
  22. * @endcond
  23. */
  24. /*! @brief Disambiguation tag for constructors and the like. */
  25. class meta_ctx_arg_t final {};
  26. /*! @brief Constant of type meta_context_arg_t used to disambiguate calls. */
  27. inline constexpr meta_ctx_arg_t meta_ctx_arg{};
  28. /*! @brief Opaque meta context type. */
  29. class meta_ctx: private internal::meta_context {
  30. // attorney idiom like model to access the base class
  31. friend struct internal::meta_context;
  32. };
  33. /**
  34. * @cond TURN_OFF_DOXYGEN
  35. * Internal details not to be documented.
  36. */
  37. [[nodiscard]] inline internal::meta_context &internal::meta_context::from(meta_ctx &ctx) {
  38. return ctx;
  39. }
  40. [[nodiscard]] inline const internal::meta_context &internal::meta_context::from(const meta_ctx &ctx) {
  41. return ctx;
  42. }
  43. /**
  44. * Internal details not to be documented.
  45. * @endcond
  46. */
  47. } // namespace entt
  48. #endif