aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-16 19:03:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-16 19:03:08 +0200
commitaded6de920f420b5c36fee1081c795cf8c6c6dc9 (patch)
treeea62cba64fdd01cb8ae0a67611038e9522d6fa4d
parente62aef8ebe4b4b7eb733da6822d7759c0427222b (diff)
Rely on as few C++14 features as possible
-rw-r--r--build/algorithm.cxx26
-rw-r--r--build/cxx/compile.cxx5
-rw-r--r--build/target9
-rw-r--r--build/utility30
4 files changed, 28 insertions, 42 deletions
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<target::prerequisites_type&>
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<target::prerequisites_type&>>
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_prerequisites>
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<butl::reverse_range<group_prerequisites>>
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 <tuple>
-#include <string>
#include <utility> // move(), make_pair()
#include <cassert> // assert()
-#include <exception>
+#include <exception> // uncaught_exception()
#include <unordered_set>
#include <build/types>
@@ -44,40 +42,32 @@ namespace build
//
extern bool exception_unwinding_dtor;
- template <typename F, typename T>
+ template <typename F>
struct exception_guard;
- template <typename F, typename... A>
- inline exception_guard<F, std::tuple<A&&...>>
- make_exception_guard (F f, A&&... a)
+ template <typename F>
+ inline exception_guard<F>
+ make_exception_guard (F f)
{
- return exception_guard<F, std::tuple<A&&...>> (
- std::move (f), std::forward_as_tuple (a...));
+ return exception_guard<F> (move (f));
}
- template <typename F, typename... A>
- struct exception_guard<F, std::tuple<A...>>
+ template <typename F>
+ struct exception_guard
{
- typedef std::tuple<A...> 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<A...> ());
+ f_ ();
exception_unwinding_dtor = false;
}
}
private:
- template <std::size_t... I>
- void
- call (std::index_sequence<I...>) {f_ (std::get<I> (a_)...);}
-
F f_;
- T a_;
};
// Pools (@@ perhaps move into a separate header).