summaryrefslogtreecommitdiff
path: root/src/env.h
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-02-09 08:52:03 -0500
committerGitHub <noreply@github.com>2020-02-09 08:52:03 -0500
commit1f1f99f253f981ae3d11e9df177a144d00dbce0e (patch)
tree01d38125329508f5628f9221f797e303180c8fc3 /src/env.h
parent718c2a56f91f824c5eab69d8cc16294f77243370 (diff)
parent3a80685189967fbf4cfa002ac2b8a4fa421306ca (diff)
Merge pull request #994 from isanae/generic-file-list
New file tree
Diffstat (limited to 'src/env.h')
-rw-r--r--src/env.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/env.h b/src/env.h
index 16f8039e..5c7492c6 100644
--- a/src/env.h
+++ b/src/env.h
@@ -30,6 +30,23 @@ struct DesktopDCReleaser
using DesktopDCPtr = std::unique_ptr<HDC, DesktopDCReleaser>;
+// used by HMenuPtr, calls DestroyMenu() as the deleter
+//
+struct HMenuFreer
+{
+ using pointer = HMENU;
+
+ void operator()(HMENU h)
+ {
+ if (h != 0) {
+ ::DestroyMenu(h);
+ }
+ }
+};
+
+using HMenuPtr = std::unique_ptr<HMENU, HMenuFreer>;
+
+
// used by LibraryPtr, calls FreeLibrary as the deleter
//
struct LibraryFreer
@@ -94,6 +111,23 @@ template <class T>
using LocalPtr = std::unique_ptr<T, LocalFreer<T>>;
+// used by the CoTaskMemPtr, calls CoTaskMemFree() as the deleter
+//
+template <class T>
+struct CoTaskMemFreer
+{
+ using pointer = T;
+
+ void operator()(T p)
+ {
+ ::CoTaskMemFree(p);
+ }
+};
+
+template <class T>
+using CoTaskMemPtr = std::unique_ptr<T, CoTaskMemFreer<T>>;
+
+
// creates a console in the constructor and destroys it in the destructor,
// also redirects standard streams
//