From 2fa0910547a92a6a1cf0cb7cb11e5b4f6242e3c8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 10 Mar 2002 06:41:40 +0000 Subject: [PATCH] initial checkin [SVN r13165] --- include/boost/python/detail/void_ptr.hpp | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 include/boost/python/detail/void_ptr.hpp diff --git a/include/boost/python/detail/void_ptr.hpp b/include/boost/python/detail/void_ptr.hpp new file mode 100644 index 00000000..676a5cac --- /dev/null +++ b/include/boost/python/detail/void_ptr.hpp @@ -0,0 +1,34 @@ +// Copyright David Abrahams 2002. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +#ifndef VOID_PTR_DWA200239_HPP +# define VOID_PTR_DWA200239_HPP + +namespace boost { namespace python { namespace detail { + +template +inline U& void_ptr_to_reference(void const volatile* p, U&(*)()) +{ + return *(U*)p; +} + +template +inline void write_void_ptr(void const volatile* storage, void* ptr, T*) +{ + *(T**)storage = (T*)ptr; +} + +// writes U(ptr) into the storage +template +inline void write_void_ptr_reference(void const volatile* storage, void* ptr, U&(*)()) +{ + // stripping CV qualification suppresses warnings on older EDGs + typedef typename remove_cv::type u_stripped; + write_void_ptr(storage, ptr, u_stripped(0)); +} + +}}} // namespace boost::python::detail + +#endif // VOID_PTR_DWA200239_HPP