std :: fileystem :: diefory_iterator и std :: fileystem :: recursive_directory_iterator означает рекурсивное обход всех подкаталогов, в противном случае смотрите только в заданный путь. < /p>
Код: Выделить всё
argv[2]В качестве теста я использую std :: variant в функции option_r () , который выбирает правильный Directory_iterator в зависимости от того, в зависимости от того, является ли -р Флаг присутствует на вводе или нет.
Код: Выделить всё
#include
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace std::filesystem;
template concept isIter =
is_same::value || is_same::value;
template
dirIterator option_R(std::string_view options, const path& my_path)
{
variant my_iter;
if (options.find('R') != string::npos) {
my_iter.emplace(my_path, directory_options::skip_permission_denied);
return get(my_iter);
} else {
my_iter.emplace(my_path);
return get(my_iter);
}
}
template
void traverse(isIter& my_iter, vector& my_vec)
{
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79449553/use-of-stdvariant-to-select-types-after-command-prompt-input-is-that-even-p[/url]
Мобильная версия