1 //===- TypeTraits.h -------------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef MCLD_ADT_TYPETRAITS_H 10 #define MCLD_ADT_TYPETRAITS_H 11 12 #include <cstdlib> 13 14 namespace mcld { 15 16 template<typename DataType> 17 struct NonConstTraits; 18 19 template<typename DataType> 20 struct ConstTraits 21 { 22 typedef DataType value_type; 23 typedef const DataType* pointer; 24 typedef const DataType& reference; 25 typedef size_t size_type; 26 typedef ConstTraits<DataType> const_traits; 27 typedef NonConstTraits<DataType> nonconst_traits; 28 }; 29 30 template<typename DataType> 31 struct NonConstTraits 32 { 33 typedef DataType value_type; 34 typedef DataType* pointer; 35 typedef DataType& reference; 36 typedef size_t size_type; 37 typedef ConstTraits<DataType> const_traits; 38 typedef NonConstTraits<DataType> nonconst_traits; 39 }; 40 41 template<typename DataType> 42 struct ConstIteratorTraits 43 { 44 typedef DataType value_type; 45 typedef const DataType* pointer; 46 typedef const DataType& reference; 47 typedef size_t size_type; 48 typedef ConstTraits<DataType> const_traits; 49 typedef NonConstTraits<DataType> nonconst_traits; 50 typedef typename DataType::const_iterator iterator; 51 }; 52 53 template<typename DataType> 54 struct NonConstIteratorTraits 55 { 56 typedef DataType value_type; 57 typedef DataType* pointer; 58 typedef DataType& reference; 59 typedef size_t size_type; 60 typedef ConstTraits<DataType> const_traits; 61 typedef NonConstTraits<DataType> nonconst_traits; 62 typedef typename DataType::iterator iterator; 63 }; 64 65 } // namespace of mcld 66 67 #endif 68 69