From 557269660c1d9796a7cf9e911efb9262f645e359 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Nov 2016 12:10:03 +0200 Subject: Use diagnostics facility from libbutl --- build2/utility | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) (limited to 'build2/utility') diff --git a/build2/utility b/build2/utility index 4b83844..a0d040a 100644 --- a/build2/utility +++ b/build2/utility @@ -14,9 +14,8 @@ #include // ref(), cref() #include // combine_hash(), reverse_iterate(), casecmp(), - // lcase() + // lcase(), etc -#include // uncaught_exception() #include #include @@ -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 - struct exception_guard; - - template - inline exception_guard - make_exception_guard (F f) - { - return exception_guard (move (f)); - } - - template - 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 -- cgit v1.1