aboutsummaryrefslogtreecommitdiff
path: root/build2/utility
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-22 12:10:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-22 12:10:03 +0200
commit557269660c1d9796a7cf9e911efb9262f645e359 (patch)
tree0323bcb5a90c339fe87fcd193cf71bdcb3431c91 /build2/utility
parentfae6cd2235c907e077dad7b5d8dc9b6d90a78a37 (diff)
Use diagnostics facility from libbutl
Diffstat (limited to 'build2/utility')
-rw-r--r--build2/utility46
1 files changed, 4 insertions, 42 deletions
diff --git a/build2/utility b/build2/utility
index 4b83844..a0d040a 100644
--- a/build2/utility
+++ b/build2/utility
@@ -14,9 +14,8 @@
#include <functional> // ref(), cref()
#include <butl/utility> // combine_hash(), reverse_iterate(), casecmp(),
- // lcase()
+ // lcase(), etc
-#include <exception> // uncaught_exception()
#include <unordered_set>
#include <build2/types>
@@ -54,6 +53,9 @@ namespace build2
using butl::alnum;
using butl::digit;
+ using butl::exception_guard;
+ using butl::make_exception_guard;
+
// Basic string utilities.
//
@@ -434,46 +436,6 @@ namespace build2
unsigned int
to_version (const string&);
- // Call a function if there is an exception.
- //
-
- // Means we are in the body of a destructor that is being called
- // as part of the exception stack unwindining. Used to compensate
- // for the deficiencies of uncaught_exception() until C++17
- // uncaught_exceptions() becomes available.
- //
- // @@ MT: will have to be TLS.
- //
- extern bool exception_unwinding_dtor;
-
- template <typename F>
- struct exception_guard;
-
- template <typename F>
- inline exception_guard<F>
- make_exception_guard (F f)
- {
- return exception_guard<F> (move (f));
- }
-
- template <typename F>
- struct exception_guard
- {
- exception_guard (F f): f_ (move (f)) {}
- ~exception_guard ()
- {
- if (std::uncaught_exception ())
- {
- exception_unwinding_dtor = true;
- f_ ();
- exception_unwinding_dtor = false;
- }
- }
-
- private:
- F f_;
- };
-
// Pools (@@ perhaps move into a separate header).
//
struct string_pool: std::unordered_set<std::string>