From 8749eeea8723196fa38a9eb7917775cfe8b87ad7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Nov 2016 12:09:27 +0200 Subject: Use diagnostics facility from libbutl --- bpkg/utility | 45 ++++----------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) (limited to 'bpkg/utility') diff --git a/bpkg/utility b/bpkg/utility index b7dbf36..950a36a 100644 --- a/bpkg/utility +++ b/bpkg/utility @@ -11,7 +11,7 @@ #include // assert() #include // make_move_iterator() -#include // casecmp(), reverse_iterate() +#include // casecmp(), reverse_iterate(), etc #include // uncaught_exception() @@ -35,6 +35,9 @@ namespace bpkg using butl::casecmp; using butl::reverse_iterate; + using butl::exception_guard; + using butl::make_exception_guard; + // Widely-used paths. // extern const dir_path bpkg_dir; // .bpkg/ @@ -112,46 +115,6 @@ namespace bpkg bool quiet = false, const strings& pvars = strings (), const strings& cvars = strings ()); - - // Call a function if there is an exception. - // - - // True 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 (std::move (f)); - } - - template - struct exception_guard - { - exception_guard (F f): f_ (std::move (f)) {} - ~exception_guard () - { - if (std::uncaught_exception ()) - { - exception_unwinding_dtor = true; - f_ (); - exception_unwinding_dtor = false; - } - } - - private: - F f_; - }; } #endif // BPKG_UTILITY -- cgit v1.1