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 {