raii
Why use one vs the other: `boost::shared_array` VS `boost::shared_ptr<std::vector>`?
So to deal with large blobs of memory either for an image or similar there are clea开发者_Python百科rly lots of options.[详细]
2023-03-22 14:15 分类:问答Improper nesting of variable scopes in C++?
I have some code that looks something like this: ComplexObject cpy; { RAIILockObject _(obj->mutex); cpy = obj->org;[详细]
2023-03-22 04:52 分类:问答Best way to use RAII conditionally
I have a nice resource managing class. For concreteness, lets have it be a File class for managing a FILE* (handling the open and close operations)[详细]
2023-03-14 04:39 分类:问答Queried class member returns wrong value
I have created a simple RAII class in one of my DLLs (let\'s call it the exporting DLL) which monitors for configuration restore in my application:[详细]
2023-03-13 18:56 分类:问答Move constructor and const member variables
I like the idea of const member variables especially when I wrap C functions into classes. The constructor takes a resource handle (e.g. a file descriptor) that stays valid during the whole object lif[详细]
2023-03-12 10:30 分类:问答Scopeguard and parameters by reference
In this article in the Supporting Parameters by Reference section, they point out the probl开发者_运维技巧em with and provide the solution to references.My question is: why don\'t they just declare th[详细]
2023-03-04 20:50 分类:问答Should I clean up ivar C++ vector...?
If a vector is placed in stack, it will be destructed automatically at the end of its automatic variable scope开发者_如何学C.[详细]
2023-02-20 11:51 分类:问答longjmp and RAII
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 of t[详细]
2023-02-18 05:39 分类:问答Understanding the life time of an object, scope, RAII
In the below code, when I pass an unnamed A variable to the ctor of B, the variable is destructed after the line. According to this answer :[详细]
2023-02-18 01:53 分类:问答RAII in Python - automatic destruction when leaving a scope
I\'ve been trying to find RAII in Python. Resource Allocation Is Initialization is a pattern in C++ whereby[详细]
2023-02-12 05:06 分类:问答