array.hpp 893 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_IMPL_ARRAY_HPP
  10. #define BOOST_JSON_DETAIL_IMPL_ARRAY_HPP
  11. namespace boost {
  12. namespace json {
  13. namespace detail {
  14. unchecked_array::
  15. ~unchecked_array()
  16. {
  17. if(! data_ ||
  18. sp_.is_not_shared_and_deallocate_is_trivial())
  19. return;
  20. for(unsigned long i = 0;
  21. i < size_; ++i)
  22. data_[i].~value();
  23. }
  24. void
  25. unchecked_array::
  26. relocate(value* dest) noexcept
  27. {
  28. if(size_ > 0)
  29. std::memcpy(
  30. static_cast<void*>(dest),
  31. data_, size_ * sizeof(value));
  32. data_ = nullptr;
  33. }
  34. } // detail
  35. } // namespace json
  36. } // namespace boost
  37. #endif