value_ref.hpp 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_IMPL_VALUE_REF_HPP
  10. #define BOOST_JSON_IMPL_VALUE_REF_HPP
  11. namespace boost {
  12. namespace json {
  13. template<class T>
  14. value
  15. value_ref::
  16. from_builtin(
  17. void const* p,
  18. storage_ptr sp) noexcept
  19. {
  20. return value(
  21. *reinterpret_cast<
  22. T const*>(p),
  23. std::move(sp));
  24. }
  25. template<class T>
  26. value
  27. value_ref::
  28. from_const(
  29. void const* p,
  30. storage_ptr sp)
  31. {
  32. return value(
  33. *reinterpret_cast<
  34. T const*>(p),
  35. std::move(sp));
  36. }
  37. template<class T>
  38. value
  39. value_ref::
  40. from_rvalue(
  41. void* p,
  42. storage_ptr sp)
  43. {
  44. return value(
  45. std::move(
  46. *reinterpret_cast<T*>(p)),
  47. std::move(sp));
  48. }
  49. } // namespace json
  50. } // namespace boost
  51. #endif