221 |
221 |
222 // |
222 // |
223 // Get the amount of elements in something. |
223 // Get the amount of elements in something. |
224 // |
224 // |
225 template<typename T, size_t N> |
225 template<typename T, size_t N> |
226 int length(T(&)[N]) |
226 int countof(T(&)[N]) |
227 { |
227 { |
228 return N; |
228 return N; |
229 } |
229 } |
230 |
230 |
231 static inline int length(const QString& string) |
231 static inline int countof(const QString& string) |
232 { |
232 { |
233 return string.length(); |
233 return string.length(); |
234 } |
234 } |
235 |
235 |
236 template<typename T> |
236 template<typename T> |
237 int length(const QVector<T>& vector) |
237 int countof(const QVector<T>& vector) |
238 { |
238 { |
239 return vector.size(); |
239 return vector.size(); |
240 } |
240 } |
241 |
241 |
242 template<typename T> |
242 template<typename T> |
243 int length(const QList<T>& vector) |
243 int countof(const QList<T>& vector) |
244 { |
244 { |
245 return vector.size(); |
245 return vector.size(); |
246 } |
246 } |
247 |
247 |
248 template<typename T> |
248 template<typename T> |
249 int length(const std::initializer_list<T>& vector) |
249 int countof(const std::initializer_list<T>& vector) |
250 { |
250 { |
251 return vector.size(); |
251 return vector.size(); |
252 } |
252 } |