|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56168 - trunk/boost
From: Alexander.Nasonov_at_[hidden]
Date: 2009-09-13 09:16:28
Author: nasonov
Date: 2009-09-13 09:16:28 EDT (Sun, 13 Sep 2009)
New Revision: 56168
URL: http://svn.boost.org/trac/boost/changeset/56168
Log:
Fix #754 (boost::any - typeid comparison across shared boundaries).
Text files modified:
trunk/boost/any.hpp | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
Modified: trunk/boost/any.hpp
==============================================================================
--- trunk/boost/any.hpp (original)
+++ trunk/boost/any.hpp 2009-09-13 09:16:28 EDT (Sun, 13 Sep 2009)
@@ -19,6 +19,17 @@
#include <boost/throw_exception.hpp>
#include <boost/static_assert.hpp>
+// See boost/python/type_id.hpp
+// TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp
+# if (defined(__GNUC__) && __GNUC__ >= 3) \
+ || 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
@@ -164,9 +175,14 @@
template<typename ValueType>
ValueType * any_cast(any * operand)
{
- return operand && operand->type() == typeid(ValueType)
- ? &static_cast<any::holder<ValueType> *>(operand->content)->held
- : 0;
+ return operand &&
+#ifdef BOOST_AUX_ANY_TYPE_ID_NAME
+ std::strcmp(operand->type().name(), typeid(ValueType).name()) == 0
+#else
+ operand->type() == typeid(ValueType)
+#endif
+ ? &static_cast<any::holder<ValueType> *>(operand->content)->held
+ : 0;
}
template<typename ValueType>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk