3rdparty/glm/doc/api/a00128_source.html
| | 0.9.8 |
type_vec1.hpp
Go to the documentation of this file.
1
4 #pragma once
5
6 #include "../fwd.hpp"
7 #include "type_vec.hpp"
8 #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
9 # if GLM_HAS_UNRESTRICTED_UNIONS
10 # include "_swizzle.hpp"
11 # else
12 # include "_swizzle_func.hpp"
13 # endif
14 #endif //GLM_SWIZZLE
15 #include <cstddef>
16
17 namespace glm
18 {
19template <typename T, precision P = defaultp>
20struct tvec1
21 {
22// -- Implementation detail --
23
24typedef T value_type;
25typedef tvec1<T, P> type;
26typedef tvec1<bool, P> bool_type;
27
28// -- Data --
29
30 # if GLM_HAS_ALIGNED_TYPE
31 # if GLM_COMPILER & GLM_COMPILER_GCC
32 # pragma GCC diagnostic push
33 # pragma GCC diagnostic ignored "-pedantic"
34 # endif
35 # if GLM_COMPILER & GLM_COMPILER_CLANG
36 # pragma clang diagnostic push
37 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
38 # pragma clang diagnostic ignored "-Wnested-anon-types"
39 # endif
40
41union
42 {
43 T x;
44 T r;
45 T s;
46 /*
47 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
48 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, x)
49 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, r)
50 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, s)
51 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, x)
52 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, r)
53 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, s)
54 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, x)
55 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, r)
56 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, s)
57 # endif//GLM_SWIZZLE*/
58 };
59
60 # if GLM_COMPILER & GLM_COMPILER_CLANG
61 # pragma clang diagnostic pop
62 # endif
63 # if GLM_COMPILER & GLM_COMPILER_GCC
64 # pragma GCC diagnostic pop
65 # endif
66 # else
67union {T x, r, s;};
68 /*
69 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
70 GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, P, tvec2, tvec2, tvec3, tvec4)
71 # endif//GLM_SWIZZLE*/
72 # endif
73
74// -- Component accesses --
75
77typedef length_t length_type;
78 GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
79
80 GLM_FUNC_DECL T & operator[](length_type i);
81 GLM_FUNC_DECL T const & operator[](length_type i) const;
82
83// -- Implicit basic constructors --
84
85 GLM_FUNC_DECL GLM_CONSTEXPR tvec1() GLM_DEFAULT_CTOR;
86 GLM_FUNC_DECL GLM_CONSTEXPR tvec1(tvec1<T, P> const & v) GLM_DEFAULT;
87 template <precision Q>
88 GLM_FUNC_DECL GLM_CONSTEXPR tvec1(tvec1<T, Q> const & v);
89
90// -- Explicit basic constructors --
91
92 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit tvec1(ctor);
93 GLM_FUNC_DECL GLM_CONSTEXPR explicit tvec1(T scalar);
94
95// -- Conversion vector constructors --
96
98 template <typename U, precision Q>
99 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tvec1(tvec2<U, Q> const & v);
101 template <typename U, precision Q>
102 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tvec1(tvec3<U, Q> const & v);
104 template <typename U, precision Q>
105 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tvec1(tvec4<U, Q> const & v);
106
108 template <typename U, precision Q>
109 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tvec1(tvec1<U, Q> const & v);
110
111// -- Swizzle constructors --
112 /*
113 # if(GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED))
114 template <int E0>
115 GLM_FUNC_DECL tvec1(detail::_swizzle<1, T, P, tvec1, E0, -1,-2,-3> const & that)
116 {
117 *this = that();
118 }
119 # endif//(GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED))
120 */
121// -- Unary arithmetic operators --
122
123 GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<T, P> const & v) GLM_DEFAULT;
124
125 template <typename U>
126 GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<U, P> const & v);
127 template <typename U>
128 GLM_FUNC_DECL tvec1<T, P> & operator+=(U scalar);
129 template <typename U>
130 GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
131 template <typename U>
132 GLM_FUNC_DECL tvec1<T, P> & operator-=(U scalar);
133 template <typename U>
134 GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
135 template <typename U>
136 GLM_FUNC_DECL tvec1<T, P> & operator*=(U scalar);
137 template <typename U>
138 GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
139 template <typename U>
140 GLM_FUNC_DECL tvec1<T, P> & operator/=(U scalar);
141 template <typename U>
142 GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
143
144// -- Increment and decrement operators --
145
146 GLM_FUNC_DECL tvec1<T, P> & operator++();
147 GLM_FUNC_DECL tvec1<T, P> & operator--();
148 GLM_FUNC_DECL tvec1<T, P> operator++(int);
149 GLM_FUNC_DECL tvec1<T, P> operator--(int);
150
151// -- Unary bit operators --
152
153 template <typename U>
154 GLM_FUNC_DECL tvec1<T, P> & operator%=(U scalar);
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 scalar);
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 scalar);
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 scalar);
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 scalar);
171 template <typename U>
172 GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
173 template <typename U>
174 GLM_FUNC_DECL tvec1<T, P> & operator>>=(U scalar);
175 template <typename U>
176 GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);
177 };
178
179// -- Unary operators --
180
181 template <typename T, precision P>
182 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v);
183
184 template <typename T, precision P>
185 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
186
187// -- Binary operators --
188
189 template <typename T, precision P>
190 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T scalar);
191
192 template <typename T, precision P>
193 GLM_FUNC_DECL tvec1<T, P> operator+(T scalar, tvec1<T, P> const & v);
194
195 template <typename T, precision P>
196 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
197
198 template <typename T, precision P>
199 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T scalar);
200
201 template <typename T, precision P>
202 GLM_FUNC_DECL tvec1<T, P> operator-(T scalar, tvec1<T, P> const & v);
203
204 template <typename T, precision P>
205 GLM_FUNC_DECL tvec1<T, P> operator- (tvec1<T, P> const & v1, tvec1<T, P> const & v2);
206
207 template <typename T, precision P>
208 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T scalar);
209
210 template <typename T, precision P>
211 GLM_FUNC_DECL tvec1<T, P> operator*(T scalar, tvec1<T, P> const & v);
212
213 template <typename T, precision P>
214 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
215
216 template <typename T, precision P>
217 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T scalar);
218
219 template <typename T, precision P>
220 GLM_FUNC_DECL tvec1<T, P> operator/(T scalar, tvec1<T, P> const & v);
221
222 template <typename T, precision P>
223 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
224
225 template <typename T, precision P>
226 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T scalar);
227
228 template <typename T, precision P>
229 GLM_FUNC_DECL tvec1<T, P> operator%(T scalar, tvec1<T, P> const & v);
230
231 template <typename T, precision P>
232 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
233
234 template <typename T, precision P>
235 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T scalar);
236
237 template <typename T, precision P>
238 GLM_FUNC_DECL tvec1<T, P> operator&(T scalar, tvec1<T, P> const & v);
239
240 template <typename T, precision P>
241 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
242
243 template <typename T, precision P>
244 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T scalar);
245
246 template <typename T, precision P>
247 GLM_FUNC_DECL tvec1<T, P> operator|(T scalar, tvec1<T, P> const & v);
248
249 template <typename T, precision P>
250 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
251
252 template <typename T, precision P>
253 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T scalar);
254
255 template <typename T, precision P>
256 GLM_FUNC_DECL tvec1<T, P> operator^(T scalar, tvec1<T, P> const & v);
257
258 template <typename T, precision P>
259 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
260
261 template <typename T, precision P>
262 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T scalar);
263
264 template <typename T, precision P>
265 GLM_FUNC_DECL tvec1<T, P> operator<<(T scalar, tvec1<T, P> const & v);
266
267 template <typename T, precision P>
268 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
269
270 template <typename T, precision P>
271 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T scalar);
272
273 template <typename T, precision P>
274 GLM_FUNC_DECL tvec1<T, P> operator>>(T scalar, tvec1<T, P> const & v);
275
276 template <typename T, precision P>
277 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
278
279 template <typename T, precision P>
280 GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
281
282// -- Boolean operators --
283
284 template <typename T, precision P>
285 GLM_FUNC_DECL bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
286
287 template <typename T, precision P>
288 GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
289
290 template <precision P>
291 GLM_FUNC_DECL tvec1<bool, P> operator&&(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2);
292
293 template <precision P>
294 GLM_FUNC_DECL tvec1<bool, P> operator||(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2);
295 }//namespace glm
296
297 #ifndef GLM_EXTERNAL_TEMPLATE
298 #include "type_vec1.inl"
299 #endif//GLM_EXTERNAL_TEMPLATE
GLM Core
Definition: _noise.hpp:11
GLM Core
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
GLM Core
Generated by 1.8.10