diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2017-04-07 16:13:54 +0300 |
---|---|---|
committer | Sergey Yershov <syershov@maps.me> | 2017-04-19 22:04:09 +0300 |
commit | 96e77809e46c6e7bad62273b50078934e4368e76 (patch) | |
tree | 17fc9ecb00e0dd3e5d1c5847d53faed09fdb7ebc | |
parent | de1c29b3761c4a91d6b3a4f83b746c7947fb850d (diff) |
std migration basebeta-773
-rw-r--r-- | base/base_tests/buffer_vector_test.cpp | 11 | ||||
-rw-r--r-- | base/base_tests/cache_test.cpp | 6 | ||||
-rw-r--r-- | base/base_tests/collection_cast_test.cpp | 6 | ||||
-rw-r--r-- | base/base_tests/levenshtein_dfa_test.cpp | 10 | ||||
-rw-r--r-- | base/base_tests/logging_test.cpp | 6 | ||||
-rw-r--r-- | base/base_tests/math_test.cpp | 8 | ||||
-rw-r--r-- | base/base_tests/mem_trie_test.cpp | 2 | ||||
-rw-r--r-- | base/base_tests/newtype_test.cpp | 16 | ||||
-rw-r--r-- | base/base_tests/observer_list_test.cpp | 8 | ||||
-rw-r--r-- | base/base_tests/range_iterator_test.cpp | 22 | ||||
-rw-r--r-- | base/base_tests/regexp_test.cpp | 44 | ||||
-rw-r--r-- | base/base_tests/stl_add_test.cpp | 4 | ||||
-rw-r--r-- | base/base_tests/stl_helpers_test.cpp | 40 | ||||
-rw-r--r-- | base/base_tests/string_utils_test.cpp | 118 | ||||
-rw-r--r-- | base/base_tests/thread_pool_tests.cpp | 18 | ||||
-rw-r--r-- | base/base_tests/threaded_list_test.cpp | 10 | ||||
-rw-r--r-- | base/base_tests/timegm_test.cpp | 2 | ||||
-rw-r--r-- | base/math.hpp | 3 | ||||
-rw-r--r-- | base/rolling_hash.hpp | 4 |
19 files changed, 172 insertions, 166 deletions
diff --git a/base/base_tests/buffer_vector_test.cpp b/base/base_tests/buffer_vector_test.cpp index 6b7949d488..56cb5a09cd 100644 --- a/base/base_tests/buffer_vector_test.cpp +++ b/base/base_tests/buffer_vector_test.cpp @@ -1,10 +1,11 @@ #include "testing/testing.hpp" #include "base/buffer_vector.hpp" +#include "base/stl_add.hpp" #include "base/string_utils.hpp" -#include "std/numeric.hpp" -#include "std/unique_ptr.hpp" +#include <memory> +#include <numeric> namespace { @@ -276,7 +277,7 @@ namespace struct CopyCtorChecker { - string m_s; + std::string m_s; CopyCtorChecker() = default; CopyCtorChecker(char const * s) : m_s(s) {} @@ -354,10 +355,10 @@ UNIT_TEST(BufferVector_EraseIf) UNIT_TEST(BufferVector_OnlyMoveableItems) { - buffer_vector<unique_ptr<size_t>, 4> v; + buffer_vector<std::unique_ptr<size_t>, 4> v; for (size_t i = 0; i < 10; ++i) - v.emplace_back(make_unique<size_t>(i)); + v.emplace_back(my::make_unique<size_t>(i)); TEST_EQUAL(v.size(), 10, ()); for (size_t i = 0; i < 10; ++i) diff --git a/base/base_tests/cache_test.cpp b/base/base_tests/cache_test.cpp index e9d8f2e65e..8e9ae4dc52 100644 --- a/base/base_tests/cache_test.cpp +++ b/base/base_tests/cache_test.cpp @@ -3,7 +3,7 @@ #include "base/macros.hpp" #include "base/stl_add.hpp" -#include "std/bind.hpp" +#include <functional> namespace { @@ -102,7 +102,7 @@ UNIT_TEST(CacheSmoke_2) { my::Cache<uint32_t, char> cache(3); // it contains 2^3=8 elements SimpleFunctor f; - cache.ForEachValue(ref(f)); // f passed by reference + cache.ForEachValue(std::ref(f)); // f passed by reference TEST_EQUAL(f.m_v, std::vector<char>(8, 0), ()); } @@ -149,7 +149,7 @@ UNIT_TEST(CacheSmoke_5) { my::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements SimpleFunctor f; - cache.ForEachValue(ref(f)); // f passed by reference + cache.ForEachValue(std::ref(f)); // f passed by reference TEST_EQUAL(f.m_v, std::vector<char>(8, 0), ()); } diff --git a/base/base_tests/collection_cast_test.cpp b/base/base_tests/collection_cast_test.cpp index c5ead707b5..a322a0ef5c 100644 --- a/base/base_tests/collection_cast_test.cpp +++ b/base/base_tests/collection_cast_test.cpp @@ -2,10 +2,10 @@ #include "base/collection_cast.hpp" -#include "std/list.hpp" -#include "std/vector.hpp" +#include <list> +#include <vector> UNIT_TEST(collection_cast) { - TEST_EQUAL((list<int>{1, 2, 3, 4, }), my::collection_cast<list>(vector<int> {1, 2, 3, 4}), ()); + TEST_EQUAL((std::list<int>{1, 2, 3, 4, }), my::collection_cast<std::list>(std::vector<int> {1, 2, 3, 4}), ()); } diff --git a/base/base_tests/levenshtein_dfa_test.cpp b/base/base_tests/levenshtein_dfa_test.cpp index 01e9756206..2d8bdc0910 100644 --- a/base/base_tests/levenshtein_dfa_test.cpp +++ b/base/base_tests/levenshtein_dfa_test.cpp @@ -3,7 +3,7 @@ #include "base/dfa_helpers.hpp" #include "base/levenshtein_dfa.hpp" -#include "std/string.hpp" +#include <string> using namespace strings; @@ -16,7 +16,7 @@ enum class Status Intermediate }; -Status GetStatus(LevenshteinDFA const & dfa, string const & s) +Status GetStatus(LevenshteinDFA const & dfa, std::string const & s) { auto it = dfa.Begin(); DFAMove(it, s); @@ -27,17 +27,17 @@ Status GetStatus(LevenshteinDFA const & dfa, string const & s) return Status::Intermediate; } -bool Accepts(LevenshteinDFA const & dfa, string const & s) +bool Accepts(LevenshteinDFA const & dfa, std::string const & s) { return GetStatus(dfa, s) == Status::Accepts; } -bool Rejects(LevenshteinDFA const & dfa, string const & s) +bool Rejects(LevenshteinDFA const & dfa, std::string const & s) { return GetStatus(dfa, s) == Status::Rejects; } -bool Intermediate(LevenshteinDFA const & dfa, string const & s) +bool Intermediate(LevenshteinDFA const & dfa, std::string const & s) { return GetStatus(dfa, s) == Status::Intermediate; } diff --git a/base/base_tests/logging_test.cpp b/base/base_tests/logging_test.cpp index cb6439ef18..ff5e50ad16 100644 --- a/base/base_tests/logging_test.cpp +++ b/base/base_tests/logging_test.cpp @@ -2,13 +2,13 @@ #include "base/logging.hpp" -#include "std/utility.hpp" -#include "std/vector.hpp" +#include <utility> +#include <vector> namespace { - void TestLogMessage(my::LogLevel, my::SrcPoint const &, string const &) + void TestLogMessage(my::LogLevel, my::SrcPoint const &, std::string const &) { } diff --git a/base/base_tests/math_test.cpp b/base/base_tests/math_test.cpp index cc79055856..183a66ce73 100644 --- a/base/base_tests/math_test.cpp +++ b/base/base_tests/math_test.cpp @@ -1,6 +1,8 @@ #include "testing/testing.hpp" + #include "base/math.hpp" -#include "std/limits.hpp" + +#include <limits> #include <boost/math/special_functions/next.hpp> @@ -45,8 +47,8 @@ UNIT_TEST(AlmostEqualULPs_Smoke) TEST_ALMOST_EQUAL_ULPS(3.0, 3.0, ()); TEST_ALMOST_EQUAL_ULPS(+0.0, -0.0, ()); - double const eps = numeric_limits<double>::epsilon(); - double const dmax = numeric_limits<double>::max(); + double const eps = std::numeric_limits<double>::epsilon(); + double const dmax = std::numeric_limits<double>::max(); TEST_ALMOST_EQUAL_ULPS(1.0 + eps, 1.0, ()); TEST_ALMOST_EQUAL_ULPS(1.0 - eps, 1.0, ()); diff --git a/base/base_tests/mem_trie_test.cpp b/base/base_tests/mem_trie_test.cpp index 1c4bb3ac9b..925a23f7f5 100644 --- a/base/base_tests/mem_trie_test.cpp +++ b/base/base_tests/mem_trie_test.cpp @@ -9,7 +9,7 @@ namespace { -using Trie = my::MemTrie<string, my::VectorValues<int>>; +using Trie = my::MemTrie<std::string, my::VectorValues<int>>; using Data = std::vector<std::pair<std::string, int>>; void GetTrieContents(Trie const & trie, Data & data) diff --git a/base/base_tests/newtype_test.cpp b/base/base_tests/newtype_test.cpp index e912b557d1..c0908fac9c 100644 --- a/base/base_tests/newtype_test.cpp +++ b/base/base_tests/newtype_test.cpp @@ -2,8 +2,8 @@ #include "base/newtype.hpp" -#include "std/sstream.hpp" -#include "std/type_traits.hpp" +#include <sstream> +#include <type_traits> namespace { @@ -11,17 +11,17 @@ NEWTYPE(int, Int); string DebugPrint(Int const & i) { - stringstream sstr; + std::stringstream sstr; sstr << "Int(" << i.Get() << ')'; return sstr.str(); } UNIT_TEST(NewType_TypeChecks) { - TEST((is_constructible<Int, int>::value), ()); - TEST((is_constructible<Int, char>::value), ()); - TEST(!(is_convertible<int, Int>::value), ()); - TEST(!(is_convertible<Int, int>::value), ()); + TEST((std::is_constructible<Int, int>::value), ()); + TEST((std::is_constructible<Int, char>::value), ()); + TEST(!(std::is_convertible<int, Int>::value), ()); + TEST(!(std::is_convertible<Int, int>::value), ()); } UNIT_TEST(NewType_Base) @@ -107,7 +107,7 @@ UNIT_TEST(NewType_SimpleOutPut) using namespace test_output; TEST_EQUAL(test_output::DebugPrint(Int(10)), "10", ()); - ostringstream sstr; + std::ostringstream sstr; sstr << Int(20); TEST_EQUAL(sstr.str(), "20", ()); } diff --git a/base/base_tests/observer_list_test.cpp b/base/base_tests/observer_list_test.cpp index 342c3254e0..5db3af375c 100644 --- a/base/base_tests/observer_list_test.cpp +++ b/base/base_tests/observer_list_test.cpp @@ -2,7 +2,7 @@ #include "base/observer_list.hpp" -#include "std/string.hpp" +#include <string> namespace { @@ -10,13 +10,13 @@ struct Observer { Observer() : status(0) {} - void OnOperationCompleted(string const & message, int status) + void OnOperationCompleted(std::string const & message, int status) { this->message = message; this->status = status; } - string message; + std::string message; int status; }; } // namespace @@ -43,7 +43,7 @@ UNIT_TEST(ObserverList_Basic) TEST(!observers.Add(observer1), ()); TEST(!observers.Add(observer2), ()); - string const message = "HTTP OK"; + std::string const message = "HTTP OK"; observers.ForEach(&Observer::OnOperationCompleted, message, 204); // Check observers internal state. diff --git a/base/base_tests/range_iterator_test.cpp b/base/base_tests/range_iterator_test.cpp index bca5d09096..50ff634e1e 100644 --- a/base/base_tests/range_iterator_test.cpp +++ b/base/base_tests/range_iterator_test.cpp @@ -2,42 +2,42 @@ #include "base/range_iterator.hpp" -#include "std/vector.hpp" +#include <vector> UNIT_TEST(RangeIterator) { using namespace my; { - vector<int> result; + std::vector<int> result; for (auto const i : UpTo(5)) result.push_back(i); - TEST_EQUAL(result, (vector<int>{0, 1, 2, 3, 4}), ()); + TEST_EQUAL(result, (std::vector<int>{0, 1, 2, 3, 4}), ()); } { - vector<int> result; + std::vector<int> result; for (auto const i : UpTo(2, 5)) result.push_back(i); - TEST_EQUAL(result, (vector<int>{2, 3, 4}), ()); + TEST_EQUAL(result, (std::vector<int>{2, 3, 4}), ()); } { - vector<int> result; + std::vector<int> result; for (auto const i : DownTo(5)) result.push_back(i); - TEST_EQUAL(result, (vector<int>{4, 3, 2, 1, 0}), ()); + TEST_EQUAL(result, (std::vector<int>{4, 3, 2, 1, 0}), ()); } { - vector<int> result; + std::vector<int> result; for (auto const i : DownTo(2, 5)) result.push_back(i); - TEST_EQUAL(result, (vector<int>{4, 3, 2}), ()); + TEST_EQUAL(result, (std::vector<int>{4, 3, 2}), ()); } { - TEST_EQUAL(vector<int>(MakeRangeIterator(0), MakeRangeIterator(5)), - (vector<int>{0, 1, 2, 3, 4}), ()); + TEST_EQUAL(std::vector<int>(MakeRangeIterator(0), MakeRangeIterator(5)), + (std::vector<int>{0, 1, 2, 3, 4}), ()); } } diff --git a/base/base_tests/regexp_test.cpp b/base/base_tests/regexp_test.cpp index a1f7474505..06e0f2921f 100644 --- a/base/base_tests/regexp_test.cpp +++ b/base/base_tests/regexp_test.cpp @@ -3,41 +3,41 @@ #include "base/stl_add.hpp" #include "base/string_utils.hpp" -#include "std/regex.hpp" +#include <regex> UNIT_TEST(RegExp_Or) { - regex exp("\\.mwm\\.(downloading2?$|resume2?$)"); + std::regex exp("\\.mwm\\.(downloading2?$|resume2?$)"); - TEST(regex_search("Aruba.mwm.downloading", exp), ()); + TEST(std::regex_search("Aruba.mwm.downloading", exp), ()); TEST(!regex_search("Aruba.mwm.downloading1", exp), ()); - TEST(regex_search("Aruba.mwm.downloading2", exp), ()); + TEST(std::regex_search("Aruba.mwm.downloading2", exp), ()); TEST(!regex_search("Aruba.mwm.downloading3", exp), ()); TEST(!regex_search("Aruba.mwm.downloading.tmp", exp), ()); - TEST(regex_search("Aruba.mwm.resume", exp), ()); + TEST(std::regex_search("Aruba.mwm.resume", exp), ()); TEST(!regex_search("Aruba.mwm.resume1", exp), ()); - TEST(regex_search("Aruba.mwm.resume2", exp), ()); + TEST(std::regex_search("Aruba.mwm.resume2", exp), ()); TEST(!regex_search("Aruba.mwm.resume3", exp), ()); TEST(!regex_search("Aruba.mwm.resume.tmp", exp), ()); } UNIT_TEST(RegExp_ForEachMatched) { - regex exp("-?\\d+\\.?\\d*, *-?\\d+\\.?\\d*"); + std::regex exp("-?\\d+\\.?\\d*, *-?\\d+\\.?\\d*"); { - string const s = "6.66, 9.99"; - std::vector<string> v; + std::string const s = "6.66, 9.99"; + std::vector<std::string> v; strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 1, ()); TEST_EQUAL(v[0], s, ()); } { - string const s1 = "6.66, 9.99"; - string const s2 = "-5.55, -7.77"; - std::vector<string> v; + std::string const s1 = "6.66, 9.99"; + std::string const s2 = "-5.55, -7.77"; + std::vector<std::string> v; strings::ForEachMatched(s1 + " 180 , bfuewib 365@" + s2, exp, MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 2, ()); TEST_EQUAL(v[0], s1, ()); @@ -45,31 +45,31 @@ UNIT_TEST(RegExp_ForEachMatched) } { - string const s = "X6.66, 9.99"; - std::vector<string> v; + std::string const s = "X6.66, 9.99"; + std::vector<std::string> v; strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 1, ()); - TEST_EQUAL(v[0], string(s.begin() + 1, s.end()), ()); + TEST_EQUAL(v[0], std::string(s.begin() + 1, s.end()), ()); } { - string const s = "6.66, 9.99X"; - std::vector<string> v; + std::string const s = "6.66, 9.99X"; + std::vector<std::string> v; strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 1, ()); - TEST_EQUAL(v[0], string(s.begin(), s.end() - 1), ()); + TEST_EQUAL(v[0], std::string(s.begin(), s.end() - 1), ()); } { - string const s = "6.66X, 9.99"; - std::vector<string> v; + std::string const s = "6.66X, 9.99"; + std::vector<std::string> v; strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 0, ()); } { - string const s = "6.66, X9.99"; - std::vector<string> v; + std::string const s = "6.66, X9.99"; + std::vector<std::string> v; strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 0, ()); } diff --git a/base/base_tests/stl_add_test.cpp b/base/base_tests/stl_add_test.cpp index d425003cea..82ff469580 100644 --- a/base/base_tests/stl_add_test.cpp +++ b/base/base_tests/stl_add_test.cpp @@ -4,7 +4,7 @@ #include "base/stl_add.hpp" -#include "std/deque.hpp" +#include <deque> UNIT_TEST(STLAdd_IsSorted) @@ -73,7 +73,7 @@ UNIT_TEST(STLAdd_RemoveIfKeepValid) } { - deque<int> v; + std::deque<int> v; v.push_back(1); v.push_back(0); v.push_back(1); diff --git a/base/base_tests/stl_helpers_test.cpp b/base/base_tests/stl_helpers_test.cpp index 71462cfbaf..424007c40f 100644 --- a/base/base_tests/stl_helpers_test.cpp +++ b/base/base_tests/stl_helpers_test.cpp @@ -2,10 +2,10 @@ #include "base/stl_helpers.hpp" -#include "std/algorithm.hpp" -#include "std/deque.hpp" -#include "std/utility.hpp" -#include "std/vector.hpp" +#include <algorithm> +#include <deque> +#include <utility> +#include <vector> namespace { @@ -31,7 +31,7 @@ void TestSortUnique() } { using Value = int; - using Pair = pair<Value, int>; + using Pair = std::pair<Value, int>; Cont<Pair> d = {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}}; @@ -44,7 +44,7 @@ void TestSortUnique() } { using Value = double; - using Pair = pair<Value, int>; + using Pair = std::pair<Value, int>; Cont<Pair> d = {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}}; @@ -61,9 +61,9 @@ template <template <typename...> class Cont> void TestEqualsBy() { { - using Value = pair<int, int>; + using Value = std::pair<int, int>; Cont<Value> actual = {{1, 2}, {1, 3}, {2, 100}, {3, 7}, {3, 8}, {2, 500}}; - actual.erase(unique(actual.begin(), actual.end(), my::EqualsBy(&Value::first)), actual.end()); + actual.erase(std::unique(actual.begin(), actual.end(), my::EqualsBy(&Value::first)), actual.end()); Cont<int> const expected = {{1, 2, 3, 2}}; TEST_EQUAL(expected.size(), actual.size(), ()); @@ -75,7 +75,7 @@ void TestEqualsBy() Cont<Int> actual; for (auto const v : {0, 0, 1, 2, 2, 0}) actual.emplace_back(v); - actual.erase(unique(actual.begin(), actual.end(), my::EqualsBy(&Int::Get)), actual.end()); + actual.erase(std::unique(actual.begin(), actual.end(), my::EqualsBy(&Int::Get)), actual.end()); Cont<int> const expected = {{0, 1, 2, 0}}; TEST_EQUAL(expected.size(), actual.size(), ()); @@ -87,28 +87,28 @@ void TestEqualsBy() UNIT_TEST(LessBy) { { - using Value = pair<int, int>; + using Value = std::pair<int, int>; - vector<Value> v = {{2, 2}, {0, 4}, {3, 1}, {4, 0}, {1, 3}}; - sort(v.begin(), v.end(), my::LessBy(&Value::first)); + std::vector<Value> v = {{2, 2}, {0, 4}, {3, 1}, {4, 0}, {1, 3}}; + std::sort(v.begin(), v.end(), my::LessBy(&Value::first)); for (size_t i = 0; i < v.size(); ++i) TEST_EQUAL(i, v[i].first, ()); - vector<Value const *> pv; + std::vector<Value const *> pv; for (auto const & p : v) pv.push_back(&p); - sort(pv.begin(), pv.end(), my::LessBy(&Value::second)); + std::sort(pv.begin(), pv.end(), my::LessBy(&Value::second)); for (size_t i = 0; i < pv.size(); ++i) TEST_EQUAL(i, pv[i]->second, ()); } { - vector<Int> v; + std::vector<Int> v; for (int i = 9; i >= 0; --i) v.emplace_back(i); - sort(v.begin(), v.end(), my::LessBy(&Int::Get)); + std::sort(v.begin(), v.end(), my::LessBy(&Int::Get)); for (size_t i = 0; i < v.size(); ++i) TEST_EQUAL(v[i].Get(), static_cast<int>(i), ()); } @@ -116,14 +116,14 @@ UNIT_TEST(LessBy) UNIT_TEST(EqualsBy_VectorTest) { - TestEqualsBy<vector>(); - TestEqualsBy<deque>(); + TestEqualsBy<std::vector>(); + TestEqualsBy<std::deque>(); } UNIT_TEST(SortUnique_VectorTest) { - TestSortUnique<vector>(); - TestSortUnique<deque>(); + TestSortUnique<std::vector>(); + TestSortUnique<std::deque>(); } UNIT_TEST(IgnoreFirstArgument) diff --git a/base/base_tests/string_utils_test.cpp b/base/base_tests/string_utils_test.cpp index 0f2438bf5c..aad6b7a2dd 100644 --- a/base/base_tests/string_utils_test.cpp +++ b/base/base_tests/string_utils_test.cpp @@ -3,12 +3,12 @@ #include "base/string_utils.hpp" #include "base/logging.hpp" -#include "std/bind.hpp" -#include "std/fstream.hpp" -#include "std/iomanip.hpp" -#include "std/map.hpp" -#include "std/unordered_map.hpp" -#include "std/vector.hpp" +#include <functional> +#include <fstream> +#include <iomanip> +#include <map> +#include <unordered_map> +#include <vector> #include <sstream> @@ -21,9 +21,9 @@ UNIT_TEST(LowerUniChar) // To use Platform class here, we need to add many link stuff into .pro file ... //string const fName = GetPlatform().WritablePathForFile("CaseFolding.test"); - string const fName = "../../../omim/data/CaseFolding.test"; + std::string const fName = "../../../omim/data/CaseFolding.test"; - ifstream file(fName.c_str()); + std::ifstream file(fName.c_str()); if (!file.good()) { LOG(LWARNING, ("Can't open unicode test file", fName)); @@ -31,12 +31,12 @@ UNIT_TEST(LowerUniChar) } size_t fCount = 0, cCount = 0; - typedef unordered_map<strings::UniChar, strings::UniString> mymap; + typedef std::unordered_map<strings::UniChar, strings::UniString> mymap; mymap m; - string line; + std::string line; while (file.good()) { - getline(file, line); + std::getline(file, line); // strip comments size_t const sharp = line.find('#'); if (sharp != string::npos) @@ -44,18 +44,18 @@ UNIT_TEST(LowerUniChar) strings::SimpleTokenizer semicolon(line, ";"); if (!semicolon) continue; - string const capital = *semicolon; + std::string const capital = *semicolon; std::istringstream stream(capital); strings::UniChar uc; - stream >> hex >> uc; + stream >> std::hex >> uc; ++semicolon; - string const type = *semicolon; + std::string const type = *semicolon; if (type == " S" || type == " T") continue; if (type != " C" && type != " F") continue; ++semicolon; - string const outChars = *semicolon; + std::string const outChars = *semicolon; strings::UniString us; strings::SimpleTokenizer spacer(outChars, " "); while (spacer) @@ -63,7 +63,7 @@ UNIT_TEST(LowerUniChar) stream.clear(); stream.str(*spacer); strings::UniChar smallCode; - stream >> hex >> smallCode; + stream >> std::hex >> smallCode; us.push_back(smallCode); ++spacer; } @@ -101,7 +101,7 @@ UNIT_TEST(LowerUniChar) UNIT_TEST(MakeLowerCase) { - string s; + std::string s; s = "THIS_IS_UPPER"; strings::MakeLowerCaseInplace(s); @@ -115,7 +115,7 @@ UNIT_TEST(MakeLowerCase) strings::MakeLowerCaseInplace(s); TEST_EQUAL(s, "this_is_lower", ()); - string const utf8("Hola! 99-\xD0\xA3\xD0\x9F\xD0\xAF\xD0\xA7\xD0\x9A\xD0\x90"); + std::string const utf8("Hola! 99-\xD0\xA3\xD0\x9F\xD0\xAF\xD0\xA7\xD0\x9A\xD0\x90"); TEST_EQUAL(strings::MakeLowerCase(utf8), "hola! 99-\xD1\x83\xD0\xBF\xD1\x8F\xD1\x87\xD0\xBA\xD0\xB0", ()); @@ -137,7 +137,7 @@ UNIT_TEST(EqualNoCase) UNIT_TEST(to_double) { - string s; + std::string s; double d; s = ""; @@ -177,7 +177,7 @@ UNIT_TEST(to_double) UNIT_TEST(to_int) { int i; - string s; + std::string s; s = "AF"; TEST(strings::to_int(s, i, 16), ()); @@ -202,7 +202,7 @@ UNIT_TEST(to_int) UNIT_TEST(to_uint) { unsigned int i; - string s; + std::string s; s = ""; TEST(!strings::to_uint(s, i), ()); @@ -239,7 +239,7 @@ UNIT_TEST(to_uint) UNIT_TEST(to_uint64) { uint64_t i; - string s; + std::string s; s = ""; TEST(!strings::to_uint64(s, i), ()); @@ -259,7 +259,7 @@ UNIT_TEST(to_uint64) UNIT_TEST(to_int64) { int64_t i; - string s; + std::string s; s = "-24567"; TEST(strings::to_int64(s, i), ()); @@ -333,20 +333,20 @@ UNIT_TEST(to_string_dac) struct FunctorTester { size_t & m_index; - vector<string> const & m_tokens; + std::vector<std::string> const & m_tokens; - FunctorTester(size_t & counter, vector<string> const & tokens) + FunctorTester(size_t & counter, std::vector<std::string> const & tokens) : m_index(counter), m_tokens(tokens) { } - void operator()(string const & s) + void operator()(std::string const & s) { TEST_EQUAL(s, m_tokens[m_index++], ()); } }; -void TestIter(string const & s, char const * delims, vector<string> const & tokens) +void TestIter(std::string const & s, char const * delims, std::vector<std::string> const & tokens) { strings::SimpleTokenizer it(s, delims); for (size_t i = 0; i < tokens.size(); ++i) @@ -363,7 +363,7 @@ void TestIter(string const & s, char const * delims, vector<string> const & toke TEST_EQUAL(counter, tokens.size(), ()); } -void TestIterWithEmptyTokens(string const & s, char const * delims, vector<string> const & tokens) +void TestIterWithEmptyTokens(std::string const & s, char const * delims, std::vector<std::string> const & tokens) { strings::SimpleTokenizerWithEmptyTokens it(s, delims); @@ -378,7 +378,7 @@ void TestIterWithEmptyTokens(string const & s, char const * delims, vector<strin UNIT_TEST(SimpleTokenizer) { - vector<string> tokens; + std::vector<std::string> tokens; TestIter("", "", tokens); TestIter("", "; ", tokens); TestIter(" : ; , ;", "; :,", tokens); @@ -416,38 +416,38 @@ UNIT_TEST(SimpleTokenizer) } { - string const s = ""; - vector<string> const tokens = {""}; + std::string const s = ""; + std::vector<std::string> const tokens = {""}; TestIterWithEmptyTokens(s, ",", tokens); } { - string const s = ";"; - vector<string> const tokens = {"", ""}; + std::string const s = ";"; + std::vector<std::string> const tokens = {"", ""}; TestIterWithEmptyTokens(s, ";", tokens); } { - string const s = ";;"; - vector<string> const tokens = {"", "", ""}; + std::string const s = ";;"; + std::vector<std::string> const tokens = {"", "", ""}; TestIterWithEmptyTokens(s, ";", tokens); } { - string const s = "Hello, World!"; - vector<string> const tokens = {s}; + std::string const s = "Hello, World!"; + std::vector<std::string> const tokens = {s}; TestIterWithEmptyTokens(s, "", tokens); } { - string const s = "Hello, World!"; - vector<string> const tokens = {"Hello", " World", ""}; + std::string const s = "Hello, World!"; + std::vector<std::string> const tokens = {"Hello", " World", ""}; TestIterWithEmptyTokens(s, ",!", tokens); } { - string const s = ";a;b;;c;d;"; - vector<string> const tokens = {"", "a", "b", "", "c", "d", ""}; + std::string const s = ";a;b;;c;d;"; + std::vector<std::string> const tokens = {"", "a", "b", "", "c", "d", ""}; TestIterWithEmptyTokens(s, ";", tokens); } } @@ -455,7 +455,7 @@ UNIT_TEST(SimpleTokenizer) UNIT_TEST(Tokenize) { { - std::initializer_list<string> expected{"acb", "def", "ghi"}; + std::initializer_list<std::string> expected{"acb", "def", "ghi"}; TEST_EQUAL(strings::Tokenize<std::vector>("acb def ghi", " " /* delims */), std::vector<std::string>(expected), ()); TEST_EQUAL(strings::Tokenize<std::set>("acb def ghi", " " /* delims */), std::set<std::string>(expected), ()); } @@ -470,7 +470,7 @@ UNIT_TEST(LastUniChar) UNIT_TEST(GetUniString) { - string const s = "Hello, \xD0\x9C\xD0\xB8\xD0\xBD\xD1\x81\xD0\xBA!"; + std::string const s = "Hello, \xD0\x9C\xD0\xB8\xD0\xBD\xD1\x81\xD0\xBA!"; strings::SimpleTokenizer iter(s, ", !"); { strings::UniChar const s[] = { 'H', 'e', 'l', 'l', 'o' }; @@ -505,12 +505,12 @@ UNIT_TEST(Normalize) UNIT_TEST(Normalize_Special) { { - string const utf8 = "ąĄćłŁÓŻźŃĘęĆ"; + std::string const utf8 = "ąĄćłŁÓŻźŃĘęĆ"; TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), "aAclLOZzNEeC", ()); } { - string const utf8 = "əüöğ"; + std::string const utf8 = "əüöğ"; TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), "əuog", ()); } } @@ -519,16 +519,16 @@ UNIT_TEST(UniStringToUtf8) { char const utf8Text[] = "У нас исходники хранятся в Utf8!"; strings::UniString uniS = strings::MakeUniString(utf8Text); - TEST_EQUAL(string(utf8Text), strings::ToUtf8(uniS), ()); + TEST_EQUAL(std::string(utf8Text), strings::ToUtf8(uniS), ()); } UNIT_TEST(StartsWith) { using namespace strings; - TEST(StartsWith(string(), ""), ()); + TEST(StartsWith(std::string(), ""), ()); - string s("xyz"); + std::string s("xyz"); TEST(StartsWith(s, ""), ()); TEST(StartsWith(s, "x"), ()); TEST(StartsWith(s, "xyz"), ()); @@ -548,9 +548,9 @@ UNIT_TEST(StartsWith) UNIT_TEST(EndsWith) { using namespace strings; - TEST(EndsWith(string(), ""), ()); + TEST(EndsWith(std::string(), ""), ()); - string s("xyz"); + std::string s("xyz"); TEST(EndsWith(s, ""), ()); TEST(EndsWith(s, "z"), ()); TEST(EndsWith(s, "yz"), ()); @@ -562,7 +562,7 @@ UNIT_TEST(EndsWith) UNIT_TEST(UniString_LessAndEqualsAndNotEquals) { - vector<strings::UniString> v; + std::vector<strings::UniString> v; v.push_back(strings::MakeUniString("")); v.push_back(strings::MakeUniString("Tes")); v.push_back(strings::MakeUniString("Test")); @@ -680,8 +680,8 @@ UNIT_TEST(AlmostEqual) TEST(!AlmostEqual("MKAD, 45-y kilometre", "MKAD, 46", 2), ()); TEST(!AlmostEqual("ул. Героев Панфиловцев", "ул. Планерная", 2), ()); - string small(10, '\0'); - string large(1000, '\0'); + std::string small(10, '\0'); + std::string large(1000, '\0'); TEST(AlmostEqual(small, large, large.length()), ()); TEST(AlmostEqual(large, small, large.length()), ()); } @@ -717,7 +717,7 @@ UNIT_TEST(EditDistance) UNIT_TEST(NormalizeDigits) { - auto const nd = [](string str) -> string + auto const nd = [](std::string str) -> std::string { strings::NormalizeDigits(str); return str; @@ -730,7 +730,7 @@ UNIT_TEST(NormalizeDigits) UNIT_TEST(NormalizeDigits_UniString) { - auto const nd = [](string const & utf8) -> string + auto const nd = [](std::string const & utf8) -> std::string { strings::UniString us = strings::MakeUniString(utf8); strings::NormalizeDigits(us); @@ -744,14 +744,14 @@ UNIT_TEST(NormalizeDigits_UniString) UNIT_TEST(CSV) { - vector<string> target; + std::vector<std::string> target; strings::ParseCSVRow(",Test\\,проверка,0,", ',', target); - vector<string> expected({"", "Test\\", "проверка", "0", ""}); + std::vector<std::string> expected({"", "Test\\", "проверка", "0", ""}); TEST_EQUAL(target, expected, ()); strings::ParseCSVRow("and there was none", ' ', target); - vector<string> expected2({"and", "there", "", "was", "none"}); + std::vector<std::string> expected2({"and", "there", "", "was", "none"}); TEST_EQUAL(target, expected2, ()); strings::ParseCSVRow("", 'q', target); - vector<string> expected3; + std::vector<std::string> expected3; TEST_EQUAL(target, expected3, ()); } diff --git a/base/base_tests/thread_pool_tests.cpp b/base/base_tests/thread_pool_tests.cpp index 063d9086da..ac1544a1c6 100644 --- a/base/base_tests/thread_pool_tests.cpp +++ b/base/base_tests/thread_pool_tests.cpp @@ -5,8 +5,8 @@ #include "base/thread_pool.hpp" #include "base/condition.hpp" -#include "std/vector.hpp" -#include "std/bind.hpp" +#include <functional> +#include <vector> namespace { @@ -43,7 +43,8 @@ UNIT_TEST(ThreadPool_CanceledTaskTest) { int finishCounter = 0; threads::Condition cond; - threads::ThreadPool pool(4, bind(&JoinFinishFunction, _1, ref(finishCounter), ref(cond))); + threads::ThreadPool pool(4, std::bind(&JoinFinishFunction, std::placeholders::_1, + std::ref(finishCounter), std::ref(cond))); for (int i = 0; i < TASK_COUNT; ++i) pool.PushBack(new CanceledTask()); @@ -75,7 +76,8 @@ UNIT_TEST(ThreadPool_StopOperationTest) int finishCounter = 0; threads::Condition cond; // in this case we have empty pool, and all tasks must be finish only on Stop method call - threads::ThreadPool pool(0, bind(&JoinFinishFunction, _1, ref(finishCounter), ref(cond))); + threads::ThreadPool pool(0, std::bind(&JoinFinishFunction, std::placeholders::_1, + std::ref(finishCounter), std::ref(cond))); for (int i = 0; i < TASK_COUNT; ++i) pool.PushBack(new EmptyPoolTask()); @@ -116,7 +118,7 @@ namespace UNIT_TEST(ThreadPool_ExecutionTaskTest) { - vector<threads::IRoutine *> tasks; + std::vector<threads::IRoutine *> tasks; for (int i = 0; i < TASK_COUNT - 1; ++i) tasks.push_back(new CancelTestTask(true)); // CancelTastTask::Do method should not be called for last task @@ -124,7 +126,8 @@ UNIT_TEST(ThreadPool_ExecutionTaskTest) int finishCounter = 0; threads::Condition cond; - threads::ThreadPool pool(4, bind(&JoinFinishFunction, _1, ref(finishCounter), ref(cond))); + threads::ThreadPool pool(4, std::bind(&JoinFinishFunction, std::placeholders::_1, + std::ref(finishCounter), std::ref(cond))); for (size_t i = 0; i < tasks.size(); ++i) pool.PushBack(tasks[i]); @@ -146,7 +149,8 @@ UNIT_TEST(ThreadPool_EmptyTest) { int finishCouter = 0; threads::Condition cond; - threads::ThreadPool pool(4, bind(&JoinFinishFunction, _1, ref(finishCouter), ref(cond))); + threads::ThreadPool pool(4, std::bind(&JoinFinishFunction, std::placeholders::_1, + std::ref(finishCouter), std::ref(cond))); threads::Sleep(100); pool.Stop(); diff --git a/base/base_tests/threaded_list_test.cpp b/base/base_tests/threaded_list_test.cpp index 806e155823..c11fa80f2a 100644 --- a/base/base_tests/threaded_list_test.cpp +++ b/base/base_tests/threaded_list_test.cpp @@ -5,16 +5,16 @@ #include "base/logging.hpp" #include "base/stl_add.hpp" -#include "std/mutex.hpp" +#include <mutex> struct ThreadedListProcessor : public threads::IRoutine { ThreadedList<int> & m_p; - mutex & m_resMutex; + std::mutex & m_resMutex; std::list<int> & m_res; int m_id; - ThreadedListProcessor(ThreadedList<int> & p, mutex & resMutex, std::list<int> & res, int id) + ThreadedListProcessor(ThreadedList<int> & p, std::mutex & resMutex, std::list<int> & res, int id) : m_p(p), m_resMutex(resMutex), m_res(res), m_id(id) { } @@ -25,7 +25,7 @@ struct ThreadedListProcessor : public threads::IRoutine { int res = m_p.Front(true /* doPop */); { - lock_guard<mutex> resGuard(m_resMutex); + std::lock_guard<std::mutex> resGuard(m_resMutex); m_res.push_back(res); } LOG(LINFO, (m_id, " thread got ", res)); @@ -39,7 +39,7 @@ UNIT_TEST(ThreadedList) { std::list<int> l; - mutex resMutex; + std::mutex resMutex; std::list<int> res; ThreadedList<int> p; diff --git a/base/base_tests/timegm_test.cpp b/base/base_tests/timegm_test.cpp index e352ab7697..b51f704193 100644 --- a/base/base_tests/timegm_test.cpp +++ b/base/base_tests/timegm_test.cpp @@ -1,6 +1,6 @@ #include "testing/testing.hpp" -#include "std/ctime.hpp" +#include <ctime> #include "base/timegm.hpp" diff --git a/base/math.hpp b/base/math.hpp index 01c31a0c43..15f7359ad0 100644 --- a/base/math.hpp +++ b/base/math.hpp @@ -1,9 +1,8 @@ #pragma once #include "base/assert.hpp" -#include "std/cmath.hpp" - #include <algorithm> +#include <climits> #include <cmath> #include <functional> #include <limits> diff --git a/base/rolling_hash.hpp b/base/rolling_hash.hpp index 79d9077fe8..20f3fc1e39 100644 --- a/base/rolling_hash.hpp +++ b/base/rolling_hash.hpp @@ -4,7 +4,7 @@ #include "base/bits.hpp" #include "base/math.hpp" #ifdef DEBUG -#include "std/queue.hpp" +#include <queue> #endif @@ -56,7 +56,7 @@ private: hash_type m_RemoveMultiplier; uint64_t m_WindowSize; #ifdef DEBUG - queue<value_type> m_Queue; + std::queue<value_type> m_Queue; #endif }; |