From e98a546e8921b7245386940f3d0ee6da3b61296e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Oct 2018 20:29:10 +0300 Subject: [PATCH] Use string comparison on MinGW/Cygwin when comparing typeinfo across DLLs --- include/boost/core/typeinfo.hpp | 34 ++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/include/boost/core/typeinfo.hpp b/include/boost/core/typeinfo.hpp index f9c4415..a272596 100644 --- a/include/boost/core/typeinfo.hpp +++ b/include/boost/core/typeinfo.hpp @@ -21,6 +21,7 @@ #include #include +#include namespace boost { @@ -36,26 +37,43 @@ private: typeinfo& operator=( typeinfo const& ); char const * name_; + void (*lib_id_)(); public: - explicit typeinfo( char const * name ): name_( name ) + typeinfo( char const * name, void (*lib_id)() ): name_( name ), lib_id_( lib_id ) { } bool operator==( typeinfo const& rhs ) const { +#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION) + + return lib_id_ == rhs.lib_id_? this == &rhs: std::strcmp( name_, rhs.name_ ) == 0; + +#else + return this == &rhs; + +#endif } bool operator!=( typeinfo const& rhs ) const { - return this != &rhs; + return !( *this == rhs ); } bool before( typeinfo const& rhs ) const { +#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION) + + return lib_id_ == rhs.lib_id_? std::less< typeinfo const* >()( this, &rhs ): std::strcmp( name_, rhs.name_ ) < 0; + +#else + return std::less< typeinfo const* >()( this, &rhs ); + +#endif } char const* name() const @@ -84,13 +102,11 @@ template struct BOOST_SYMBOL_VISIBLE core_typeid_ } }; -#if defined(__SUNPRO_CC) -// see #4199, the Sun Studio compiler gets confused about static initialization -// constructor arguments. But an assignment works just fine. -template boost::core::typeinfo core_typeid_< T >::ti_ = core_typeid_< T >::name(); -#else -template boost::core::typeinfo core_typeid_< T >::ti_(core_typeid_< T >::name()); -#endif +BOOST_SYMBOL_VISIBLE inline void core_typeid_lib_id() +{ +} + +template boost::core::typeinfo core_typeid_< T >::ti_( core_typeid_< T >::name(), &core_typeid_lib_id ); template struct core_typeid_< T & >: core_typeid_< T > {