global_resource.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <boost/container/container_fwd.hpp>
  19. #include <cstddef>
  20. namespace boost {
  21. namespace container {
  22. namespace pmr {
  23. //! <b>Returns</b>: A pointer to a static-duration object of a type derived from
  24. //! memory_resource that can serve as a resource for allocating memory using
  25. //! global `operator new` and global `operator delete`. The same value is returned every time this function
  26. //! is called. For return value p and memory resource r, p->is_equal(r) returns &r == p.
  27. BOOST_CONTAINER_DECL memory_resource* new_delete_resource() BOOST_NOEXCEPT;
  28. //! <b>Returns</b>: A pointer to a static-duration object of a type derived from
  29. //! memory_resource for which allocate() always throws bad_alloc and for which
  30. //! deallocate() has no effect. The same value is returned every time this function
  31. //! is called. For return value p and memory resource r, p->is_equal(r) returns &r == p.
  32. BOOST_CONTAINER_DECL memory_resource* null_memory_resource() BOOST_NOEXCEPT;
  33. //! <b>Effects</b>: If r is non-null, sets the value of the default memory resource
  34. //! pointer to r, otherwise sets the default memory resource pointer to new_delete_resource().
  35. //!
  36. //! <b>Postconditions</b>: get_default_resource() == r.
  37. //!
  38. //! <b>Returns</b>: The previous value of the default memory resource pointer.
  39. //!
  40. //! <b>Remarks</b>: Calling the set_default_resource and get_default_resource functions shall
  41. //! not incur a data race. A call to the set_default_resource function shall synchronize
  42. //! with subsequent calls to the set_default_resource and get_default_resource functions.
  43. BOOST_CONTAINER_DECL memory_resource* set_default_resource(memory_resource* r) BOOST_NOEXCEPT;
  44. //! <b>Returns</b>: The current value of the default
  45. //! memory resource pointer.
  46. BOOST_CONTAINER_DECL memory_resource* get_default_resource() BOOST_NOEXCEPT;
  47. } //namespace pmr {
  48. } //namespace container {
  49. } //namespace boost {
  50. #include <boost/container/detail/config_end.hpp>
  51. #endif //BOOST_CONTAINER_PMR_GLOBAL_RESOURCE_HPP