]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Remove obsolete ScopeGuard
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 8 May 2020 19:26:33 +0000 (21:26 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 8 May 2020 19:27:05 +0000 (21:27 +0200)
Makefile.in
dev.mk.in
src/ScopeGuard.hpp [deleted file]
src/ccache.cpp
unittest/test_ScopeGuard.cpp [deleted file]

index a5094f0353226c9d8809a099d0b6d9edb702feec..fbd2aea60d5d7798f446dde49226ad225a197dcc 100644 (file)
@@ -89,7 +89,6 @@ test_suites += unittest/test_Config.cpp
 test_suites += unittest/test_FormatNonstdStringView.cpp
 test_suites += unittest/test_Lockfile.cpp
 test_suites += unittest/test_NullCompression.cpp
-test_suites += unittest/test_ScopeGuard.cpp
 test_suites += unittest/test_Stat.cpp
 test_suites += unittest/test_Util.cpp
 test_suites += unittest/test_ZstdCompression.cpp
index 28121bc779d92cc67eaf75eff610298de313cc39..96f8a1a58b7dd652bd3e638208bb586eb736cbce 100644 (file)
--- a/dev.mk.in
+++ b/dev.mk.in
@@ -45,7 +45,6 @@ non_third_party_headers_without_cpp = \
     src/NullCompressor.hpp \
     src/NullDecompressor.hpp \
     src/ProgressBar.hpp \
-    src/ScopeGuard.hpp \
     src/Stat.hpp \
     src/StdMakeUnique.hpp \
     src/ThreadPool.hpp \
diff --git a/src/ScopeGuard.hpp b/src/ScopeGuard.hpp
deleted file mode 100644 (file)
index 9827ecd..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2020 Joel Rosdahl and other contributors
-//
-// See doc/AUTHORS.adoc for a complete list of contributors.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 3 of the License, or (at your option)
-// any later version.
-//
-// This program is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-// more details.
-//
-// You should have received a copy of the GNU General Public License along with
-// this program; if not, write to the Free Software Foundation, Inc., 51
-// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-#pragma once
-
-#include "NonCopyable.hpp"
-
-template<typename OnExit, typename T> struct ScopeGuard : NonCopyable
-{
-  explicit ScopeGuard(T& guarded) : m_guarded{guarded}
-  {
-  }
-
-  ~ScopeGuard()
-  {
-    OnExit onexit;
-    onexit(m_guarded);
-  }
-
-private:
-  T& m_guarded;
-};
index bd73f6a55ad6feecb7218a3b9dc1264755035595..397b45a731aa37d20b45fd1c99ffdd6e85686aa1 100644 (file)
@@ -25,7 +25,6 @@
 #include "File.hpp"
 #include "FormatNonstdStringView.hpp"
 #include "ProgressBar.hpp"
-#include "ScopeGuard.hpp"
 #include "Util.hpp"
 #include "argprocessing.hpp"
 #include "cleanup.hpp"
diff --git a/unittest/test_ScopeGuard.cpp b/unittest/test_ScopeGuard.cpp
deleted file mode 100644 (file)
index 124305e..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (C) 2020 Joel Rosdahl and other contributors
-//
-// See doc/AUTHORS.adoc for a complete list of contributors.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 3 of the License, or (at your option)
-// any later version.
-//
-// This program is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-// more details.
-//
-// You should have received a copy of the GNU General Public License along with
-// this program; if not, write to the Free Software Foundation, Inc., 51
-// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-#include "NonCopyable.hpp"
-#include "ScopeGuard.hpp"
-
-#include "third_party/catch.hpp"
-
-struct ptr_deleter
-{
-  void
-  operator()(int*& ptr)
-  {
-    delete ptr;
-    ptr = nullptr;
-  }
-};
-
-TEST_CASE("delete pointer")
-{
-  using ScopeGuardInt = ScopeGuard<ptr_deleter, int*>;
-  int* i = new int(3);
-
-  {
-    ScopeGuardInt guard(i);
-    CHECK(*i == 3);
-  }
-
-  CHECK(i == nullptr);
-}
-
-struct Value : NonCopyable
-{
-  int i = 3;
-};
-
-struct reset_value
-{
-  void
-  operator()(Value& v)
-  {
-    v.i = 0;
-  }
-};
-
-TEST_CASE("reset a value type")
-{
-  using ScopeGuardValue = ScopeGuard<reset_value, Value>;
-
-  Value v;
-
-  CHECK(v.i == 3);
-
-  {
-    ScopeGuardValue guard(v);
-    CHECK(v.i == 3);
-  }
-
-  CHECK(v.i == 0);
-}