blob: 688002c411c128a62a097a32ac26a0502590c172 [file] [log] [blame]
From b59340efc30219492b095d2cfcdb8183b3e35b69 Mon Sep 17 00:00:00 2001
From: Antony Polukhin <antoshkka@gmail.com>
Date: Thu, 20 Feb 2014 17:06:44 +0400
Subject: [PATCH 1/2] Boost.Any not can work without RTTI support.
---
test/Jamfile.v2 | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index cd167dc..76f9e5a 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -9,6 +9,7 @@
test-suite any :
[ run any_test.cpp ]
[ run any_test_rv.cpp ]
+ [ run any_test_rv.cpp : : : <rtti>off : any_test_rv_no_rtti ]
[ compile-fail any_cast_cv_failed.cpp ]
[ compile-fail any_test_temporary_to_ref_failed.cpp ]
[ compile-fail any_test_cv_to_rv_failed.cpp ]
--
1.8.5.3
From 62b9b01713fc50355f82e892bc0fd5618ce5c648 Mon Sep 17 00:00:00 2001
From: Antony Polukhin <antoshkka@gmail.com>
Date: Thu, 20 Feb 2014 17:30:42 +0400
Subject: [PATCH 2/2] Boost.Any not can work without RTTI support.
---
include/boost/any.hpp | 37 +++++++++++++------------------------
1 file changed, 13 insertions(+), 24 deletions(-)
diff --git a/include/boost/any.hpp b/include/boost/any.hpp
index a63fea4..bda00a2 100644
--- a/include/boost/any.hpp
+++ b/include/boost/any.hpp
@@ -15,9 +15,9 @@
// when: July 2001, April 2013 - May 2013
#include <algorithm>
-#include <typeinfo>
#include "boost/config.hpp"
+#include <boost/type_index.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/type_traits/add_reference.hpp>
@@ -29,17 +29,6 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp>
-// See boost/python/type_id.hpp
-// TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp
-# if defined(__GNUC__) \
- || defined(_AIX) \
- || ( defined(__sgi) && defined(__host_mips)) \
- || (defined(__hpux) && defined(__HP_aCC)) \
- || (defined(linux) && defined(__INTEL_COMPILER) && defined(__ICC))
-# define BOOST_AUX_ANY_TYPE_ID_NAME
-#include <cstring>
-# endif
-
namespace boost
{
class any
@@ -144,9 +133,9 @@ namespace boost
any().swap(*this);
}
- const std::type_info & type() const BOOST_NOEXCEPT
+ const boost::typeind::type_info& type() const BOOST_NOEXCEPT
{
- return content ? content->type() : typeid(void);
+ return content ? content->type() : boost::typeind::type_id<void>().type_info();
}
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -165,7 +154,7 @@ namespace boost
public: // queries
- virtual const std::type_info & type() const BOOST_NOEXCEPT = 0;
+ virtual const boost::typeind::type_info& type() const BOOST_NOEXCEPT = 0;
virtual placeholder * clone() const = 0;
@@ -189,9 +178,9 @@ namespace boost
#endif
public: // queries
- virtual const std::type_info & type() const BOOST_NOEXCEPT
+ virtual const boost::typeind::type_info& type() const BOOST_NOEXCEPT
{
- return typeid(ValueType);
+ return boost::typeind::type_id<ValueType>().type_info();
}
virtual placeholder * clone() const
@@ -232,7 +221,12 @@ namespace boost
lhs.swap(rhs);
}
- class BOOST_SYMBOL_VISIBLE bad_any_cast : public std::bad_cast
+ class BOOST_SYMBOL_VISIBLE bad_any_cast :
+#ifndef BOOST_NO_RTTI
+ public std::bad_cast
+#else
+ public std::exception
+#endif
{
public:
virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW
@@ -245,12 +239,7 @@ namespace boost
template<typename ValueType>
ValueType * any_cast(any * operand) BOOST_NOEXCEPT
{
- return operand &&
-#ifdef BOOST_AUX_ANY_TYPE_ID_NAME
- std::strcmp(operand->type().name(), typeid(ValueType).name()) == 0
-#else
- operand->type() == typeid(ValueType)
-#endif
+ return operand && operand->type() == boost::typeind::type_id<ValueType>()
? &static_cast<any::holder<ValueType> *>(operand->content)->held
: 0;
}
--
1.8.5.3