From a8349dfd94bcc456af5dc4b1bf4f175875d8ae54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Sun, 7 Jul 2013 12:39:05 +0200 Subject: [PATCH] Only use string comparison for type_id when necessary. See a83af3c69a3cd6da5ba21ea5062205fa664e59d2 "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. --- luabind/typeid.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/luabind/typeid.hpp b/luabind/typeid.hpp index db0c0c8d..647ec99d 100644 --- a/luabind/typeid.hpp +++ b/luabind/typeid.hpp @@ -19,6 +19,15 @@ # include # 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 @@ -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