forked from boostorg/core
Use string comparison on MinGW/Cygwin when comparing typeinfo across DLLs
This commit is contained in:
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <boost/current_function.hpp>
|
#include <boost/current_function.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -36,26 +37,43 @@ private:
|
|||||||
typeinfo& operator=( typeinfo const& );
|
typeinfo& operator=( typeinfo const& );
|
||||||
|
|
||||||
char const * name_;
|
char const * name_;
|
||||||
|
void (*lib_id_)();
|
||||||
|
|
||||||
public:
|
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
|
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;
|
return this == &rhs;
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( typeinfo const& rhs ) const
|
bool operator!=( typeinfo const& rhs ) const
|
||||||
{
|
{
|
||||||
return this != &rhs;
|
return !( *this == rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool before( typeinfo const& rhs ) const
|
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 );
|
return std::less< typeinfo const* >()( this, &rhs );
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* name() const
|
char const* name() const
|
||||||
@ -84,13 +102,11 @@ template<class T> struct BOOST_SYMBOL_VISIBLE core_typeid_
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__SUNPRO_CC)
|
BOOST_SYMBOL_VISIBLE inline void core_typeid_lib_id()
|
||||||
// see #4199, the Sun Studio compiler gets confused about static initialization
|
{
|
||||||
// constructor arguments. But an assignment works just fine.
|
}
|
||||||
template<class T> boost::core::typeinfo core_typeid_< T >::ti_ = core_typeid_< T >::name();
|
|
||||||
#else
|
template<class T> boost::core::typeinfo core_typeid_< T >::ti_( core_typeid_< T >::name(), &core_typeid_lib_id );
|
||||||
template<class T> boost::core::typeinfo core_typeid_< T >::ti_(core_typeid_< T >::name());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class T> struct core_typeid_< T & >: core_typeid_< T >
|
template<class T> struct core_typeid_< T & >: core_typeid_< T >
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user