get_pointer.hpp 921 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright Peter Dimov and 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 GET_POINTER_DWA20021219_HPP
  6. # define GET_POINTER_DWA20021219_HPP
  7. // In order to avoid circular dependencies with Boost.TR1
  8. // we make sure that our include of <memory> doesn't try to
  9. // pull in the TR1 headers: that's why we use this header
  10. // rather than including <memory> directly:
  11. # include <boost/config/no_tr1/memory.hpp> // std::auto_ptr
  12. namespace boost {
  13. // get_pointer(p) extracts a ->* capable pointer from p
  14. template<class T> T * get_pointer(T * p)
  15. {
  16. return p;
  17. }
  18. // get_pointer(shared_ptr<T> const & p) has been moved to shared_ptr.hpp
  19. template<class T> T * get_pointer(std::auto_ptr<T> const& p)
  20. {
  21. return p.get();
  22. }
  23. } // namespace boost
  24. #endif // GET_POINTER_DWA20021219_HPP