default_registry.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (c) 2018-2025 Jean-Louis Leroy
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // See accompanying file LICENSE_1_0.txt
  4. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_OPENMETHOD_DEFAULT_REGISTRY_HPP
  6. #define BOOST_OPENMETHOD_DEFAULT_REGISTRY_HPP
  7. #include <boost/openmethod/preamble.hpp>
  8. #include <boost/openmethod/policies/std_rtti.hpp>
  9. #include <boost/openmethod/policies/vptr_vector.hpp>
  10. #include <boost/openmethod/policies/stderr_output.hpp>
  11. #include <boost/openmethod/policies/fast_perfect_hash.hpp>
  12. #include <boost/openmethod/policies/default_error_handler.hpp>
  13. namespace boost::openmethod {
  14. //! Default registry.
  15. //!
  16. //! `default_registry` is a predefined @ref registry, and the default value of
  17. //! {{BOOST_OPENMETHOD_DEFAULT_REGISTRY}}.
  18. //! It contains the following policies:
  19. //! @li @ref policies::std_rtti: Use standard RTTI.
  20. //! @li @ref policies::fast_perfect_hash: Use a fast perfect hash function to
  21. //! map type ids to indices.
  22. //! @li @ref policies::vptr_vector: Store v-table pointers in a `std::vector`.
  23. //! @li @ref policies::default_error_handler: Write short diagnostic messages.
  24. //! @li @ref policies::stderr_output: Write messages to `stderr`.
  25. //!
  26. //! If
  27. //! {{BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS}}
  28. //! is defined, `default_registry` also includes the @ref runtime_checks policy.
  29. //!
  30. //! @note Use `BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS` with caution, as
  31. //! inconsistent use of the macro can cause ODR violations. If defined, it must
  32. //! be in all the translation units in the program that use `default_registry`,
  33. //! including those pulled from libraries.
  34. struct default_registry
  35. : registry<
  36. policies::std_rtti, policies ::vptr_vector,
  37. policies::fast_perfect_hash, policies::default_error_handler,
  38. policies::stderr_output
  39. #ifdef BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS
  40. ,
  41. policies::runtime_checks
  42. #endif
  43. > {
  44. };
  45. namespace detail {
  46. static odr_check<default_registry> default_registry_odr_check_instance;
  47. }
  48. //! Indirect registry.
  49. //!
  50. //! `indirect_registry` is a predefined @ref registry that uses the same
  51. //! policies as @ref default_registry, plus the @ref indirect_vptr policy.
  52. //!
  53. //! @see indirect_vptr.
  54. struct indirect_registry : default_registry::with<policies::indirect_vptr> {};
  55. } // namespace boost::openmethod
  56. #endif