4

I have been learning C++ these days and sometimes I heard about the term “Scope Bound Resource Management”. What does Scope Bound Resource Management mean?

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
LiuHao
  • 412
  • 1
  • 6
  • 16
  • If you have a class that creates the resource in its constructor and destroys the resource in its destructor and you create a local variable of that type the resource will be managed based on the scope of the object - the resource will be destroyed when the object foes out of scope. – Jerry Jeremiah May 21 '15 at 03:11
  • See http://stackoverflow.com/questions/2321511/what-is-meant-by-resource-acquisition-is-initialization-raii (Not exactly a duplicate due to the other terminology. But on the other hand it's the second google result for "What does Scope Bound Resource Management mean?" after this question itself.) – TheUndeadFish May 21 '15 at 03:52
  • It's a better name of [RAII](http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization) – jfly May 21 '15 at 04:00

1 Answers1

8

It is synonymous to RAII. Since Bjarne himself says RAII is not a good name for the concept, some one proposed to use SBRM instead.

wilx
  • 17,697
  • 6
  • 59
  • 114
  • 3
    In the link you give, SBRM is a subset of RAII rather a synonym for it. RAII emphasizes that something somewhere owns a resource, while SBRM is the aspect of RAII related to nested scopes {}. A resource can however outlive a scope boundary by being assigned to a member of a class or return parameter. – Dwayne Robinson Sep 18 '15 at 04:46
  • 1
    @DwayneRobinson Can we say that the object has been passed to another (i.e. extended) scope? – Dmitrii Volosnykh Aug 08 '20 at 11:46
  • @wilx Would you mind adding a reference to the source of the aforementioned statement by Bjarne? – Dmitrii Volosnykh Aug 08 '20 at 11:46
  • @DmitryVolosnykh Yes, I would mind. This is not Wikipedia. Just watch his public appearances videos over the last 15 years. You will eventually find it. – wilx Aug 09 '20 at 22:15