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/algorithm.cxx | 26 +++++++++++--------------- build/cxx/compile.cxx | 5 ++--- build/target | 9 +++++---- build/utility | 30 ++++++++++-------------------- 4 files changed, 28 insertions(+), 42 deletions(-) (limited to 'build') diff --git a/build/algorithm.cxx b/build/algorithm.cxx index b296929..a2ee7c0 100644 --- a/build/algorithm.cxx +++ b/build/algorithm.cxx @@ -145,12 +145,11 @@ namespace build { auto g ( make_exception_guard ( - [](action a, target& t, const string& n) + [ra, &t, &n]() { info << "while matching rule " << n << " to " - << diag_do (a, t); - }, - ra, t, n)); + << diag_do (ra, t); + })); if (!(m = ru.match (ra, t, hint))) continue; @@ -173,12 +172,11 @@ namespace build { auto g ( make_exception_guard ( - [](action a, target& t, const string& n1) + [ra, &t, &n1]() { info << "while matching rule " << n1 << " to " - << diag_do (a, t); - }, - ra, t, n1)); + << diag_do (ra, t); + })); if (!ru1.match (ra, t, hint)) continue; @@ -203,12 +201,11 @@ namespace build { auto g ( make_exception_guard ( - [](action a, target& t, const string& n) + [ra, &t, &n]() { info << "while applying rule " << n << " to " - << diag_do (a, t); - }, - ra, t, n)); + << diag_do (ra, t); + })); // @@ We could also allow the rule to change the recipe // action in apply(). Could be useful with delegates. @@ -352,12 +349,11 @@ namespace build { auto g ( make_exception_guard ( - [](action a, target& t) + [a, &t]() { t.raw_state = target_state::failed; info << "while " << diag_doing (a, t); - }, - a, t)); + })); target_state ts (t.recipe (a) (a, t)); assert (ts != target_state::unknown && ts != target_state::failed); diff --git a/build/cxx/compile.cxx b/build/cxx/compile.cxx index 2a56fbd..2481b62 100644 --- a/build/cxx/compile.cxx +++ b/build/cxx/compile.cxx @@ -514,11 +514,10 @@ namespace build // auto g ( make_exception_guard ( - [](target& s) + [&s]() { info << "while extracting dependencies from " << s; - }, - s)); + })); while (pos != l.size ()) { diff --git a/build/target b/build/target index 22b5e89..c848f14 100644 --- a/build/target +++ b/build/target @@ -709,7 +709,7 @@ namespace build // prerequisite_members(t.prerequisites) // - inline auto + inline prerequisite_members_range prerequisite_members (action a, target& t, bool members = true) { return prerequisite_members (a, t.prerequisites, members); @@ -717,7 +717,8 @@ namespace build // prerequisite_members(reverse_iterate(t.prerequisites)) // - inline auto + inline prerequisite_members_range< + butl::reverse_range> reverse_prerequisite_members (action a, target& t, bool members = true) { return prerequisite_members ( @@ -726,7 +727,7 @@ namespace build // prerequisite_members(group_prerequisites (t)) // - inline auto + inline prerequisite_members_range group_prerequisite_members (action a, target& t, bool members = true) { return prerequisite_members (a, group_prerequisites (t), members); @@ -734,7 +735,7 @@ namespace build // prerequisite_members(reverse_iterate (group_prerequisites (t))) // - inline auto + inline prerequisite_members_range> reverse_group_prerequisite_members (action a, target& t, bool members = true) { return prerequisite_members ( 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