cast_ptr.hpp 824 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright 2015 Andrey Semashev
  3. *
  4. * Distributed under the Boost Software License, Version 1.0.
  5. * See http://www.boost.org/LICENSE_1_0.txt
  6. */
  7. #ifndef BOOST_WINAPI_DETAIL_CAST_PTR_HPP_INCLUDED_
  8. #define BOOST_WINAPI_DETAIL_CAST_PTR_HPP_INCLUDED_
  9. #include <boost/winapi/config.hpp>
  10. #ifdef BOOST_HAS_PRAGMA_ONCE
  11. #pragma once
  12. #endif
  13. namespace boost {
  14. namespace winapi {
  15. namespace detail {
  16. //! This class is used to automatically cast pointers to the type used in the current Windows SDK function declarations
  17. class cast_ptr
  18. {
  19. private:
  20. const void* m_p;
  21. public:
  22. explicit BOOST_FORCEINLINE cast_ptr(const void* p) BOOST_NOEXCEPT : m_p(p) {}
  23. template< typename T >
  24. BOOST_FORCEINLINE operator T* () const BOOST_NOEXCEPT { return (T*)m_p; }
  25. };
  26. }
  27. }
  28. }
  29. #endif // BOOST_WINAPI_DETAIL_CAST_PTR_HPP_INCLUDED_