Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TCG_TRAITS_H
Toshihiro Shimizu 890ddd
#define TCG_TRAITS_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// STD includes
Toshihiro Shimizu 890ddd
#include <iterator></iterator>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//--------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace tcg {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//****************************************************************************
Toshihiro Shimizu 890ddd
//    TCG traits for generic type concepts
Toshihiro Shimizu 890ddd
//****************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct traits {
Shinya Kitaoka 120a6e
  typedef T *pointer_type;
Shinya Kitaoka 120a6e
  typedef T pointed_type;
Shinya Kitaoka 120a6e
  typedef T &reference_type;
Shinya Kitaoka 120a6e
  typedef T referenced_type;
Shinya Kitaoka 120a6e
  typedef T element_type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct traits<t *=""> {</t>
Shinya Kitaoka 120a6e
  typedef T **pointer_type;
Shinya Kitaoka 120a6e
  typedef T pointed_type;
Shinya Kitaoka 120a6e
  typedef T *&reference_type;
Shinya Kitaoka 120a6e
  typedef T *referenced_type;
Shinya Kitaoka 120a6e
  typedef T *element_type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct traits<t[]> : public traits<t *=""> {</t></t[]>
Shinya Kitaoka 120a6e
  typedef T element_type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Shinya Kitaoka 120a6e
struct traits<t &=""> : public traits<t> {};</t></t>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <>
Toshihiro Shimizu 890ddd
struct traits<void> {</void>
Shinya Kitaoka 120a6e
  typedef void *pointer_type;
Shinya Kitaoka 120a6e
  typedef void pointed_type;
Shinya Kitaoka 120a6e
  typedef void reference_type;
Shinya Kitaoka 120a6e
  typedef void referenced_type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//****************************************************************************
Toshihiro Shimizu 890ddd
//    Qualifier removers
Toshihiro Shimizu 890ddd
//****************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct remove_const {
Shinya Kitaoka 120a6e
  typedef T type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct remove_const<const t=""> {</const>
Shinya Kitaoka 120a6e
  typedef T type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct remove_ref {
Shinya Kitaoka 120a6e
  typedef T type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct remove_ref<t &=""> {</t>
Shinya Kitaoka 120a6e
  typedef T type;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct remove_cref {
Shinya Kitaoka 120a6e
  typedef typename remove_const<typename remove_ref<t="">::type>::type type;</typename>
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
//    TCG traits for output container readers
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename outputdata="typename" reader,="" reader::value_type="" typename=""></typename>
Toshihiro Shimizu 890ddd
struct container_reader_traits {
Shinya Kitaoka 120a6e
  typedef Reader reader_type;
Shinya Kitaoka 120a6e
  typedef OutputData value_type;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static void openContainer(reader_type &reader) { reader.openContainer(); }
Shinya Kitaoka 120a6e
  static void addElement(reader_type &reader, const value_type &data) {
Shinya Kitaoka 120a6e
    reader.addElement(data);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  static void closeContainer(reader_type &reader) { reader.closeContainer(); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
//    Notable Test  traits
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Toshihiro Shimizu 890ddd
struct is_floating_point {
Shinya Kitaoka 120a6e
  enum { value = false };
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <>
Toshihiro Shimizu 890ddd
struct is_floating_point<float> {</float>
Shinya Kitaoka 120a6e
  enum { value = true };
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <>
Toshihiro Shimizu 890ddd
struct is_floating_point<double> {</double>
Shinya Kitaoka 120a6e
  enum { value = true };
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <>
Toshihiro Shimizu 890ddd
struct is_floating_point<long double=""> {</long>
Shinya Kitaoka 120a6e
  enum { value = true };
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace tcg
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TCG_TRAITS_H