Squashed 'third_party/boostorg/type_index/' content from commit c2caa34

Change-Id: I76e1c1099cbf17522d18a78a42581be067301ca4
git-subtree-dir: third_party/boostorg/type_index
git-subtree-split: c2caa340ab9d9d834c5ffafb3f267b3c46c8c821
diff --git a/patched/README.md b/patched/README.md
new file mode 100644
index 0000000..4dab0d6
--- /dev/null
+++ b/patched/README.md
@@ -0,0 +1,9 @@
+patches for Boost libraries to work without RTTI 
+==========
+
+Here are the patches that are TESTED and work well with RTTI disabled and enabled. 
+Patches add tests for some of the libraries to make sure that library compile and work without RTTI.
+
+Patches remove duplicate code, improve output, allow compilation with RTTI off...
+
+Libraries Boost.Graph, Boost.XPressive, Boost.PropertyMap and others may also benefit from TypeIndex library.
diff --git a/patched/boost_detail_sp_typeinfo.patch b/patched/boost_detail_sp_typeinfo.patch
new file mode 100644
index 0000000..b0649e0
--- /dev/null
+++ b/patched/boost_detail_sp_typeinfo.patch
@@ -0,0 +1,151 @@
+From b77c0af6af8bc4797defc3627878acc3cf7a6f39 Mon Sep 17 00:00:00 2001
+From: Antony Polukhin <antoshkka@gmail.com>
+Date: Thu, 20 Feb 2014 17:57:24 +0400
+Subject: [PATCH] detail/sp_typeinfo.hpp now uses TypeIndex
+
+---
+ include/boost/detail/sp_typeinfo.hpp | 123 +++--------------------------------
+ 1 file changed, 8 insertions(+), 115 deletions(-)
+
+diff --git a/include/boost/detail/sp_typeinfo.hpp b/include/boost/detail/sp_typeinfo.hpp
+index 43fae78..fbdf86d 100644
+--- a/include/boost/detail/sp_typeinfo.hpp
++++ b/include/boost/detail/sp_typeinfo.hpp
+@@ -10,126 +10,19 @@
+ //  detail/sp_typeinfo.hpp
+ //
+ //  Copyright 2007 Peter Dimov
++//  Copyright 2014 Antony Polukhin
+ //
+ // 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)
+ 
+-#include <boost/config.hpp>
++#include <boost/type_index.hpp>
++namespace boost { namespace detail {
++ 
++typedef boost::typeind::type_info sp_typeinfo;
++ 
++}} // namespace boost::detail
+ 
+-#if defined( BOOST_NO_TYPEID )
+-
+-#include <boost/current_function.hpp>
+-#include <functional>
+-
+-namespace boost
+-{
+-
+-namespace detail
+-{
+-
+-class sp_typeinfo
+-{
+-private:
+-
+-    sp_typeinfo( sp_typeinfo const& );
+-    sp_typeinfo& operator=( sp_typeinfo const& );
+-
+-    char const * name_;
+-
+-public:
+-
+-    explicit sp_typeinfo( char const * name ): name_( name )
+-    {
+-    }
+-
+-    bool operator==( sp_typeinfo const& rhs ) const
+-    {
+-        return this == &rhs;
+-    }
+-
+-    bool operator!=( sp_typeinfo const& rhs ) const
+-    {
+-        return this != &rhs;
+-    }
+-
+-    bool before( sp_typeinfo const& rhs ) const
+-    {
+-        return std::less< sp_typeinfo const* >()( this, &rhs );
+-    }
+-
+-    char const* name() const
+-    {
+-        return name_;
+-    }
+-};
+-
+-template<class T> struct sp_typeid_
+-{
+-    static sp_typeinfo ti_;
+-
+-    static char const * name()
+-    {
+-        return BOOST_CURRENT_FUNCTION;
+-    }
+-};
+-
+-#if defined(__SUNPRO_CC)
+-// see #4199, the Sun Studio compiler gets confused about static initialization 
+-// constructor arguments. But an assignment works just fine. 
+-template<class T> sp_typeinfo sp_typeid_< T >::ti_ = sp_typeid_< T >::name();
+-#else
+-template<class T> sp_typeinfo sp_typeid_< T >::ti_(sp_typeid_< T >::name());
+-#endif
+-
+-template<class T> struct sp_typeid_< T & >: sp_typeid_< T >
+-{
+-};
+-
+-template<class T> struct sp_typeid_< T const >: sp_typeid_< T >
+-{
+-};
+-
+-template<class T> struct sp_typeid_< T volatile >: sp_typeid_< T >
+-{
+-};
+-
+-template<class T> struct sp_typeid_< T const volatile >: sp_typeid_< T >
+-{
+-};
+-
+-} // namespace detail
+-
+-} // namespace boost
+-
+-#define BOOST_SP_TYPEID(T) (boost::detail::sp_typeid_<T>::ti_)
+-
+-#else
+-
+-#include <typeinfo>
+-
+-namespace boost
+-{
+-
+-namespace detail
+-{
+-
+-#if defined( BOOST_NO_STD_TYPEINFO )
+-
+-typedef ::type_info sp_typeinfo;
+-
+-#else
+-
+-typedef std::type_info sp_typeinfo;
+-
+-#endif
+-
+-} // namespace detail
+-
+-} // namespace boost
+-
+-#define BOOST_SP_TYPEID(T) typeid(T)
+-
+-#endif
++#define BOOST_SP_TYPEID(T) (boost::typeind::type_id<T>().type_info())
+ 
+ #endif  // #ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED
+-- 
+1.8.5.3
+
diff --git a/patched/boost_exception.patch b/patched/boost_exception.patch
new file mode 100644
index 0000000..9b3643e
--- /dev/null
+++ b/patched/boost_exception.patch
@@ -0,0 +1,156 @@
+From 8f57d59bfbc978673a2493a90b4f3e7e54ddbf18 Mon Sep 17 00:00:00 2001
+From: Antony Polukhin <antoshkka@gmail.com>
+Date: Thu, 20 Feb 2014 18:30:11 +0400
+Subject: [PATCH] Boost.Exception now uses TypeIndex to reduce duplicate code
+ and simplify name demanglings
+
+---
+ include/boost/exception/detail/type_info.hpp       | 43 +++-------------------
+ include/boost/exception/diagnostic_information.hpp |  2 +-
+ include/boost/exception/exception.hpp              |  3 +-
+ include/boost/exception/info.hpp                   |  2 +-
+ test/Jamfile.v2                                    |  2 +
+ 5 files changed, 12 insertions(+), 40 deletions(-)
+
+diff --git a/include/boost/exception/detail/type_info.hpp b/include/boost/exception/detail/type_info.hpp
+index 6e5942d..a247b71 100644
+--- a/include/boost/exception/detail/type_info.hpp
++++ b/include/boost/exception/detail/type_info.hpp
+@@ -12,13 +12,7 @@
+ #pragma warning(push,1)
+ #endif
+ 
+-#include <boost/detail/sp_typeinfo.hpp>
+-#include <boost/current_function.hpp>
+-#include <boost/config.hpp>
+-//#ifndef BOOST_NO_TYPEID
+-//#include <boost/units/detail/utility.hpp>
+-//#endif
+-#include <string>
++#include <boost/type_index.hpp>
+ 
+ namespace
+ boost
+@@ -28,11 +22,7 @@ boost
+     std::string
+     tag_type_name()
+         {
+-#ifdef BOOST_NO_TYPEID
+-        return BOOST_CURRENT_FUNCTION;
+-#else
+-        return /*units::detail::demangle*/(typeid(T*).name());
+-#endif
++        return boost::typeind::type_id<T*>().pretty_name();
+         }
+ 
+     template <class T>
+@@ -40,41 +30,20 @@ boost
+     std::string
+     type_name()
+         {
+-#ifdef BOOST_NO_TYPEID
+-        return BOOST_CURRENT_FUNCTION;
+-#else
+-        return /*units::detail::demangle*/(typeid(T).name());
+-#endif
++        return boost::typeind::type_id<T>().pretty_name();
+         }
+ 
+     namespace
+     exception_detail
+         {
+-        struct
+-        type_info_
+-            {
+-            detail::sp_typeinfo const * type_;
+-
+-            explicit
+-            type_info_( detail::sp_typeinfo const & type ):
+-                type_(&type)
+-                {
+-                }
+-
+-            friend
+-            bool
+-            operator<( type_info_ const & a, type_info_ const & b )
+-                {
+-                return 0!=(a.type_->before(*b.type_));
+-                }
+-            };
++        typedef boost::typeind::type_index type_info_;
+         }
+     }
+ 
+-#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T))
++#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::typeind::type_id<T>()
+ 
+ #ifndef BOOST_NO_RTTI
+-#define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::exception_detail::type_info_(typeid(x))
++#define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::typeind::type_id_runtime(x)
+ #endif
+ 
+ #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
+diff --git a/include/boost/exception/diagnostic_information.hpp b/include/boost/exception/diagnostic_information.hpp
+index 2f5cb88..0f8b5e8 100644
+--- a/include/boost/exception/diagnostic_information.hpp
++++ b/include/boost/exception/diagnostic_information.hpp
+@@ -151,7 +151,7 @@ boost
+ #ifndef BOOST_NO_RTTI
+             if ( verbose )
+                 tmp << std::string("Dynamic exception type: ") <<
+-                    /*units::detail::demangle*/((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
++                    /*units::detail::demangle*/((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)))) << '\n';
+ #endif
+             if( with_what && se && verbose )
+                 tmp << "std::exception::what: " << wh << '\n';
+diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp
+index 9f20a04..53c341f 100644
+--- a/include/boost/exception/exception.hpp
++++ b/include/boost/exception/exception.hpp
+@@ -12,6 +12,8 @@
+ #pragma warning(push,1)
+ #endif
+ 
++#include <boost/exception/detail/type_info.hpp>
++
+ namespace
+ boost
+     {
+@@ -151,7 +153,6 @@ boost
+     exception_detail
+         {
+         class error_info_base;
+-        struct type_info_;
+ 
+         struct
+         error_info_container
+diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp
+index edbf058..e0f4950 100644
+--- a/include/boost/exception/info.hpp
++++ b/include/boost/exception/info.hpp
+@@ -96,7 +96,7 @@ boost
+                     {
+                     shared_ptr<error_info_base> const & p = i->second;
+ #ifndef BOOST_NO_RTTI
+-                    BOOST_ASSERT( *BOOST_EXCEPTION_DYNAMIC_TYPEID(*p).type_==*ti.type_ );
++                    BOOST_ASSERT(BOOST_EXCEPTION_DYNAMIC_TYPEID(*p)==ti );
+ #endif
+                     return p;
+                     }
+diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
+index d2dfcd6..5bd076d 100644
+--- a/test/Jamfile.v2
++++ b/test/Jamfile.v2
+@@ -35,7 +35,9 @@ run enable_error_info_test.cpp helper1.cpp ;
+ run throw_exception_test.cpp helper2.cpp ;
+ run errno_test.cpp ;
+ run error_info_test.cpp ;
++run error_info_test.cpp : : : <rtti>off : error_info_test_rtti ;
+ run diagnostic_information_test.cpp ;
++run diagnostic_information_test.cpp : : : <rtti>off : diagnostic_information_test_rtti ;
+ run refcount_ptr_test.cpp ;
+ run current_exception_cast_test.cpp ;
+ run no_exceptions_test.cpp : : : <exception-handling>off ;
+-- 
+1.8.5.3
+
diff --git a/patched/boost_smart_ptr.patch b/patched/boost_smart_ptr.patch
new file mode 100644
index 0000000..5120199
--- /dev/null
+++ b/patched/boost_smart_ptr.patch
@@ -0,0 +1,26 @@
+From 03194eefcb9c3314054855d28bd9a90d3188768d Mon Sep 17 00:00:00 2001
+From: Antony Polukhin <antoshkka@gmail.com>
+Date: Thu, 20 Feb 2014 18:50:10 +0400
+Subject: [PATCH] Use TypeIndex features in Boost.SharedPtr to avoid type_info
+ related bugs
+
+---
+ include/boost/smart_ptr/detail/sp_counted_impl.hpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/boost/smart_ptr/detail/sp_counted_impl.hpp b/include/boost/smart_ptr/detail/sp_counted_impl.hpp
+index a7b43ae..5955036 100644
+--- a/include/boost/smart_ptr/detail/sp_counted_impl.hpp
++++ b/include/boost/smart_ptr/detail/sp_counted_impl.hpp
+@@ -155,7 +155,7 @@ public:
+ 
+     virtual void * get_deleter( detail::sp_typeinfo const & ti )
+     {
+-        return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0;
++        return ti == boost::typeind::type_id<D>()? &reinterpret_cast<char&>( del ): 0;
+     }
+ 
+     virtual void * get_untyped_deleter()
+-- 
+1.8.5.3
+