forked from OctaForge/libostd
predefined API for generating simple depend callbacks
This commit is contained in:
parent
08e8dc3f19
commit
3bdb789b7a
|
@ -71,6 +71,15 @@ private:
|
||||||
std::vector<string_range> p_subs{};
|
std::vector<string_range> p_subs{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline auto make_depend_simple(string_range dep) {
|
||||||
|
return [d = std::string{dep}](
|
||||||
|
string_range, decltype(appender<std::vector<std::string>>()) &app
|
||||||
|
) {
|
||||||
|
/* need to copy as it may be called multiple times */
|
||||||
|
app.put(d);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
struct make_rule {
|
struct make_rule {
|
||||||
using body_func = std::function<
|
using body_func = std::function<
|
||||||
void(string_range, iterator_range<string_range *>)
|
void(string_range, iterator_range<string_range *>)
|
||||||
|
@ -169,9 +178,7 @@ private:
|
||||||
template<typename R>
|
template<typename R>
|
||||||
void add_depend(R &&v) {
|
void add_depend(R &&v) {
|
||||||
if constexpr (std::is_constructible_v<std::string, R const &>) {
|
if constexpr (std::is_constructible_v<std::string, R const &>) {
|
||||||
p_deps.push_back([s = std::string{v}](auto, auto &app) {
|
p_deps.push_back(make_depend_simple(v));
|
||||||
app.put(std::move(s));
|
|
||||||
});
|
|
||||||
} else if constexpr(std::is_constructible_v<depend_func, R &&>) {
|
} else if constexpr(std::is_constructible_v<depend_func, R &&>) {
|
||||||
p_deps.push_back(std::forward<R>(v));
|
p_deps.push_back(std::forward<R>(v));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue