• 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_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   typedef DataType value_type;
22   typedef const DataType* pointer;
23   typedef const DataType& reference;
24   typedef size_t size_type;
25   typedef ConstTraits<DataType> const_traits;
26   typedef NonConstTraits<DataType> nonconst_traits;
27 };
28 
29 template <typename DataType>
30 struct NonConstTraits {
31   typedef DataType value_type;
32   typedef DataType* pointer;
33   typedef DataType& reference;
34   typedef size_t size_type;
35   typedef ConstTraits<DataType> const_traits;
36   typedef NonConstTraits<DataType> nonconst_traits;
37 };
38 
39 template <typename DataType>
40 struct ConstIteratorTraits {
41   typedef DataType value_type;
42   typedef const DataType* pointer;
43   typedef const DataType& reference;
44   typedef size_t size_type;
45   typedef ConstTraits<DataType> const_traits;
46   typedef NonConstTraits<DataType> nonconst_traits;
47   typedef typename DataType::const_iterator iterator;
48 };
49 
50 template <typename DataType>
51 struct NonConstIteratorTraits {
52   typedef DataType value_type;
53   typedef DataType* pointer;
54   typedef DataType& reference;
55   typedef size_t size_type;
56   typedef ConstTraits<DataType> const_traits;
57   typedef NonConstTraits<DataType> nonconst_traits;
58   typedef typename DataType::iterator iterator;
59 };
60 
61 }  // namespace mcld
62 
63 #endif  // MCLD_ADT_TYPETRAITS_H_
64