cast_ptr.hpp 909 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include <boost/winapi/detail/header.hpp>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. #pragma once
  13. #endif
  14. namespace boost {
  15. namespace winapi {
  16. namespace detail {
  17. //! This class is used to automatically cast pointers to the type used in the current Windows SDK function declarations
  18. class cast_ptr
  19. {
  20. private:
  21. const void* m_p;
  22. public:
  23. explicit BOOST_FORCEINLINE cast_ptr(const void* p) BOOST_NOEXCEPT : m_p(p) {}
  24. template< typename T >
  25. BOOST_FORCEINLINE operator T* () const BOOST_NOEXCEPT { return (T*)m_p; }
  26. };
  27. }
  28. }
  29. }
  30. #include <boost/winapi/detail/footer.hpp>
  31. #endif // BOOST_WINAPI_DETAIL_CAST_PTR_HPP_INCLUDED_