3 ms·
You can use `unique_ptr` with a custom deleter for wrapping C libraries. using snd_pcm_T = std::unique_ptr< snd_pcm_t, decltype([](void* ptr){snd_pcm
by badmintonbaseba 2y ago
You can use `unique_ptr` with a custom deleter for wrapping C libraries.
using snd_pcm_T = std::unique_ptr<
snd_pcm_t,
decltype([](void* ptr){snd_pcm_close(ptr);})
>;
auto pcm_handle = snd_pcm_T(snd_pcm_open(...));
The lambda in decltype is C++20, otherwise the deleter type could be declared out-of-line.