global_resource.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2015-2015. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_CONTAINER_PMR_GLOBAL_RESOURCE_HPP
  11. #define BOOST_CONTAINER_PMR_GLOBAL_RESOURCE_HPP
  12. #if defined (_MSC_VER)
  13. # pragma once
  14. #endif
  15. #include <boost/container/detail/config_begin.hpp>
  16. #include <boost/container/detail/workaround.hpp>
  17. #include <boost/container/detail/auto_link.hpp>
  18. #include <cstddef>
  19. namespace boost {
  20. namespace container {
  21. namespace pmr {
  22. /// @cond
  23. class memory_resource;
  24. /// @endcond
  25. //! <b>Returns</b>: A pointer to a static-duration object of a type derived from
  26. //! memory_resource that can serve as a resource for allocating memory using
  27. //! global `operator new` and global `operator delete`. The same value is returned every time this function
  28. //! is called. For return value p and memory resource r, p->is_equal(r) returns &r == p.
  29. BOOST_CONTAINER_DECL memory_resource* new_delete_resource() BOOST_NOEXCEPT;
  30. //! <b>Returns</b>: A pointer to a static-duration object of a type derived from
  31. //! memory_resource for which allocate() always throws bad_alloc and for which
  32. //! deallocate() has no effect. The same value is returned every time this function
  33. //! is called. For return value p and memory resource r, p->is_equal(r) returns &r == p.
  34. BOOST_CONTAINER_DECL memory_resource* null_memory_resource() BOOST_NOEXCEPT;
  35. //! <b>Effects</b>: If r is non-null, sets the value of the default memory resource
  36. //! pointer to r, otherwise sets the default memory resource pointer to new_delete_resource().
  37. //!
  38. //! <b>Postconditions</b>: get_default_resource() == r.
  39. //!
  40. //! <b>Returns</b>: The previous value of the default memory resource pointer.
  41. //!
  42. //! <b>Remarks</b>: Calling the set_default_resource and get_default_resource functions shall
  43. //! not incur a data race. A call to the set_default_resource function shall synchronize
  44. //! with subsequent calls to the set_default_resource and get_default_resource functions.
  45. BOOST_CONTAINER_DECL memory_resource* set_default_resource(memory_resource* r) BOOST_NOEXCEPT;
  46. //! <b>Returns</b>: The current value of the default
  47. //! memory resource pointer.
  48. BOOST_CONTAINER_DECL memory_resource* get_default_resource() BOOST_NOEXCEPT;
  49. } //namespace pmr {
  50. } //namespace container {
  51. } //namespace boost {
  52. #include <boost/container/detail/config_end.hpp>
  53. #endif //BOOST_CONTAINER_PMR_GLOBAL_RESOURCE_HPP