Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 08:52:04

0001 // Copyright (c) 2018-2025 Jean-Louis Leroy
0002 // Distributed under the Boost Software License, Version 1.0.
0003 // See accompanying file LICENSE_1_0.txt
0004 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_OPENMETHOD_POLICY_MINIMAL_RTTI_HPP
0007 #define BOOST_OPENMETHOD_POLICY_MINIMAL_RTTI_HPP
0008 
0009 #include <boost/openmethod/preamble.hpp>
0010 
0011 namespace boost::openmethod::policies {
0012 
0013 //! Minimal implementation of the `rtti` policy.
0014 //!
0015 //! `static_rtti` implements only the static parts of the `rtti` policy. It uses
0016 //! the addresses of a per-class static variables as a `type_id`. It categorizes
0017 //! all types as non-polymorphic. As a consequence, the `virtual_ptr`
0018 //! constructors that take a pointer or a reference to a polymorphic object are
0019 //! disabled. `virtual_ptr` must be constructed using @ref final_virtual_ptr (or
0020 //! its equivalents for smart pointers).
0021 //!
0022 //! @par Example
0023 //! TODO
0024 //! include::example$static_rtti.cpp[tag=all]
0025 struct static_rtti : rtti {
0026     //! A RttiFn metafunction.
0027     //!
0028     //! @tparam Registry The registry containing this policy.
0029     template<class Registry>
0030     struct fn : rtti::defaults {
0031         //! Always evaluates to `false`.
0032         //! @tparam Class A class.
0033         template<class Class>
0034         static constexpr bool is_polymorphic = false;
0035 
0036         //! Returns the @ref type_id of `Class`.
0037         //!
0038         //! @tparam Class A class.
0039         template<typename T>
0040         static auto static_type() -> type_id {
0041             static char id;
0042             return &id;
0043         }
0044     };
0045 };
0046 
0047 } // namespace boost::openmethod::policies
0048 
0049 #endif