array.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_DETAIL_ARRAY_HPP
  10. #define BOOST_JSON_DETAIL_ARRAY_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/json/storage_ptr.hpp>
  13. #include <cstddef>
  14. BOOST_JSON_NS_BEGIN
  15. class value;
  16. namespace detail {
  17. class unchecked_array
  18. {
  19. value* data_;
  20. std::size_t size_;
  21. storage_ptr const& sp_;
  22. public:
  23. inline
  24. ~unchecked_array();
  25. unchecked_array(
  26. value* data,
  27. std::size_t size,
  28. storage_ptr const& sp) noexcept
  29. : data_(data)
  30. , size_(size)
  31. , sp_(sp)
  32. {
  33. }
  34. unchecked_array(
  35. unchecked_array&& other) noexcept
  36. : data_(other.data_)
  37. , size_(other.size_)
  38. , sp_(other.sp_)
  39. {
  40. other.data_ = nullptr;
  41. }
  42. storage_ptr const&
  43. storage() const noexcept
  44. {
  45. return sp_;
  46. }
  47. std::size_t
  48. size() const noexcept
  49. {
  50. return size_;
  51. }
  52. inline
  53. void
  54. relocate(value* dest) noexcept;
  55. };
  56. } // detail
  57. BOOST_JSON_NS_END
  58. // includes are at the bottom of <boost/json/value.hpp>
  59. #endif