Changeset 3753
 Timestamp:
 Jan 2, 2015, 2:44:59 AM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/base/array.h
r3697 r3753 2 2 // Lol Engine 3 3 // 4 // Copyright: (c) 2010201 4Sam Hocevar <sam@hocevar.net>4 // Copyright: (c) 20102015 Sam Hocevar <sam@hocevar.net> 5 5 // (c) 20132014 Benjamin "Touky" Huet <huet.benjamin@gmail.com> 6 6 // This program is free software; you can redistribute it and/or … … 134 134 /* Allow array[0] even if size is zero so that people can 135 135 * always use &array[0] to get a pointer to the data. */ 136 ASSERT(n >= 0); 137 ASSERT(n < m_count  (!n && !m_count)); 136 ASSERT(n >= 0 && (n < m_count  (!n && !m_count)), 137 "cannot access index %lld in array of size %lld", 138 (long long int)n, (long long int)m_count); 138 139 return m_data[n]; 139 140 } … … 141 142 inline element_t const& operator[](ptrdiff_t n) const 142 143 { 143 ASSERT(n >= 0); 144 ASSERT(n < m_count  (!n && !m_count)); 144 ASSERT(n >= 0 && (n < m_count  (!n && !m_count)), 145 "cannot access index %lld in array of size %lld", 146 (long long int)n, (long long int)m_count); 145 147 return m_data[n]; 146 148 } … … 206 208 inline void Insert(T const &x, ptrdiff_t pos) 207 209 { 208 ASSERT(pos >= 0); 209 ASSERT(pos <= m_count); 210 ASSERT(pos >= 0 && pos <= m_count, 211 "cannot insert at index %lld in array of size %lld", 212 (long long int)pos, (long long int)m_count); 210 213 211 214 if (m_count >= m_reserved) … … 223 226 inline bool InsertUnique(T const &x, ptrdiff_t pos) 224 227 { 225 ASSERT(pos >= 0); 226 ASSERT(pos <= m_count); 228 ASSERT(pos >= 0 && pos <= m_count, 229 "cannot insert at index %lld in array of size %lld", 230 (long long int)pos, (long long int)m_count); 227 231 228 232 if (Find(x) != INDEX_NONE) … … 285 289 void Swap(ptrdiff_t pos1, ptrdiff_t pos2) 286 290 { 287 ASSERT(pos1 >= 0); 288 ASSERT(pos2 >= 0); 289 ASSERT(pos1 < m_count); 290 ASSERT(pos2 < m_count); 291 ASSERT(pos1 >= 0 && pos1 <= m_count, 292 "cannot swap index %lld in array of size %lld", 293 (long long int)pos1, (long long int)m_count); 294 ASSERT(pos2 >= 0 && pos2 <= m_count, 295 "cannot swap index %lld in array of size %lld", 296 (long long int)pos2, (long long int)m_count); 291 297 292 298 if (pos1 != pos2) … … 297 303 { 298 304 ASSERT(todelete >= 0); 299 ASSERT(pos  todelete >= m_count  1); 300 ASSERT(pos + todelete <= m_count); 305 ASSERT(pos  todelete >= m_count  1 && pos + todelete <= m_count, 306 "cannot remove %lld elements at %lld in array of size %lld", 307 (long long int)todelete, (long long int)pos, 308 (long long int)m_count); 309 301 310 if (pos < 0) 302 311 pos = m_count + pos; … … 312 321 { 313 322 ASSERT(todelete >= 0); 314 ASSERT(pos  todelete >= m_count  1); 315 ASSERT(pos + todelete <= m_count); 323 ASSERT(pos  todelete >= m_count  1 && pos + todelete <= m_count, 324 "cannot remove %lld elements at %lld in array of size %lld", 325 (long long int)todelete, (long long int)pos, 326 (long long int)m_count); 327 316 328 if (pos < 0) 317 329 pos = m_count + pos; … … 486 498 inline void Insert(ptrdiff_t pos, T... args) 487 499 { 488 ASSERT(pos >= 0); 489 ASSERT(pos <= this>m_count); 500 ASSERT(pos >= 0 && pos <= this>m_count, 501 "cannot insert at index %lld in array of size %lld", 502 (long long int)pos, (long long int)this>m_count); 490 503 491 504 if (this>m_count >= this>m_reserved)
Note: See TracChangeset
for help on using the changeset viewer.