应用场景:
在内存中维持一个有序的vector:
root@u18:~/cp/test# valgrind --tool=memcheck --leak-check=yes ./a.out
==24247== Memcheck, a memory error detector
==24247== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==24247== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==24247== Command: ./a.out
==24247==
Before Sort:
0 sh
1 shsh
2 shshsh
3 shshshsh
4 shshshshsh
5 shshshshshsh
6 shshshshshshsh
7 shshshshshshshsh
8 shshshshshshshshsh
9 shshshshshshshshshsh
对向量中的所有元素按member1进行升序排列:
==24247== HEAP SUMMARY:
==24247== in use at exit: 0 bytes in 0 blocks
==24247== total heap usage: 25 allocs, 25 frees, 768 bytes allocated
==24247== All heap blocks were freed -- no leaks are possible
==24247== For counts of detected and suppressed errors, rerun with: -v
==24247== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)