From: Joel Rosdahl Date: Sat, 5 Sep 2020 18:46:42 +0000 (+0200) Subject: Use “using nonstd::*” consistently X-Git-Tag: v4.0~124 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b25ee490f16ab47741a39838053996a3a52b5c3e;p=thirdparty%2Fccache.git Use “using nonstd::*” consistently --- diff --git a/src/Args.cpp b/src/Args.cpp index 034233fbf..92a1e41ba 100644 --- a/src/Args.cpp +++ b/src/Args.cpp @@ -20,6 +20,10 @@ #include "Util.hpp" +using nonstd::nullopt; +using nonstd::optional; +using nonstd::string_view; + Args::Args(Args&& other) noexcept : m_args(std::move(other.m_args)) { } @@ -42,14 +46,14 @@ Args::from_string(const std::string& command) return args; } -nonstd::optional +optional Args::from_gcc_atfile(const std::string& filename) { std::string argtext; try { argtext = Util::read_file(filename); } catch (Error&) { - return nonstd::nullopt; + return nullopt; } Args args; @@ -152,7 +156,7 @@ Args::to_string() const } void -Args::erase_with_prefix(nonstd::string_view prefix) +Args::erase_with_prefix(string_view prefix) { m_args.erase(std::remove_if(m_args.begin(), m_args.end(), diff --git a/src/Hash.cpp b/src/Hash.cpp index 9f493e45a..c5b135aaf 100644 --- a/src/Hash.cpp +++ b/src/Hash.cpp @@ -87,7 +87,7 @@ Hash::hash(const void* data, size_t size, HashType hash_type) } Hash& -Hash::hash(nonstd::string_view data) +Hash::hash(string_view data) { hash(data.data(), data.length()); return *this; diff --git a/src/Util.cpp b/src/Util.cpp index f5cf0193d..644864b9d 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -176,7 +176,7 @@ rewrite_stderr_to_absolute_paths(string_view text) line = line.substr(csi_seq.length()); } size_t path_end = line.find(':'); - if (path_end == nonstd::string_view::npos) { + if (path_end == string_view::npos) { result.append(line.data(), line.length()); } else { std::string path(line.substr(0, path_end)); @@ -868,8 +868,7 @@ make_relative_path(const Context& ctx, string_view path) } bool -matches_dir_prefix_or_file(nonstd::string_view dir_prefix_or_file, - nonstd::string_view path) +matches_dir_prefix_or_file(string_view dir_prefix_or_file, string_view path) { return !dir_prefix_or_file.empty() && !path.empty() && dir_prefix_or_file.length() <= path.length() diff --git a/src/ccache.cpp b/src/ccache.cpp index 03c40fcbe..201722701 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -767,7 +767,7 @@ update_manifest_file(Context& ctx) } static bool -create_cachedir_tag(nonstd::string_view dir) +create_cachedir_tag(string_view dir) { constexpr char cachedir_tag[] = "Signature: 8a477f597d28d172789f06886806bc55\n" diff --git a/unittest/test_FormatNonstdStringView.cpp b/unittest/test_FormatNonstdStringView.cpp index bb271c4ce..c171c74aa 100644 --- a/unittest/test_FormatNonstdStringView.cpp +++ b/unittest/test_FormatNonstdStringView.cpp @@ -20,28 +20,30 @@ #include "third_party/doctest.h" +using nonstd::string_view; + TEST_SUITE_BEGIN("FormatNonstdStringView"); TEST_CASE("fmt::format and nonstd::string_view") { - nonstd::string_view null; + string_view null; CHECK(fmt::format("{}", null) == ""); const std::string s = "0123456789"; - nonstd::string_view empty(s.data(), 0); + string_view empty(s.data(), 0); CHECK(fmt::format("{}", empty) == ""); - nonstd::string_view empty_end(s.data() + s.length(), 0); + string_view empty_end(s.data() + s.length(), 0); CHECK(fmt::format("{}", empty_end) == ""); - nonstd::string_view start(s.data(), 2); + string_view start(s.data(), 2); CHECK(fmt::format("{}", start) == "01"); - nonstd::string_view middle(s.data() + 3, 4); + string_view middle(s.data() + 3, 4); CHECK(fmt::format("{}", middle) == "3456"); - nonstd::string_view end(s.data() + s.length() - 2, 2); + string_view end(s.data() + s.length() - 2, 2); CHECK(fmt::format("{}", end) == "89"); }