<commit_before>// Copyright <NAME> 2008. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef LUABIND_TYPEID_081227_HPP
# define LUABIND_TYPEID_081227_HPP

# include <luabind/detail/primitives.hpp>

# include <boost/operators.hpp>

# include <cstdlib>
# include <cstring>
# include <typeinfo>

// boost/units/detail/utility.hpp
# if defined(__GLIBCXX__) || defined(__GLIBCPP__)
#  define LUABIND_USE_DEMANGLING
#  include <cxxabi.h>
# endif // __GNUC__

namespace luabind {

# ifdef BOOST_MSVC
#  pragma warning(push)
// std::type_info::before() returns int, rather than bool.
// At least on MSVC7.1, this is true for the comparison
// operators as well.
#  pragma warning(disable:4800)
# endif

class type_id
  : boost::less_than_comparable<type_id>
{
public:
    type_id()
      : m_id(&typeid(detail::null_type))
    {}

    type_id(std::type_info const& id)
      : m_id(&id)
    {}

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

    bool operator==(type_id const& other) const
    {
        return std::strcmp(m_id->name(), other.m_id->name()) == 0;
    }

    bool operator<(type_id const& other) const
    {
        return std::strcmp(m_id->name(), other.m_id->name()) < 0;
    }
<commit_msg>Only use string comparison for type_id when necessary.<commit_after>// Copyright <NAME> 2008. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef LUABIND_TYPEID_081227_HPP
# define LUABIND_TYPEID_081227_HPP

# include <luabind/detail/primitives.hpp>

# include <boost/operators.hpp>

# include <cstdlib>
# include <cstring>
# include <typeinfo>

// boost/units/detail/utility.hpp
# if defined(__GLIBCXX__) || defined(__GLIBCPP__)
#  define LUABIND_USE_DEMANGLING
#  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
#  pragma warning(push)
// std::type_info::before() returns int, rather than bool.
// At least on MSVC7.1, this is true for the comparison
// operators as well.
#  pragma warning(disable:4800)
# endif

class type_id
  : boost::less_than_comparable<type_id>
{
public:
    type_id()
      : m_id(&typeid(detail::null_type))
    {}

    type_id(std::type_info const& id)
      : m_id(&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
    }

{'fraction_non_alphanumeric': 0.14005197805371067, 'fraction_numerical': 0.019058619693907018, 'mean_word_length': 3.582010582010582, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 33, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4848767', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1245, 'n_words': 272}