decay.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // (C) Copyright John Maddock & Thorsten Ottosen 2005.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. //
  6. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  7. #ifndef BOOST_TT_DECAY_HPP_INCLUDED
  8. #define BOOST_TT_DECAY_HPP_INCLUDED
  9. #include <boost/type_traits/is_array.hpp>
  10. #include <boost/type_traits/is_function.hpp>
  11. #include <boost/type_traits/remove_bounds.hpp>
  12. #include <boost/type_traits/add_pointer.hpp>
  13. #include <boost/type_traits/remove_reference.hpp>
  14. #include <boost/type_traits/remove_cv.hpp>
  15. namespace boost
  16. {
  17. namespace detail
  18. {
  19. template <class T, bool Array, bool Function> struct decay_imp { typedef typename remove_cv<T>::type type; };
  20. template <class T> struct decay_imp<T, true, false> { typedef typename remove_bounds<T>::type* type; };
  21. template <class T> struct decay_imp<T, false, true> { typedef T* type; };
  22. }
  23. template< class T >
  24. struct decay
  25. {
  26. private:
  27. typedef typename remove_reference<T>::type Ty;
  28. public:
  29. typedef typename boost::detail::decay_imp<Ty, boost::is_array<Ty>::value, boost::is_function<Ty>::value>::type type;
  30. };
  31. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  32. template <class T> using decay_t = typename decay<T>::type;
  33. #endif
  34. } // namespace boost
  35. #endif // BOOST_TT_DECAY_HPP_INCLUDED