array.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  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. namespace boost {
  15. namespace json {
  16. class value;
  17. namespace detail {
  18. class unchecked_array
  19. {
  20. value* data_;
  21. std::size_t size_;
  22. storage_ptr const& sp_;
  23. public:
  24. inline
  25. ~unchecked_array();
  26. unchecked_array(
  27. value* data,
  28. std::size_t size,
  29. storage_ptr const& sp) noexcept
  30. : data_(data)
  31. , size_(size)
  32. , sp_(sp)
  33. {
  34. }
  35. unchecked_array(
  36. unchecked_array&& other) noexcept
  37. : data_(other.data_)
  38. , size_(other.size_)
  39. , sp_(other.sp_)
  40. {
  41. other.data_ = nullptr;
  42. }
  43. storage_ptr const&
  44. storage() const noexcept
  45. {
  46. return sp_;
  47. }
  48. std::size_t
  49. size() const noexcept
  50. {
  51. return size_;
  52. }
  53. inline
  54. void
  55. relocate(value* dest) noexcept;
  56. };
  57. } // detail
  58. } // namespace json
  59. } // namespace boost
  60. // includes are at the bottom of <boost/json/value.hpp>
  61. #endif