Skip to content

Commit

Permalink
Only use string comparison for type_id when necessary.
Browse files Browse the repository at this point in the history
See a83af3c "Fix use of Luabind classes across
shared library boundary." The commit notes already contain links to
descriptions and even code snippets, describing when this is necessary. This
patch basically copies the #if from boost.
  • Loading branch information
Oberon00 committed Jul 7, 2013
1 parent c882761 commit a8349df
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions luabind/typeid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
# include <cxxabi.h>
# endif // __GNUC__

// See https://svn.boost.org/trac/boost/ticket/754
# 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 LUABIND_SAFE_TYPEID
# endif

namespace luabind {

# ifdef BOOST_MSVC
Expand All @@ -43,17 +52,29 @@ class type_id

bool operator!=(type_id const& other) const
{
# ifdef LUABIND_SAFE_TYPEID
return std::strcmp(m_id->name(), other.m_id->name()) != 0;
# else
return *m_id != *other.m_id;
# endif
}

bool operator==(type_id const& other) const
{
# ifdef LUABIND_SAFE_TYPEID
return std::strcmp(m_id->name(), other.m_id->name()) == 0;
# else
return *m_id == *other.m_id;
# endif
}

bool operator<(type_id const& other) const
{
# ifdef LUABIND_SAFE_TYPEID
return std::strcmp(m_id->name(), other.m_id->name()) < 0;
# else
return m_id->before(*other.m_id);
# endif
}

std::string name() const
Expand Down

0 comments on commit a8349df

Please sign in to comment.