Audacity 3.2.0
CFResources.h
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file CFResources.h
6
7 @brief Wrap resource pointers from Apple Core SDK for RAII
8
9 Paul Licameli
10
11 **********************************************************************/
12
13#ifndef __AUDACITY_CFRESOURCES__
14#define __AUDACITY_CFRESOURCES__
15
16#ifdef __APPLE__
17
18#include <cstddef>
19#include <memory>
20#include <type_traits>
21#include <utility>
22#include <CoreFoundation/CFBase.h>
23
24template<typename T = void *> struct CFReleaser{
25 void operator () (T p) const noexcept { if (p) CFRelease(p); } };
26
28
40template<typename T> using CF_ptr =
41 std::unique_ptr<std::remove_pointer_t<T>, CFReleaser<T>>;
42
43extern template struct CFReleaser<>;
44
45#endif
46#endif