Changeset 3404
- Timestamp:
- Apr 3, 2015, 9:36:12 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/utility.cc
r3390 r3404 219 219 long double xld = 8.0; 220 220 suite.add(suite.equal(utility::log2(xld), 3.0)); 221 222 std::vector<std::string> vec(1, "text"); 223 utility::clear(vec); 224 suite.add(vec.size()==0); 221 225 222 226 test_basename(suite); -
trunk/yat/utility/stl_utility.h
r3295 r3404 466 466 467 467 /** 468 \brief reduce size and capacity to zero 469 470 The standard provides a member function clear(void), which clears 471 the contents of the vector i.e. sets the size to zero. However, 472 the member function might leave the capacity unchanged and 473 sometimes, when it's desiribale to save memory usage e.g., it 474 preferable to use this function, which reduces the capacity to zero. 475 476 \since new in yat 0.13 477 */ 478 template<typename T> 479 void clear(std::vector<T>& vec) 480 { 481 std::vector<T> other; 482 vec.swap(other); 483 } 484 485 486 /** 468 487 Same functionality as map::operator[] but the function does not 469 488 modify the map and the function throws if key does not exist in
Note: See TracChangeset
for help on using the changeset viewer.