list<RawAddress>::iterator it = find(addresses.begin(),addresses.end(),rawAddress);
return it != addresses.end(); }
HeapTracked使用示例
classAsset: public HeapTracked{ private: UPNumber value; ... };
voidinventoryAsset(const Asset *ap) { if(ap->isOnHeap()){ // ap is a heap-based asset —— inventory it as such; } else{ // ap is a non-heap-based asset —— record it that way; } }
//TEST Asset asset; if (asset.isOnHeap()){ cout << "asset is on Heap" << "\n"; } else{ cout << "asset is not on Heap" << "\n"; }
Asset *asset_ptr = newAsset(); if (asset_ptr->isOnHeap()) { cout << "asset_ptr is on Heap" << "\n"; } else { cout << "asset_ptr is not on Heap" << "\n"; }
Asset *asset_ptr1 = &asset; if (asset_ptr1->isOnHeap()) { cout << "asset_ptr1 is on Heap" << "\n"; } else { cout << "asset_ptr1 is not on Heap" << "\n"; }