179 { |
179 { |
180 // general case: n arguments |
180 // general case: n arguments |
181 return arg ? arg : coalesce(rest...); |
181 return arg ? arg : coalesce(rest...); |
182 } |
182 } |
183 |
183 |
|
184 /** |
|
185 * @brief Finds an element in a map and possibly returns a reference to it if find |
|
186 * @param map |
|
187 * @param key |
|
188 * @returns the value or nullptr if not found |
|
189 */ |
|
190 template<typename T, typename R, typename K> |
|
191 const R* findInMap(const std::map<T, R>& map, K&& key) |
|
192 { |
|
193 auto pair = map.find(key); |
|
194 if (pair != map.end()) |
|
195 { |
|
196 return &pair->second; |
|
197 } |
|
198 else |
|
199 { |
|
200 return nullptr; |
|
201 } |
|
202 } |
|
203 |
|
204 /** |
|
205 * @brief Finds an element in a map and possibly returns a reference to it if find |
|
206 * @param map |
|
207 * @param key |
|
208 * @returns the value or no value if not found |
|
209 */ |
|
210 template<typename T, typename R, typename K> |
|
211 R* findInMap(std::map<T, R>& map, K&& key) |
|
212 { |
|
213 auto pair = map.find(key); |
|
214 if (pair != map.end()) |
|
215 { |
|
216 return &pair->second; |
|
217 } |
|
218 else |
|
219 { |
|
220 return nullptr; |
|
221 } |
|
222 } |
|
223 |
184 template<typename T = double> |
224 template<typename T = double> |
185 constexpr std::enable_if_t<std::is_floating_point_v<T>, T> PI = static_cast<T>(M_PIl); |
225 constexpr std::enable_if_t<std::is_floating_point_v<T>, T> PI = static_cast<T>(M_PIl); |
186 |
226 |
187 Q_DECLARE_METATYPE(glm::vec3) |
227 Q_DECLARE_METATYPE(glm::vec3) |
188 Q_DECLARE_METATYPE(glm::mat4) |
228 Q_DECLARE_METATYPE(glm::mat4) |