about summary refs log tree commit diff
path: root/src/libutil/util.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-01-16T21·39+0100
committerEelco Dolstra <edolstra@gmail.com>2017-01-16T21·39+0100
commit8079ab87a2a7cd288a35334517da7a808af8e1e0 (patch)
tree011aa471421d7d51033077994464ecdd3fe9a1eb /src/libutil/util.hh
parent2b9d0a99cbf7649c20492bc539e2823a2d2e57c5 (diff)
AutoCloseDir: Use std::unique_ptr
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r--src/libutil/util.hh15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index d420997815f5..679c3a1b6df4 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -180,18 +180,15 @@ public:
 };
 
 
-class AutoCloseDir
+struct DIRDeleter
 {
-    DIR * dir;
-public:
-    AutoCloseDir();
-    AutoCloseDir(DIR * dir);
-    ~AutoCloseDir();
-    void operator =(DIR * dir);
-    operator DIR *();
-    void close();
+    void operator()(DIR * dir) const {
+        closedir(dir);
+    }
 };
 
+typedef std::unique_ptr<DIR, DIRDeleter> AutoCloseDir;
+
 
 class Pid
 {