construct.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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
  10. # if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
  11. , T const volatile*
  12. # else
  13. , T const*
  14. # endif
  15. )
  16. {
  17. new (storage) T(x);
  18. }
  19. template <class T, class Arg>
  20. void construct_referent_impl(void* storage, Arg& x, T&(*)())
  21. {
  22. construct_pointee(storage, x, (T*)0);
  23. }
  24. template <class T, class Arg>
  25. void construct_referent(void* storage, Arg const& x, T(*tag)() = 0)
  26. {
  27. construct_referent_impl(storage, x, tag);
  28. }
  29. template <class T, class Arg>
  30. void construct_referent(void* storage, Arg& x, T(*tag)() = 0)
  31. {
  32. construct_referent_impl(storage, x, tag);
  33. }
  34. }}} // namespace boost::python::detail
  35. #endif // CONSTRUCT_REFERENCE_DWA2002716_HPP