array.hpp 855 B

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