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 explicit tvec1(
96 T const & s);
97
99 // Swizzle constructors
100
101
102
104 // Conversion scalar constructors
105
107 template <typename U>
108 GLM_FUNC_DECL explicit tvec1(U const & s);
109
111 // Conversion vector constructors
112
114 template <typename U, precision Q>
115 GLM_FUNC_DECL explicit tvec1(tvec1<U, Q> const & v);
117 template <typename U, precision Q>
118 GLM_FUNC_DECL explicit tvec1(tvec2<U, Q> const & v);
120 template <typename U, precision Q>
121 GLM_FUNC_DECL explicit tvec1(tvec3<U, Q> const & v);
123 template <typename U, precision Q>
124 GLM_FUNC_DECL explicit tvec1(tvec4<U, Q> const & v);
125
127 // Unary arithmetic operators
128
129 GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<T, P> const & v);
130 template <typename U>
131 GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<U, P> const & v);
132
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 template <typename U>
138 GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
139 template <typename U>
140 GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
141 template <typename U>
142 GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
143 template <typename U>
144 GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
145 template <typename U>
146 GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
147 template <typename U>
148 GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
149
151 // Increment and decrement operators
152
153 GLM_FUNC_DECL tvec1<T, P> & operator++();
154 GLM_FUNC_DECL tvec1<T, P> & operator--();
155 GLM_FUNC_DECL tvec1<T, P> operator++(int);
156 GLM_FUNC_DECL tvec1<T, P> operator--(int);
157
159 // Unary bit operators
160
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 template <typename U>
174 GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & s);
175 template <typename U>
176 GLM_FUNC_DECL tvec1<T, P> & operator^=(tvec1<U, P> const & v);
177 template <typename U>
178 GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & s);
179 template <typename U>
180 GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
181 template <typename U>
182 GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & s);
183 template <typename U>
184 GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);
185 };
186
187 GLM_DETAIL_IS_VECTOR(tvec1);
188
189 }//namespace detail
190 }//namespace glm
191
192 #ifndef GLM_EXTERNAL_TEMPLATE
193 #include "type_vec1.inl"
194 #endif//GLM_EXTERNAL_TEMPLATE
195
196 #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).