migrate to std::ranges
Move the various seq_ functions, as well as std::(stable_)sort, std::accumulate, std::transform, std::find, std::find_if to their C++20 std::ranges counterparts.
This commit is contained in:
@ -63,7 +63,7 @@ save_parts(const Message& message, const std::string& filename_rx,
|
||||
else if (opts.extract.save_attachments &&
|
||||
part.looks_like_attachment())
|
||||
return true;
|
||||
else if (seq_some(opts.extract.parts,
|
||||
else if (std::ranges::any_of(opts.extract.parts,
|
||||
[&](auto&& num){return num==partnum;}))
|
||||
return true;
|
||||
else if (!filename_rx.empty() && part.raw_filename()) {
|
||||
|
||||
@ -144,10 +144,10 @@ topic_combi_fields(const Options& opts)
|
||||
Table fields;
|
||||
fields.add_row({"combi-field", "fields"});
|
||||
|
||||
seq_for_each(combi_fields(), [&](const auto& cfield) {
|
||||
std::ranges::for_each(combi_fields(), [&](const auto& cfield) {
|
||||
|
||||
std::string fnames;
|
||||
seq_for_each(cfield.fields, [&](auto&& field) {
|
||||
std::ranges::for_each(cfield.fields, [&](auto&& field) {
|
||||
if (!fnames.empty())
|
||||
fnames += ", ";
|
||||
fnames += mu_format("{}", field.name);
|
||||
|
||||
@ -49,7 +49,7 @@ Mu::mu_cmd_move(Mu::Store& store, const Options& opts)
|
||||
"Must have at least one of destination and flags");
|
||||
else if (!dest.empty()) {
|
||||
const auto mdirs{store.maildirs()};
|
||||
if (!seq_some(mdirs, [&](auto &&d){ return d == dest;}))
|
||||
if (!std::ranges::any_of(mdirs, [&](auto &&d){ return d == dest;}))
|
||||
return Err(Error{Error::Code::InvalidArgument,
|
||||
"No maildir '{}' in store", dest}
|
||||
.add_hint("Try 'mu mkdir'"));
|
||||
|
||||
@ -30,7 +30,7 @@ Mu::mu_cmd_script(const Options& opts)
|
||||
{
|
||||
ScriptPaths paths = { MU_SCRIPTS_DIR };
|
||||
const auto&& scriptinfos{script_infos(paths)};
|
||||
auto script_it = Mu::seq_find_if(scriptinfos, [&](auto&& item) {
|
||||
auto script_it = std::ranges::find_if(scriptinfos, [&](auto&& item) {
|
||||
return item.name == opts.script.name;
|
||||
});
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ static std::string /* return comma-sep'd list of attachments */
|
||||
get_attach_str(const Message& message, const Options& opts)
|
||||
{
|
||||
std::string str;
|
||||
seq_for_each(message.parts(), [&](auto&& part) {
|
||||
std::ranges::for_each(message.parts(), [&](auto&& part) {
|
||||
if (auto fname = part.raw_filename(); fname) {
|
||||
if (str.empty())
|
||||
str = fname.value();
|
||||
|
||||
Reference in New Issue
Block a user