From aded6de920f420b5c36fee1081c795cf8c6c6dc9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 16 Dec 2015 19:03:08 +0200 Subject: Rely on as few C++14 features as possible --- build/utility | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'build/utility') diff --git a/build/utility b/build/utility index 6769f95..bcb6b58 100644 --- a/build/utility +++ b/build/utility @@ -5,11 +5,9 @@ #ifndef BUILD_UTILITY #define BUILD_UTILITY -#include -#include #include // move(), make_pair() #include // assert() -#include +#include // uncaught_exception() #include #include @@ -44,40 +42,32 @@ namespace build // extern bool exception_unwinding_dtor; - template + template struct exception_guard; - template - inline exception_guard> - make_exception_guard (F f, A&&... a) + template + inline exception_guard + make_exception_guard (F f) { - return exception_guard> ( - std::move (f), std::forward_as_tuple (a...)); + return exception_guard (move (f)); } - template - struct exception_guard> + template + struct exception_guard { - typedef std::tuple T; - - exception_guard (F f, T a): f_ (std::move (f)), a_ (std::move (a)) {} + exception_guard (F f): f_ (move (f)) {} ~exception_guard () { if (std::uncaught_exception ()) { exception_unwinding_dtor = true; - call (std::index_sequence_for ()); + f_ (); exception_unwinding_dtor = false; } } private: - template - void - call (std::index_sequence) {f_ (std::get (a_)...);} - F f_; - T a_; }; // Pools (@@ perhaps move into a separate header). -- cgit v1.1