• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TYPE_TRAITS_H
10 #define MCLD_TYPE_TRAITS_H
11 #ifdef ENABLE_UNITTEST
12 #include <gtest.h>
13 #endif
14 
15 #include <cstdlib>
16 
17 namespace mcld
18 {
19 template<typename DataType>
20 struct NonConstTraits;
21 
22 template<typename DataType>
23 struct ConstTraits
24 {
25   typedef DataType                 value_type;
26   typedef const DataType*          pointer;
27   typedef const DataType&          reference;
28   typedef size_t                   size_type;
29   typedef ConstTraits<DataType>    const_traits;
30   typedef NonConstTraits<DataType> nonconst_traits;
31 };
32 
33 template<typename DataType>
34 struct NonConstTraits
35 {
36   typedef DataType                 value_type;
37   typedef DataType*                pointer;
38   typedef DataType&                reference;
39   typedef size_t                   size_type;
40   typedef ConstTraits<DataType>    const_traits;
41   typedef NonConstTraits<DataType> nonconst_traits;
42 };
43 
44 template<typename DataType>
45 struct ConstIteratorTraits
46 {
47   typedef DataType                          value_type;
48   typedef const DataType*                   pointer;
49   typedef const DataType&                   reference;
50   typedef size_t                            size_type;
51   typedef ConstTraits<DataType>             const_traits;
52   typedef NonConstTraits<DataType>          nonconst_traits;
53   typedef typename DataType::const_iterator iterator;
54 };
55 
56 template<typename DataType>
57 struct NonConstIteratorTraits
58 {
59   typedef DataType                    value_type;
60   typedef DataType*                   pointer;
61   typedef DataType&                   reference;
62   typedef size_t                      size_type;
63   typedef ConstTraits<DataType>       const_traits;
64   typedef NonConstTraits<DataType>    nonconst_traits;
65   typedef typename DataType::iterator iterator;
66 };
67 
68 } // namespace of mcld
69 
70 #endif
71 
72