Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2007-01-01 17:27:10

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:

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 {

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:

Take Surveys. Earn Cash. Influence the Future of IT
Join's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash

Boost-bugs mailing list

Boost list run by bdawes at, gregod at, cpdaniel at, john at