construct.hpp 975 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef CONSTRUCT_REFERENCE_DWA2002716_HPP
  6. # define CONSTRUCT_REFERENCE_DWA2002716_HPP
  7. namespace boost { namespace python { namespace detail {
  8. template <class T, class Arg>
  9. void construct_pointee(void* storage, Arg& x, T const volatile*)
  10. {
  11. new (storage) T(x);
  12. }
  13. template <class T, class Arg>
  14. void construct_referent_impl(void* storage, Arg& x, T&(*)())
  15. {
  16. construct_pointee(storage, x, (T*)0);
  17. }
  18. template <class T, class Arg>
  19. void construct_referent(void* storage, Arg const& x, T(*tag)() = 0)
  20. {
  21. construct_referent_impl(storage, x, tag);
  22. }
  23. template <class T, class Arg>
  24. void construct_referent(void* storage, Arg& x, T(*tag)() = 0)
  25. {
  26. construct_referent_impl(storage, x, tag);
  27. }
  28. }}} // namespace boost::python::detail
  29. #endif // CONSTRUCT_REFERENCE_DWA2002716_HPP