1 // (C) Copyright Gennadiy Rozental 2001.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // See http://www.boost.org/libs/test for the library home page.
10 // Version : $Revision$
12 // Description : simple facilities for accessing type information at runtime
13 // ***************************************************************************
15 #ifndef BOOST_TEST_UTILS_RTTI_HPP
16 #define BOOST_TEST_UTILS_RTTI_HPP
20 #include <boost/test/detail/config.hpp>
25 // ************************************************************************** //
26 // ************** rtti::type_id ************** //
27 // ************************************************************************** //
29 typedef std::ptrdiff_t id_t;
31 namespace rtti_detail {
34 struct BOOST_TEST_DECL rttid_holder {
35 static id_t id() { return reinterpret_cast<id_t>( &inst() ); }
40 static rttid const& inst() { static rttid s_inst; return s_inst; }
43 } // namespace rtti_detail
45 //____________________________________________________________________________//
48 BOOST_TEST_DECL inline id_t
51 return rtti_detail::rttid_holder<T>::id();
54 //____________________________________________________________________________//
56 #define BOOST_RTTI_SWITCH( type_id_ ) if( ::boost::rtti::id_t switch_by_id = type_id_ )
57 #define BOOST_RTTI_CASE( type ) if( switch_by_id == ::boost::rtti::type_id<type>() )
59 //____________________________________________________________________________//
64 #endif // BOOST_TEST_UTILS_RTTI_HPP