Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:43

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 //  File        : $RCSfile$
0009 //
0010 //  Version     : $Revision$
0011 //
0012 //  Description : simple facilities for accessing type information at runtime
0013 // ***************************************************************************
0014 
0015 #ifndef BOOST_TEST_UTILS_RTTI_HPP
0016 #define BOOST_TEST_UTILS_RTTI_HPP
0017 
0018 // C Runtime
0019 #include <cstddef>
0020 #include <boost/test/detail/config.hpp>
0021 
0022 namespace boost {
0023 namespace rtti {
0024 
0025 // ************************************************************************** //
0026 // **************                   rtti::type_id              ************** //
0027 // ************************************************************************** //
0028 
0029 typedef std::ptrdiff_t id_t;
0030 
0031 namespace rtti_detail {
0032 
0033 template<typename T>
0034 struct BOOST_TEST_DECL rttid_holder {
0035     static id_t id() { return reinterpret_cast<id_t>( &inst() ); }
0036 
0037 private:
0038     struct rttid {};
0039 
0040     static rttid const& inst() { static rttid s_inst; return s_inst; }
0041 };
0042 
0043 } // namespace rtti_detail
0044 
0045 //____________________________________________________________________________//
0046 
0047 template<typename T>
0048 BOOST_TEST_DECL inline id_t
0049 type_id()
0050 {
0051     return rtti_detail::rttid_holder<T>::id();
0052 }
0053 
0054 //____________________________________________________________________________//
0055 
0056 #define BOOST_RTTI_SWITCH( type_id_ ) if( ::boost::rtti::id_t switch_by_id = type_id_ )
0057 #define BOOST_RTTI_CASE( type )       if( switch_by_id == ::boost::rtti::type_id<type>() )
0058 
0059 //____________________________________________________________________________//
0060 
0061 } // namespace rtti
0062 } // namespace boost
0063 
0064 #endif // BOOST_TEST_UTILS_RTTI_HPP