Skip to main content

Questions tagged [raii]

Resource Acquisition Is Initialization (RAII) is a common idiom used in C++ to manage the lifetime of resources, including memory allocations, file handles or database connections. In brief, every resource should be wrapped in an owning class, whose lifetime controls the lifetime of the resource.

2 votes
1 answer
92 views

I was recently working on my CUDA wrappers library, and this particular class is one of the oldest pieces of code in the entire project. Since that time, I added tons of other features (for example <...
NeKon's user avatar
  • 641
7 votes
1 answer
265 views

I've implemented a resource management class for CUDA interop using RAII to ensure exception safety. The goal is to handle the registration/unregistration and mapping/unmapping, of graphics resources (...
NeKon's user avatar
  • 641
1 vote
0 answers
94 views

This is some kind of follow up to my previous question, this question will be more focused on the actual tessellating pipeline. What I changed from previous question Implemented the async sphere ...
NeKon's user avatar
  • 641
4 votes
2 answers
141 views

I'm working on a C++ graphics app and have put together a set of RAII classes to manage the initialization boilerplate for SDL3 and OpenGL. My goal is to make the setup process safer and more modular. ...
NeKon's user avatar
  • 641
3 votes
2 answers
257 views

Are there any issues with this class template? It is supposed to provide an easy-to-use object solution to initialize an object of class type after the declaration of the variable. One nuisance is the ...
Bolpat's user avatar
  • 243
4 votes
2 answers
457 views

As a practice of implementing RAII-enabled class, I prepared a class called DynamicWallet that wraps around two raw pointers. I am well aware that using smart ...
D.J. Elkind's user avatar
5 votes
1 answer
968 views

I want to use the scope_exit class but my compiler/standard library (clang++-16 with libc++) don't support it. Until they do I wanted an implementation. I found a ...
nebuch's user avatar
  • 165
0 votes
1 answer
145 views

This is a wrapper for a synchronized data structure that: Saves periodically Keeps track of dirty flag automatically (set when a write access is requested) Maintains a lock on data Only allows access ...
CaptainCodeman's user avatar
2 votes
1 answer
183 views

I'm working on a personal project to build an open-source gui for git. I'm hoping to learn a lot from the project, and maybe produce something useful for folks as I do. I'm making use of libgit2 to ...
Stephen Hern's user avatar
1 vote
1 answer
414 views

I'm going to use these classes in a program I'm working on, so I want to see if they're correct or could be improved. https://pastebin.com/qx7ccteT ...
my_stack_exchange_account's user avatar
1 vote
1 answer
625 views

I have attempted to implement a similar version of the STL Vector; several functions are missing but I'd like a few words of advice on whether I am indeed on the right track or whether I should change ...
PeePeePooPoo's user avatar
4 votes
1 answer
818 views

I am trying to implement a network server application in C++ using Boost.Asio. Here are the requirements I am trying to meet: The Application creates only one instance of ...
MarekR's user avatar
  • 141
5 votes
2 answers
127 views

I got tired of the boilerplate and tedium restoring formatting context, so I made an RAII stasher that relies on the destroy-at-end-of-full-statement temporary semantics. With C++17 I can get it down ...
jthill's user avatar
  • 153
4 votes
1 answer
166 views

I need a unique_ptr and shared_ptr like structure, but instead of pointers, I would like to store some kind of reference to a ...
Adam's user avatar
  • 63
13 votes
3 answers
3k views

I was trying to create a simple RAII wrapper with rule of 5 for a TCP POSIX socket. My aim was to try learn how to apply rule of five in different situations, but this one was somehow tricky. ...
Afshin's user avatar
  • 295

15 30 50 per page