raii Questions

2

Solved

So to deal with large blobs of memory either for an image or similar there are clearly lots of options. Since I'm a fan of smart pointers and RAII I'm wondering about whether it's smarter to go wi...
Bourn asked 22/7, 2011 at 22:13

6

Solved

I make a lot of use of boost::scoped_ptr in my code and it is great but I'm currently working with software that uses shared_ptr all over the place and I'm wondering if I'm missing something. AFA...
Patras asked 5/12, 2008 at 14:49

2

Solved

I admit I have no deep understanding of D at this point, my knowledge relies purely on what documentation I have read and the few examples I have tried. In C++ you could rely on the RAII idiom to ...
Alegar asked 24/5, 2011 at 4:23

10

Solved

In C#, if I want to deterministically clean up non-managed resources, I can use the "using" keyword. But for multiple dependent objects, this ends up nesting further and further: using (FileStream...
Gratin asked 16/9, 2008 at 18:59

1

Solved

Writing a wrapper class for a handle that only gets passed by value is relatively easy. I am trying to determine what the best way is to encapsulate handles that need to be passed by address. For ...
Whensoever asked 20/4, 2011 at 19:44

3

Solved

Lets say with have generic code like the following: y.hpp: #ifndef Y_HPP #define Y_HPP // LOTS OF FILES INCLUDED template <class T> class Y { public: T z; // LOTS OF STUFF HERE }; #en...
Sward asked 28/3, 2011 at 14:8

2

Solved

So I have a library (not written by me) which unfortunately uses abort() to deal with certain errors. At the application level, these errors are recoverable so I would like to handle them instead o...
Suggestibility asked 22/3, 2011 at 15:45

10

Solved

Could you C++ developers please give us a good description of what RAII is, why it is important, and whether or not it might have any relevance to other languages? I do know a little bit. I believ...
Maratha asked 3/4, 2009 at 5:21

7

Solved

Being primarily a C++ developer the absence of RAII (Resource Acquisition Is Initialization) in Java and .NET has always bothered me. The fact that the onus of cleaning up is moved from the class w...
Cutaneous asked 6/10, 2008 at 9:25

4

Solved

Given a C API to a library controlling sessions that owns items, what is the best design to encapsulate the C API into RAII C++ classes? The C API looks like: HANDLE OpenSession(STRING sessionID)...
Asel asked 16/9, 2010 at 10:38

4

Solved

I know it's by design that you can't control what happens when an object is destroyed. I am also aware of defining some class method as a finalizer. However is the ruby idiom for C++'s RAII (Resou...
Old asked 18/10, 2008 at 5:40

3

Solved

I'm learning D, and am confused by an error I'm getting. Consider the following: module helloworld; import std.stdio; import std.perf; ptrdiff_t main( string[] args ) { auto t = new Performanc...
Plausible asked 23/10, 2010 at 22:2

1

Note: Object Lifetime RAII not using/with block scope RAII It seems like its possible using an extra gc category, short lived objects(check gc category somewhat frequently), long lived objects(che...

4

Solved

I'd like to learn how to use RAII in c++. I think I know what it is, but have no idea how to implement it in my programs. A quick google search did not show any nice tutorials. Does any one ...
Edge asked 14/4, 2010 at 8:25

12

Solved

Something I often used back in C++ was letting a class A handle a state entry and exit condition for another class B, via the A constructor and destructor, to make sure that if something in that sc...
Cincinnati asked 20/1, 2010 at 13:13

5

Can anyone provide me with one or more concrete examples in which RAII was not the most efficient method for resource management, and why?
Sliver asked 21/7, 2010 at 9:48

5

Solved

Is this good practice? Or should I just replace the code block between { and } with a function? It could be reusable (I admit) but my only motivation for doing this is to deallocate colsum since it...
Egide asked 14/7, 2010 at 17:20

6

Solved

How should an error during resource deallocation be handled, when the object representing the resource is contained in a shared pointer? EDIT 1: To put this question in more concrete terms: Man...
Treviso asked 16/5, 2010 at 19:39

3

Solved

At my work we recently finished the system architecture for a control application which has a maximum latency of roughly one to two seconds. It is distributed on small ARM on-chip boxes communicati...
Peculation asked 26/5, 2010 at 20:31

4

Solved

I have some code to update a database table that looks like try { db.execute("BEGIN"); // Lots of DELETE and INSERT db.execute("COMMIT"); } catch (DBException&) { db.execute("ROLLBACK"); ...
Headache asked 9/4, 2010 at 7:2

6

Solved

I previously asked this question under another name but deleted it because I didn't explain it very well. Let's say I have a class which manages a file. Let's say that this class treats the file a...
Homes asked 12/2, 2010 at 17:59

3

Solved

I have a case where I wish to store a list of resources in a std::vector. As I see it, my options are as follows: Give my resource a default constructor Store them as heap objects (and wrap them ...
Peeling asked 5/3, 2010 at 7:26

10

I'm just getting started with RAII in C++ and set up a little test case. Either my code is deeply confused, or RAII is not working! (I guess it is the former). If I run: #include <exception&gt...
Cavendish asked 9/7, 2009 at 14:8

1

Solved

Is there anyway to implement Resource Acquisation is Initialization in Scheme? I know that RAII does not work well in GC-ed languages (since we have no idea whe the object is destroyed). However, ...
Rush asked 19/1, 2010 at 2:46

8

Solved

In the C++ code below, am I guaranteed that the ~obj() destructor will be called after the // More code executes? Or is the compiler allowed to destruct the obj object earlier if it detects that it...
Entrepreneur asked 18/1, 2010 at 16:41

© 2022 - 2024 — McMap. All rights reserved.