ordered_base.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Profiling unordered containers implementation details -*- C++ -*-
  2. // Copyright (C) 2014-2018 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. //
  10. // This library 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 along
  18. // with this library; see the file COPYING3. If not see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file profile/ordered_base.h
  21. * This file is a GNU profile extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_PROFILE_ORDERED
  24. #define _GLIBCXX_PROFILE_ORDERED 1
  25. namespace std _GLIBCXX_VISIBILITY(default)
  26. {
  27. namespace __profile
  28. {
  29. template<typename _Cont>
  30. class _Ordered_profile
  31. {
  32. public:
  33. void
  34. _M_profile_iterate(int __rewind = 0) const
  35. { __profcxx_map2umap_iterate(this->_M_map2umap_info, __rewind); }
  36. protected:
  37. _Ordered_profile() _GLIBCXX_NOEXCEPT
  38. { _M_profile_construct(); }
  39. #if __cplusplus >= 201103L
  40. _Ordered_profile(const _Ordered_profile&) noexcept
  41. : _Ordered_profile() { }
  42. _Ordered_profile(_Ordered_profile&& __other) noexcept
  43. : _Ordered_profile()
  44. { _M_swap(__other); }
  45. _Ordered_profile&
  46. operator=(const _Ordered_profile&) noexcept
  47. {
  48. _M_profile_destruct();
  49. _M_profile_construct();
  50. }
  51. _Ordered_profile&
  52. operator=(_Ordered_profile&& __other) noexcept
  53. {
  54. _M_swap(__other);
  55. __other._M_profile_destruct();
  56. __other._M_profile_construct();
  57. }
  58. #endif
  59. ~_Ordered_profile()
  60. { _M_profile_destruct(); }
  61. void
  62. _M_profile_construct() _GLIBCXX_NOEXCEPT
  63. { _M_map2umap_info = __profcxx_map2umap_construct(); }
  64. void
  65. _M_profile_destruct() _GLIBCXX_NOEXCEPT
  66. {
  67. __profcxx_map2umap_destruct(_M_map2umap_info);
  68. _M_map2umap_info = 0;
  69. }
  70. void
  71. _M_swap(_Ordered_profile& __other)
  72. { std::swap(_M_map2umap_info, __other._M_map2umap_info); }
  73. __gnu_profile::__map2umap_info* _M_map2umap_info;
  74. private:
  75. _Cont&
  76. _M_conjure()
  77. { return *static_cast<_Cont*>(this); }
  78. };
  79. } // namespace __profile
  80. } // namespace std
  81. #endif