Get the latest tech news

Modern C++ – RAII


— RAII Modern C++ embraces the features from C++11 which lay the foundation for a new generation of C++. It introduced move semantics and embraced RAII in the standard library ( unique_ptr, shared_ptr, lock_guard).

We'll create a safe wrapper around a UNIX file descriptor keeping in mind that the same concept can be applied to any other resource. That's a problem — file descriptors aren't simple numbers that can be copied since they're a handle to a resource the kernel holds for us. In GCC and Clang, the warning is hidden behind the-Wdeprecated-copy-dtor flag which is disabled by default and almost never enabled(not part of-Wall,-Wextra or-Wpedantic).

Get the Android app

Or read this on Hacker News

Read more on:

Photo of modern c++

modern c++

Photo of RAII

RAII

Related news:

News photo

Understanding Memory Management, Part 2: C++ and RAII

News photo

Botan: Crypto and TLS for Modern C++

News photo

RAII and the Rust/Linux Drama