From 3bdb789b7abeef41716c4f78491c6c1406abaeb0 Mon Sep 17 00:00:00 2001 From: q66 Date: Fri, 4 May 2018 21:02:55 +0200 Subject: [PATCH] predefined API for generating simple depend callbacks --- ostd/build/make.hh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ostd/build/make.hh b/ostd/build/make.hh index b06e7ac..8e3a0e2 100644 --- a/ostd/build/make.hh +++ b/ostd/build/make.hh @@ -71,6 +71,15 @@ private: std::vector p_subs{}; }; +inline auto make_depend_simple(string_range dep) { + return [d = std::string{dep}]( + string_range, decltype(appender>()) &app + ) { + /* need to copy as it may be called multiple times */ + app.put(d); + }; +} + struct make_rule { using body_func = std::function< void(string_range, iterator_range) @@ -169,9 +178,7 @@ private: template void add_depend(R &&v) { if constexpr (std::is_constructible_v) { - p_deps.push_back([s = std::string{v}](auto, auto &app) { - app.put(std::move(s)); - }); + p_deps.push_back(make_depend_simple(v)); } else if constexpr(std::is_constructible_v) { p_deps.push_back(std::forward(v)); } else {