On 15/12/05, Buster
map1[5] = "hello"; // does NOT commit to container or database list1.push_back(1.0); // does NOT commit either t.commit(); // Finally commits to container and database. // Without this call, t would call rollback // in destructor.
http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm The scopeguard trick will work in any case where you have a rollback function that is nofail -- such as erase in a map or pop_back in a list. For more complex tasks you'll need a more complex solution, but ScopeGuard is quite simple and elegant for many. I wrote an implementation you're free to use or imitate or whatever: http://www.uploadthis.co.uk/uploads/me22/guard.hpp - Scott McMurray