GLM 0.9.5

- Main Page
- Related Pages
- Modules
- Namespaces
- Files

- File List

type_vec1.hpp
1
29 #ifndef glm_core_type_gentype1
30 #define glm_core_type_gentype1
31
32 #include "../fwd.hpp"
33 #include "type_vec.hpp"
34 #ifdef GLM_SWIZZLE
35 # if GLM_HAS_ANONYMOUS_UNION
36 # include "_swizzle.hpp"
37 # else
38 # include "_swizzle_func.hpp"
39 # endif
40 #endif //GLM_SWIZZLE
41 #if(GLM_HAS_INITIALIZER_LISTS)
42 # include <initializer_list>
43 #endif //GLM_HAS_INITIALIZER_LISTS
44 #include <cstddef>
45
46 namespace glm{
47 namespace detail
48 {
49 template <typename T, precision P>
50 struct tvec1
51 {
53 // Implementation detail
54
55 enum ctor{_null};
56
57 typedef tvec1<T, P> type;
58 typedef tvec1<bool, P> bool_type;
59 typedef T value_type;
60
62 // Helper
63
64 GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
65
67 // Data
68
69 union {T x, r, s;};
70
72 // Accesses
73
74 GLM_FUNC_DECL T & operator[](length_t i);
75 GLM_FUNC_DECL T const & operator[](length_t i) const;
76
78 // Implicit basic constructors
79
80 GLM_FUNC_DECL tvec1();
81 GLM_FUNC_DECL tvec1(tvec1<T, P> const & v);
82 template <precision Q>
83 GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
84
85 #if(GLM_HAS_INITIALIZER_LISTS)
86 template <typename U>
87 GLM_FUNC_DECL tvec1(std::initializer_list<U> const & v);
88 #endif//GLM_HAS_INITIALIZER_LISTS
89
91 // Explicit basic constructors
92
93 GLM_FUNC_DECL explicit tvec1(
94 ctor);
95 GLM_FUNC_DECL tvec1(
96 T const & s);
97
99 // Conversion vector constructors
100
102 template <typename U, precision Q>
103 GLM_FUNC_DECL explicit tvec1(tvec1<U, Q> const & v);
105 template <typename U, precision Q>
106 GLM_FUNC_DECL explicit tvec1(tvec2<U, Q> const & v);
108 template <typename U, precision Q>
109 GLM_FUNC_DECL explicit tvec1(tvec3<U, Q> const & v);
111 template <typename U, precision Q>
112 GLM_FUNC_DECL explicit tvec1(tvec4<U, Q> const & v);
113
115 // Unary arithmetic operators
116
117 GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<T, P> const & v);
118 template <typename U>
119 GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<U, P> const & v);
120
121 template <typename U>
122 GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & s);
123 template <typename U>
124 GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
125 template <typename U>
126 GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
127 template <typename U>
128 GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
129 template <typename U>
130 GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
131 template <typename U>
132 GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
133 template <typename U>
134 GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
135 template <typename U>
136 GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
137
139 // Increment and decrement operators
140
141 GLM_FUNC_DECL tvec1<T, P> & operator++();
142 GLM_FUNC_DECL tvec1<T, P> & operator--();
143 GLM_FUNC_DECL tvec1<T, P> operator++(int);
144 GLM_FUNC_DECL tvec1<T, P> operator--(int);
145
147 // Unary bit operators
148
149 template <typename U>
150 GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & s);
151 template <typename U>
152 GLM_FUNC_DECL tvec1<T, P> & operator%=(tvec1<U, P> const & v);
153 template <typename U>
154 GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & s);
155 template <typename U>
156 GLM_FUNC_DECL tvec1<T, P> & operator&=(tvec1<U, P> const & v);
157 template <typename U>
158 GLM_FUNC_DECL tvec1<T, P> & operator|=(U const & s);
159 template <typename U>
160 GLM_FUNC_DECL tvec1<T, P> & operator|=(tvec1<U, P> const & v);
161 template <typename U>
162 GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & s);
163 template <typename U>
164 GLM_FUNC_DECL tvec1<T, P> & operator^=(tvec1<U, P> const & v);
165 template <typename U>
166 GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & s);
167 template <typename U>
168 GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
169 template <typename U>
170 GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & s);
171 template <typename U>
172 GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);
173 };
174
175
176 template <typename T, precision P>
177 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T const & s);
178
179 template <typename T, precision P>
180 GLM_FUNC_DECL tvec1<T, P> operator+(T const & s, tvec1<T, P> const & v);
181
182 template <typename T, precision P>
183 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
184
185 template <typename T, precision P>
186 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T const & s);
187
188 template <typename T, precision P>
189 GLM_FUNC_DECL tvec1<T, P> operator-(T const & s, tvec1<T, P> const & v);
190
191 template <typename T, precision P>
192 GLM_FUNC_DECL tvec1<T, P> operator- (tvec1<T, P> const & v1, tvec1<T, P> const & v2);
193
194 template <typename T, precision P>
195 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T const & s);
196
197 template <typename T, precision P>
198 GLM_FUNC_DECL tvec1<T, P> operator*(T const & s, tvec1<T, P> const & v);
199
200 template <typename T, precision P>
201 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
202
203 template <typename T, precision P>
204 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T const & s);
205
206 template <typename T, precision P>
207 GLM_FUNC_DECL tvec1<T, P> operator/(T const & s, tvec1<T, P> const & v);
208
209 template <typename T, precision P>
210 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
211
212 template <typename T, precision P>
213 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
214
215 template <typename T, precision P>
216 GLM_FUNC_DECL bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
217
218 template <typename T, precision P>
219 GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
220
221 template <typename T, precision P>
222 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T const & s);
223
224 template <typename T, precision P>
225 GLM_FUNC_DECL tvec1<T, P> operator%(T const & s, tvec1<T, P> const & v);
226
227 template <typename T, precision P>
228 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
229
230 template <typename T, precision P>
231 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T const & s);
232
233 template <typename T, precision P>
234 GLM_FUNC_DECL tvec1<T, P> operator&(T const & s, tvec1<T, P> const & v);
235
236 template <typename T, precision P>
237 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
238
239 template <typename T, precision P>
240 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T const & s);
241
242 template <typename T, precision P>
243 GLM_FUNC_DECL tvec1<T, P> operator|(T const & s, tvec1<T, P> const & v);
244
245 template <typename T, precision P>
246 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
247
248 template <typename T, precision P>
249 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T const & s);
250
251 template <typename T, precision P>
252 GLM_FUNC_DECL tvec1<T, P> operator^(T const & s, tvec1<T, P> const & v);
253
254 template <typename T, precision P>
255 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
256
257 template <typename T, precision P>
258 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & s);
259
260 template <typename T, precision P>
261 GLM_FUNC_DECL tvec1<T, P> operator<<(T const & s, tvec1<T, P> const & v);
262
263 template <typename T, precision P>
264 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
265
266 template <typename T, precision P>
267 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & s);
268
269 template <typename T, precision P>
270 GLM_FUNC_DECL tvec1<T, P> operator>>(T const & s, tvec1<T, P> const & v);
271
272 template <typename T, precision P>
273 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
274
275 template <typename T, precision P>
276 GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
277
278 }//namespace detail
279 }//namespace glm
280
281 #ifndef GLM_EXTERNAL_TEMPLATE
282 #include "type_vec1.inl"
283 #endif//GLM_EXTERNAL_TEMPLATE
284
285 #endif//glm_core_type_gentype1
glm::length
GLM_FUNC_DECL genType::value_type length(genType const &x)
Returns the length of x, i.e., sqrt(x * x).