diff --git a/doc/tutorial/argument_parser/solution3.cpp b/doc/tutorial/argument_parser/solution3.cpp index 4f752988..d24fec3f 100644 --- a/doc/tutorial/argument_parser/solution3.cpp +++ b/doc/tutorial/argument_parser/solution3.cpp @@ -7,9 +7,8 @@ template number_type to_number(range_type && range) { - std::string str; + std::string str = [&range] () { std::string s; for (auto c : range) s.push_back(c); return s; }(); number_type num; - std::ranges::copy(range, std::cpp20::back_inserter(str)); auto res = std::from_chars(&str[0], &str[0] + str.size(), num); if (res.ec != std::errc{}) diff --git a/doc/tutorial/argument_parser/solution4.cpp b/doc/tutorial/argument_parser/solution4.cpp index 770e4be9..ae364696 100644 --- a/doc/tutorial/argument_parser/solution4.cpp +++ b/doc/tutorial/argument_parser/solution4.cpp @@ -6,9 +6,8 @@ template number_type to_number(range_type && range) { - std::string str; + std::string str = [&range] () { std::string s; for (auto c : range) s.push_back(c); return s; }(); number_type num; - std::ranges::copy(range, std::cpp20::back_inserter(str)); auto res = std::from_chars(&str[0], &str[0] + str.size(), num); if (res.ec != std::errc{}) diff --git a/doc/tutorial/argument_parser/solution5.cpp b/doc/tutorial/argument_parser/solution5.cpp index 27af61e0..8af80548 100644 --- a/doc/tutorial/argument_parser/solution5.cpp +++ b/doc/tutorial/argument_parser/solution5.cpp @@ -6,9 +6,8 @@ template number_type to_number(range_type && range) { - std::string str; + std::string str = [&range] () { std::string s; for (auto c : range) s.push_back(c); return s; }(); number_type num; - std::ranges::copy(range, std::cpp20::back_inserter(str)); auto res = std::from_chars(&str[0], &str[0] + str.size(), num); if (res.ec != std::errc{}) diff --git a/doc/tutorial/argument_parser/solution6.cpp b/doc/tutorial/argument_parser/solution6.cpp index 130e06af..e71c9114 100644 --- a/doc/tutorial/argument_parser/solution6.cpp +++ b/doc/tutorial/argument_parser/solution6.cpp @@ -6,9 +6,8 @@ template number_type to_number(range_type && range) { - std::string str; + std::string str = [&range] () { std::string s; for (auto c : range) s.push_back(c); return s; }(); number_type num; - std::ranges::copy(range, std::cpp20::back_inserter(str)); auto res = std::from_chars(&str[0], &str[0] + str.size(), num); if (res.ec != std::errc{}) diff --git a/include/sharg/argument_parser.hpp b/include/sharg/argument_parser.hpp index c5325596..705350c0 100644 --- a/include/sharg/argument_parser.hpp +++ b/include/sharg/argument_parser.hpp @@ -697,7 +697,7 @@ class argument_parser { std::string arg{argv[i]}; - if (std::ranges::find(subcommands, arg) != subcommands.end()) + if (std::find(subcommands.begin(), subcommands.end(), arg) != subcommands.end()) { sub_parser = std::make_unique(info.app_name + "-" + arg, argc - i, diff --git a/include/sharg/detail/format_help.hpp b/include/sharg/detail/format_help.hpp index 1081718c..67080111 100644 --- a/include/sharg/detail/format_help.hpp +++ b/include/sharg/detail/format_help.hpp @@ -317,17 +317,14 @@ class format_help : public format_help_base // Tokenize the text. std::istringstream iss(text.c_str()); - std::vector tokens; - std::ranges::copy(std::istream_iterator(iss), std::istream_iterator(), - std::cpp20::back_inserter(tokens)); + std::vector tokens{std::istream_iterator(iss), std::istream_iterator()}; // Print the text. assert(pos <= tab); std::fill_n(out, tab - pos, ' '); // go to tab pos = tab; - typedef std::vector::const_iterator TConstIter; - for (TConstIter it = tokens.begin(); it != tokens.end(); ++it) + for (auto it = tokens.begin(); it != tokens.end(); ++it) { if (it == tokens.begin()) { diff --git a/include/sharg/validators.hpp b/include/sharg/validators.hpp index e5a406ed..cc50b43c 100644 --- a/include/sharg/validators.hpp +++ b/include/sharg/validators.hpp @@ -12,7 +12,6 @@ #pragma once -#include #include #include @@ -355,7 +354,7 @@ class file_validator_base }; // Check if requested extension is present. - if (std::ranges::find_if(extensions, case_insensitive_ends_with) == extensions.end()) + if (std::find_if(extensions.begin(), extensions.end(), case_insensitive_ends_with) == extensions.end()) { throw validation_error{"Expected one of the following valid extensions: " + extensions_str + "! Got " + all_extensions + " instead!"}; @@ -429,12 +428,15 @@ class file_validator_base { size_t const suffix_length{suffix.size()}; size_t const str_length{str.size()}; - return suffix_length > str_length ? - false : - std::ranges::equal(str.substr(str_length - suffix_length), suffix, [] (char const chr1, char const chr2) - { - return std::tolower(chr1) == std::tolower(chr2); - }); + + if (suffix_length > str_length) + return false; + + for (size_t j = 0, s_start = str_length - suffix_length; j < suffix_length; ++j) + if (std::tolower(str[s_start + j]) != std::tolower(suffix[j])) + return false; + + return true; } //!\brief Creates a std::string from the extensions list, e.g. "[ext, ext2]".