tinfo2.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Methods for type_info for -*- C++ -*- Run Time Type Identification.
  2. // Copyright (C) 1994-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of GCC.
  5. //
  6. // GCC is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation; either version 3, or (at your option)
  9. // any later version.
  10. // GCC is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. // Under Section 7 of GPL version 3, you are granted additional
  15. // permissions described in the GCC Runtime Library Exception, version
  16. // 3.1, as published by the Free Software Foundation.
  17. // You should have received a copy of the GNU General Public License and
  18. // a copy of the GCC Runtime Library Exception along with this program;
  19. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  20. // <http://www.gnu.org/licenses/>.
  21. #include <cstddef>
  22. #include "tinfo.h"
  23. using std::type_info;
  24. #if !__GXX_TYPEINFO_EQUALITY_INLINE
  25. bool
  26. type_info::before (const type_info &arg) const _GLIBCXX_NOEXCEPT
  27. {
  28. #if __GXX_MERGED_TYPEINFO_NAMES
  29. return name () < arg.name ();
  30. #else
  31. /* The name() method will strip any leading '*' prefix. Therefore
  32. take care to look at __name rather than name() when looking for
  33. the "pointer" prefix. */
  34. return (__name[0] == '*') ? name () < arg.name ()
  35. : __builtin_strcmp (name (), arg.name ()) < 0;
  36. #endif
  37. }
  38. #endif