uncast.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2006-2014
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/intrusive for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_INTRUSIVE_DETAIL_UNCAST_HPP
  13. #define BOOST_INTRUSIVE_DETAIL_UNCAST_HPP
  14. #ifndef BOOST_CONFIG_HPP
  15. # include <boost/config.hpp>
  16. #endif
  17. #if defined(BOOST_HAS_PRAGMA_ONCE)
  18. # pragma once
  19. #endif
  20. #include <boost/intrusive/detail/config_begin.hpp>
  21. #include <boost/intrusive/pointer_traits.hpp>
  22. #include <boost/intrusive/detail/mpl.hpp>
  23. namespace boost {
  24. namespace intrusive {
  25. namespace detail {
  26. template<class ConstNodePtr>
  27. struct uncast_types
  28. {
  29. typedef typename pointer_traits<ConstNodePtr>::element_type element_type;
  30. typedef typename remove_const<element_type>::type non_const_type;
  31. typedef typename pointer_traits<ConstNodePtr>::
  32. template rebind_pointer<non_const_type>::type non_const_pointer;
  33. typedef pointer_traits<non_const_pointer> non_const_traits;
  34. };
  35. template<class ConstNodePtr>
  36. static typename uncast_types<ConstNodePtr>::non_const_pointer
  37. uncast(const ConstNodePtr & ptr)
  38. {
  39. return uncast_types<ConstNodePtr>::non_const_traits::const_cast_from(ptr);
  40. }
  41. } //namespace detail {
  42. } //namespace intrusive
  43. } //namespace boost
  44. #include <boost/intrusive/detail/config_end.hpp>
  45. #endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP