summaryrefslogtreecommitdiff
path: root/libcult/cult/types/fundamental.hxx
blob: 01116f12f9dc15641a27457eb8371bbcb4be6103 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// file      : cult/types/fundamental.hxx
// author    : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2005-2010 Boris Kolpackov
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef CULT_TYPES_FUNDAMENTAL_HXX
#define CULT_TYPES_FUNDAMENTAL_HXX

#include <cstddef> // std::size_t, std::ptrdiff_t

namespace Cult
{
  namespace Types
  {
    namespace Fundamental
    {
      // Fundamental types
      //
      typedef void Void;

      typedef bool Boolean;

      typedef char Char;
      typedef wchar_t WideChar;

      typedef short Short;
      typedef unsigned short UnsignedShort;

      typedef int Int;
      typedef unsigned int UnsignedInt;

      typedef long Long;
      typedef unsigned long UnsignedLong;

      //@@ what would be a good name for float, double and long double?
      //   ShortFloat, Float and LongFloat
      //   ShortReal, Real, LongReal

      typedef std::size_t Size;
      typedef std::ptrdiff_t PtrDifference;
      typedef Size Index;

      // Fixed-size types.
      //
      typedef signed char Int8;
      typedef unsigned char UnsignedInt8;

      typedef signed short Int16;
      typedef unsigned short UnsignedInt16;

      typedef signed int Int32;
      typedef unsigned int UnsignedInt32;

      typedef signed long long Int64;
      typedef unsigned long long UnsignedInt64;


      typedef float Float32;
      typedef double Float64;
      typedef long double Float128; // Only 96 on x86-32.
    }


    // Fundamental types
    //
    using Fundamental::Void;

    using Fundamental::Boolean;

    using Fundamental::Char;
    using Fundamental::WideChar;

    using Fundamental::Short;
    using Fundamental::UnsignedShort;

    using Fundamental::Int;
    using Fundamental::UnsignedInt;

    using Fundamental::Long;
    using Fundamental::UnsignedLong;

    using Fundamental::Size;
    using Fundamental::PtrDifference;
    using Fundamental::Index;


    // Fixed-size types.
    //
    using Fundamental::Int8;
    using Fundamental::UnsignedInt8;

    using Fundamental::Int16;
    using Fundamental::UnsignedInt16;

    using Fundamental::Int32;
    using Fundamental::UnsignedInt32;

    using Fundamental::Int64;
    using Fundamental::UnsignedInt64;


    using Fundamental::Float32;
    using Fundamental::Float64;
    using Fundamental::Float128; // Only 96 on x86-32.


    // Note: make sure you inherit publicly from this type for
    // it could be used for metaprogramming.
    //
    class NonCopyable
    {
      NonCopyable (NonCopyable const&);

      NonCopyable&
      operator= (NonCopyable const&);

    protected:
      NonCopyable ()
      {
      }
    };

    // class Clonable ?
    //

  }

  // Fundamental types
  //
  using Types::Void;

  using Types::Boolean;

  using Types::Char;
  using Types::WideChar;

  using Types::Short;
  using Types::UnsignedShort;

  using Types::Int;
  using Types::UnsignedInt;

  using Types::Long;
  using Types::UnsignedLong;

  using Types::Size;
  using Types::PtrDifference;
  using Types::Index;


  // Fixed-size types.
  //
  using Types::Int8;
  using Types::UnsignedInt8;

  using Types::Int16;
  using Types::UnsignedInt16;

  using Types::Int32;
  using Types::UnsignedInt32;

  using Types::Int64;
  using Types::UnsignedInt64;


  using Types::Float32;
  using Types::Float64;
  using Types::Float128; // Only 96 on x86-32.

  //
  //
  using Types::NonCopyable;
}

#endif  // CULT_TYPES_FUNDAMENTAL_HXX