From 3f4897826816ab794e5c4461198785bfe963c6a4 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sat, 26 Oct 2013 19:14:40 +0400 Subject: [PATCH] Another commit right in the midle of modifications --- ...mplate_info_impl.hpp => template_info.hpp} | 0 boost/type_index/type_info.hpp | 18 +++---- boost/type_index/type_info_impl.hpp | 52 ++++--------------- libs/type_index/test/template_index_test.cpp | 2 +- libs/type_index/test/type_index_test.cpp | 4 +- 5 files changed, 22 insertions(+), 54 deletions(-) rename boost/type_index/{template_info_impl.hpp => template_info.hpp} (100%) diff --git a/boost/type_index/template_info_impl.hpp b/boost/type_index/template_info.hpp similarity index 100% rename from boost/type_index/template_info_impl.hpp rename to boost/type_index/template_info.hpp diff --git a/boost/type_index/type_info.hpp b/boost/type_index/type_info.hpp index 255d4cf..000398a 100644 --- a/boost/type_index/type_info.hpp +++ b/boost/type_index/type_info.hpp @@ -6,8 +6,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BOOST_TYPE_INDEX_TYPE_INDEX_MINIMAL_HPP -#define BOOST_TYPE_INDEX_TYPE_INDEX_MINIMAL_HPP +#ifndef BOOST_TYPE_INDEX_TYPE_INFO_HPP +#define BOOST_TYPE_INDEX_TYPE_INFO_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) @@ -23,9 +23,9 @@ #include #if !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY) -# include +# include #else -# include +# include # include namespace boost { @@ -33,23 +33,23 @@ namespace boost { typedef template_index type_index; template -inline type_index type_id() BOOST_NOEXCEPT { +inline const type_index& type_id() BOOST_NOEXCEPT { return template_index::construct(); } template -inline type_index type_id_with_cvr() BOOST_NOEXCEPT { +inline const type_index& type_id_with_cvr() BOOST_NOEXCEPT { return template_index::construct_with_cvr(); } template -inline type_index type_id_rtti_only(T& rtti_val) BOOST_NOEXCEPT { +inline const type_index& type_id_rtti_only(T& rtti_val) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG(sizeof(T) && false, "boost::type_id_rtti_only(T&) requires RTTI"); return type_index(); } template -inline type_index type_id_rtti_only(T* rtti_val) { +inline const type_index& type_id_rtti_only(T* rtti_val) { BOOST_STATIC_ASSERT_MSG(sizeof(T) && false, "boost::type_id_rtti_only(T*) requires RTTI"); return type_index(); } @@ -66,5 +66,5 @@ inline type_index type_id_rtti_only(T* rtti_val) { #define BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY #endif // BOOST_TYPE_INDEX_DOXYGEN_INVOKED -#endif // BOOST_TYPE_INDEX_TYPE_INDEX_MINIMAL_HPP +#endif // BOOST_TYPE_INDEX_TYPE_INFO_HPP diff --git a/boost/type_index/type_info_impl.hpp b/boost/type_index/type_info_impl.hpp index 037220d..87405d1 100644 --- a/boost/type_index/type_info_impl.hpp +++ b/boost/type_index/type_info_impl.hpp @@ -5,17 +5,17 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BOOST_TYPE_INDEX_TYPE_INDEX_IMPL_HPP -#define BOOST_TYPE_INDEX_TYPE_INDEX_IMPL_HPP +#ifndef BOOST_TYPE_INDEX_TYPE_INFO_IMPL_HPP +#define BOOST_TYPE_INDEX_TYPE_INFO_IMPL_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) # pragma once #endif -#ifndef BOOST_TYPE_INDEX_TYPE_INDEX_MINIMAL_HPP -#error "Header must not be included directly." -#error "Include or instead." +#ifndef BOOST_TYPE_INDEX_TYPE_INFO_HPP +#error "Header must not be included directly." +#error "Include or instead." #endif /// \file type_info_impl.hpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -48,14 +47,6 @@ #include #endif -#if !defined(BOOST_NO_IOSTREAM) -#if !defined(BOOST_NO_IOSFWD) -#include // for std::basic_ostream -#else -#include -#endif -#endif - #ifdef __GNUC__ #include #endif @@ -89,7 +80,9 @@ namespace detail { template class cvr_saver{}; } -/// boost::type_info is a class that can be used as a drop-in replacement for std::type_info +/// boost::type_info is a class that can be used as a drop-in replacement for std::type_info. +/// It has all the workarounds for compatability and also has a name_demangled() method for +/// getting human-readable type names. class type_info: public detail::stl_type_info { public: /// Factory method for constructing boost::type_info instance for type T. @@ -253,39 +246,14 @@ inline const type_info& type_id_rtti_only(T* rtti_val) { /* *************** type_index free functions ******************* */ -/// @cond - -#ifndef BOOST_NO_IOSTREAM -#ifdef BOOST_NO_TEMPLATED_IOSTREAMS - -/// Ostream operator that will output demangled name. -inline std::ostream& operator<<(std::ostream& ostr, type_index const& ind) { - ostr << ind.name_demangled(); - return ostr; -} - -#else - -/// Ostream operator that will output demangled name. -template -inline std::basic_ostream& operator<<(std::basic_ostream& ostr, type_index const& ind) { - ostr << ind.name_demangled(); - return ostr; -} - -#endif // BOOST_NO_TEMPLATED_IOSTREAMS -#endif // BOOST_NO_IOSTREAM - -/// hash_value function overload for type_index. +/// hash_value function overload for boost::type_info. inline std::size_t hash_value(type_index const& v) BOOST_NOEXCEPT { return v.hash_code(); } -/// @endcond - #endif // BOOST_NO_RTTI } // namespace boost -#endif // BOOST_TYPE_INDEX_TYPE_INDEX_IMPL_HPP +#endif // BOOST_TYPE_INDEX_TYPE_INFO_IMPL_HPP diff --git a/libs/type_index/test/template_index_test.cpp b/libs/type_index/test/template_index_test.cpp index 415a0d8..2605900 100644 --- a/libs/type_index/test/template_index_test.cpp +++ b/libs/type_index/test/template_index_test.cpp @@ -11,7 +11,7 @@ // Byapssing internal assertion for correct header inclusion #define BOOST_TYPE_INDEX_TYPE_INDEX_MINIMAL_HPP -#include +#include namespace my_namespace1 { class my_class{}; diff --git a/libs/type_index/test/type_index_test.cpp b/libs/type_index/test/type_index_test.cpp index ce68309..fc63707 100644 --- a/libs/type_index/test/type_index_test.cpp +++ b/libs/type_index/test/type_index_test.cpp @@ -9,9 +9,9 @@ #include // Byapssing internal assertion for correct header inclusion -#define BOOST_TYPE_INDEX_TYPE_INDEX_MINIMAL_HPP +#define BOOST_TYPE_INDEX_TYPE_INFO_HPP -#include +#include namespace my_namespace1 { class my_class{};