array_traits.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2012 Glen Joseph Fernandes
  3. * glenfe at live dot com
  4. *
  5. * Distributed under the Boost Software License,
  6. * Version 1.0. (See accompanying file LICENSE_1_0.txt
  7. * or copy at http://boost.org/LICENSE_1_0.txt)
  8. */
  9. #ifndef BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP
  10. #define BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP
  11. #include <boost/type_traits/remove_cv.hpp>
  12. namespace boost {
  13. namespace detail {
  14. template<typename T>
  15. struct array_base {
  16. typedef typename boost::remove_cv<T>::type type;
  17. };
  18. template<typename T>
  19. struct array_base<T[]> {
  20. typedef typename array_base<T>::type type;
  21. };
  22. template<typename T, std::size_t N>
  23. struct array_base<T[N]> {
  24. typedef typename array_base<T>::type type;
  25. };
  26. template<typename T>
  27. struct array_total {
  28. enum {
  29. size = 1
  30. };
  31. };
  32. template<typename T, std::size_t N>
  33. struct array_total<T[N]> {
  34. enum {
  35. size = N * array_total<T>::size
  36. };
  37. };
  38. template<typename T>
  39. struct array_inner;
  40. template<typename T>
  41. struct array_inner<T[]> {
  42. typedef T type;
  43. };
  44. template<typename T, std::size_t N>
  45. struct array_inner<T[N]> {
  46. typedef T type;
  47. };
  48. }
  49. }
  50. #endif