indirect_reference.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef INDIRECT_REFERENCE_DWA200415_HPP
  2. # define INDIRECT_REFERENCE_DWA200415_HPP
  3. //
  4. // Copyright David Abrahams 2004. Use, modification and distribution is
  5. // subject to the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // typename indirect_reference<P>::type provides the type of *p.
  9. //
  10. // http://www.boost.org/libs/iterator/doc/pointee.html
  11. //
  12. # include <boost/detail/is_incrementable.hpp>
  13. # include <boost/iterator/iterator_traits.hpp>
  14. # include <boost/type_traits/remove_cv.hpp>
  15. # include <boost/mpl/eval_if.hpp>
  16. # include <boost/pointee.hpp>
  17. namespace boost {
  18. namespace detail
  19. {
  20. template <class P>
  21. struct smart_ptr_reference
  22. {
  23. typedef typename boost::pointee<P>::type& type;
  24. };
  25. }
  26. template <class P>
  27. struct indirect_reference
  28. : mpl::eval_if<
  29. detail::is_incrementable<P>
  30. , iterator_reference<P>
  31. , detail::smart_ptr_reference<P>
  32. >
  33. {
  34. };
  35. } // namespace boost
  36. #endif // INDIRECT_REFERENCE_DWA200415_HPP