Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
// The code below strips away various qualifiers from a type

#ifndef GENERS_STRIPPEDTYPE_HH_
#define GENERS_STRIPPEDTYPE_HH_

#include <utility>

namespace gs {
  template <class T>
  struct StrippedType {
    typedef T type;
  };

  template <class T>
  struct StrippedType<T const> {
    typedef T type;
  };

  template <class T>
  struct StrippedType<T volatile> {
    typedef T type;
  };

  template <class T>
  struct StrippedType<T const volatile> {
    typedef T type;
  };

  template <class T, class U>
  struct StrippedType<std::pair<T, U>> {
    typedef std::pair<typename StrippedType<T>::type, typename StrippedType<U>::type> type;
  };

  template <class T, class U>
  struct StrippedType<const std::pair<T, U>> {
    typedef std::pair<typename StrippedType<T>::type, typename StrippedType<U>::type> type;
  };

  template <class T, class U>
  struct StrippedType<volatile std::pair<T, U>> {
    typedef std::pair<typename StrippedType<T>::type, typename StrippedType<U>::type> type;
  };

  template <class T, class U>
  struct StrippedType<const volatile std::pair<T, U>> {
    typedef std::pair<typename StrippedType<T>::type, typename StrippedType<U>::type> type;
  };
}  // namespace gs

#endif  // GENERS_STRIPPEDTYPE_HH_