[Boost-bugs] [ boost-Bugs-1625854 ] guard_impl objects should store references

Bugs item #1625854, was opened at 2007-01-01 17:27 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1625854&group_id=7586 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: multi_index Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Braden McDaniel (braden) Assigned to: Joaqu�n M L�pez Mu�oz (joaquintides) Summary: guard_impl objects should store references Initial Comment: In multi_index::detail::scope_guard, it seems to me that the guard_impl objects should store references to their parameters rather than copies. Consider the following code: T * obj = 0; scope_guard guard = make_guard(delete_T, obj); obj = create_T(); if (obj) { // do stuff } else { guard.dismiss(); } Since make_guard passes obj by copy (and the guard_impl holds a copy), the value passed to delete_T is always 0. This behavior can be defeated by explicitly giving make_guard a reference parameter: make_guard<void (*)(T*), T*&>(delete_T, obj) However, that obviously gets quite verbose; and I don't see a downside to storing the parameters as references consistently. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1625854&group_id=7586 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Boost-bugs mailing list Boost-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/boost-bugs
participants (1)
-
SourceForge.net