forked from boostorg/type_index
Some MSVC related updates and docs improvements
This commit is contained in:
@ -25,6 +25,9 @@
|
||||
# include BOOST_TYPE_INDEX_USER_TYPEINDEX
|
||||
#elif (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
# include <boost/type_index/stl_type_index.hpp>
|
||||
# ifdef BOOST_NO_RTTI
|
||||
# inlcude <boost/type_index/stl_register_class.hpp>
|
||||
# endif
|
||||
#else
|
||||
# include <boost/type_index/ctti_type_index.hpp>
|
||||
# include <boost/type_index/ctti_register_class.hpp>
|
||||
@ -43,7 +46,11 @@ namespace boost { namespace typeind {
|
||||
// Nothing to do
|
||||
#elif (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
typedef boost::typeind::stl_type_index type_index;
|
||||
# define BOOST_TYPE_INDEX_REGISTER_CLASS
|
||||
# ifdef BOOST_NO_RTTI
|
||||
# define BOOST_TYPE_INDEX_REGISTER_CLASS BOOST_TYPE_INDEX_REGISTER_STL_CLASS
|
||||
# else
|
||||
# define BOOST_TYPE_INDEX_REGISTER_CLASS
|
||||
# endif
|
||||
#else
|
||||
typedef boost::typeind::ctti_type_index type_index;
|
||||
# define BOOST_TYPE_INDEX_REGISTER_CLASS BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS
|
||||
@ -58,10 +65,12 @@ typedef type_index::type_info_t type_info;
|
||||
|
||||
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_USER_TYPEINFO
|
||||
/// BOOST_TYPE_INDEX_USER_TYPEINFO can be defined to the path to header file
|
||||
/// \def BOOST_TYPE_INDEX_USER_TYPEINDEX
|
||||
/// BOOST_TYPE_INDEX_USER_TYPEINDEX can be defined to the path to header file
|
||||
/// with user provided implementation of type_index.
|
||||
#define BOOST_TYPE_INDEX_USER_TYPEINDEX <full/absolute/path/to/header/with/type_index>
|
||||
///
|
||||
/// See "Making own type_index" section of documentation for usage example.
|
||||
#define BOOST_TYPE_INDEX_USER_TYPEINDEX <full/absolute/path/to/header/with/type_index.hpp>
|
||||
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_REGISTER_CLASS
|
||||
@ -139,8 +148,7 @@ inline type_index type_id_with_cvr() BOOST_NOEXCEPT {
|
||||
///
|
||||
/// Retunrs runtime information about specified type.
|
||||
///
|
||||
/// \b Requirements: RTTI available or specially designed user type_info class must be provided
|
||||
/// via BOOST_TYPE_INDEX_USER_TYPEINDEX and BOOST_TYPE_INDEX_USER_TYPEINDEX_NAME macro.
|
||||
/// \b Requirements: RTTI available or Base and Derived classes must be marked with BOOST_TYPE_INDEX_REGISTER_CLASS.
|
||||
///
|
||||
/// \b Example:
|
||||
/// \code
|
||||
|
@ -28,7 +28,12 @@ inline const ctti_data& ctti_construct_typeid_ref(const T*) BOOST_NOEXCEPT {
|
||||
|
||||
}}} // namespace boost::typeind::detail
|
||||
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS
|
||||
/// BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS is used by BOOST_TYPE_INDEX_REGISTER_CLASS when RTTI is off
|
||||
/// and `typeid()` does not work.
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS macro expands to declaration and implementation of
|
||||
/// `virtual const detail::ctti_data& type_id_runtime() const` method.
|
||||
#define BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS \
|
||||
virtual const boost::typeind::detail::ctti_data& type_id_runtime() const BOOST_NOEXCEPT { \
|
||||
return boost::typeind::detail::ctti_construct_typeid_ref(this); \
|
||||
|
45
include/boost/type_index/stl_register_class.hpp
Normal file
45
include/boost/type_index/stl_register_class.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright (c) Antony Polukhin, 2013-2014.
|
||||
//
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_STL_REGISTER_CLASS_HPP
|
||||
#define BOOST_TYPE_INDEX_STL_REGISTER_CLASS_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/// \file stl_register_class.hpp
|
||||
/// \brief Contains BOOST_TYPE_INDEX_REGISTER_STL_CLASS macro.
|
||||
|
||||
#include <boost/type_index/stl_type_index.hpp>
|
||||
|
||||
namespace boost { namespace typeind { namespace detail {
|
||||
|
||||
template <class T>
|
||||
inline const stl_type_index::type_info_t& stl_construct_typeid_ref(const T*) BOOST_NOEXCEPT {
|
||||
return typeid(T);
|
||||
}
|
||||
|
||||
}}} // namespace boost::typeind::detail
|
||||
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_REGISTER_STL_CLASS
|
||||
/// BOOST_TYPE_INDEX_REGISTER_STL_CLASS is used by BOOST_TYPE_INDEX_REGISTER_CLASS when RTTI is off
|
||||
/// and `typeid()` does work.
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_REGISTER_STL_CLASS macro expands to declaration and implementation of
|
||||
/// `virtual const std::type_info& type_id_runtime() const` method.
|
||||
#define BOOST_TYPE_INDEX_REGISTER_STL_CLASS \
|
||||
virtual const boost::typeind::stl_type_index::type_info_t& type_id_runtime() const BOOST_NOEXCEPT { \
|
||||
return boost::typeind::detail::stl_construct_typeid_ref(this); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_STL_REGISTER_CLASS_HPP
|
||||
|
@ -249,8 +249,7 @@ inline stl_type_index stl_type_index::type_id_with_cvr() BOOST_NOEXCEPT {
|
||||
template <class T>
|
||||
inline stl_type_index stl_type_index::type_id_runtime(const T& value) BOOST_NOEXCEPT {
|
||||
#ifdef BOOST_NO_RTTI
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(T) && false,
|
||||
"stl_type_index::type_id_runtime(const T&) require RTTI");
|
||||
return value.type_id_runtime();
|
||||
#endif
|
||||
return typeid(value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user