diff --git a/base/stl_helpers.hpp b/base/stl_helpers.hpp index 2c24a01407..7296daabc9 100644 --- a/base/stl_helpers.hpp +++ b/base/stl_helpers.hpp @@ -135,7 +135,7 @@ impl::Equals EqualsBy(T (C::*p)() const) } template -std::underlying_type_t Key(T value) +constexpr std::underlying_type_t Key(T value) { return static_cast>(value); } diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 880bc14369..1cbe5b0a2d 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -8,11 +8,12 @@ #include "base/buffer_vector.hpp" #include "base/string_utils.hpp" -#include +#include #include #include #include -#include + +using namespace std; namespace { diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index c7b37c2f69..a16275d0ef 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -3,14 +3,17 @@ #include "indexer/feature_data.hpp" #include "base/base.hpp" +#include "base/stl_helpers.hpp" -#include "std/algorithm.hpp" -#include "std/array.hpp" -#include "std/initializer_list.hpp" -#include "std/limits.hpp" -#include "std/string.hpp" -#include "std/utility.hpp" -#include "std/vector.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -27,7 +30,7 @@ class BaseChecker size_t const m_level; protected: - vector m_types; + std::vector m_types; BaseChecker(size_t level = 2) : m_level(level) {} virtual ~BaseChecker() = default; @@ -37,14 +40,14 @@ public: bool operator() (feature::TypesHolder const & types) const; bool operator() (FeatureType const & ft) const; - bool operator() (vector const & types) const; + bool operator() (std::vector const & types) const; static uint32_t PrepareToMatch(uint32_t type, uint8_t level); template void ForEachType(TFn && fn) const { - for_each(m_types.cbegin(), m_types.cend(), forward(fn)); + std::for_each(m_types.cbegin(), m_types.cend(), std::forward(fn)); } }; @@ -168,7 +171,9 @@ public: Count }; - static_assert(static_cast(Type::Count) <= CHAR_BIT * sizeof(unsigned), + using UnderlyingType = std::underlying_type_t; + + static_assert(my::Key(Type::Count) <= CHAR_BIT * sizeof(unsigned), "Too many types of hotels"); static char const * GetHotelTypeTag(Type type); @@ -181,7 +186,7 @@ public: private: IsHotelChecker(); - array, static_cast(Type::Count)> m_sortedTypes; + std::array, my::Key(Type::Count)> m_sortedTypes; }; // WiFi is a type in classificator.txt, @@ -259,7 +264,7 @@ uint64_t GetPopulationByRadius(double r); /// feature types like "highway", "living_street", "bridge" and so on /// or *. * means any class. /// The root name ("world") is ignored -bool IsTypeConformed(uint32_t type, StringIL const & path); +bool IsTypeConformed(uint32_t type, my::StringIL const & path); // Highway class. The order is important. // The enum values follow from the biggest roads (Trunk) to the smallest ones (Service). @@ -278,7 +283,20 @@ enum class HighwayClass Count // This value is used for internals only. }; -string DebugPrint(HighwayClass const cls); +std::string DebugPrint(HighwayClass const cls); HighwayClass GetHighwayClass(feature::TypesHolder const & types); } // namespace ftypes + +namespace std +{ +template<> +struct hash +{ + size_t operator()(ftypes::IsHotelChecker::Type type) const + { + using UnderlyingType = ftypes::IsHotelChecker::UnderlyingType; + return hash()(static_cast(type)); + } +}; +} // namespace std diff --git a/search/search_tests_support/test_results_matching.cpp b/search/search_tests_support/test_results_matching.cpp index 4430ddb8d0..f2a7711468 100644 --- a/search/search_tests_support/test_results_matching.cpp +++ b/search/search_tests_support/test_results_matching.cpp @@ -5,8 +5,9 @@ #include "indexer/feature_decl.hpp" #include "indexer/index.hpp" -#include "std/sstream.hpp" +#include +using namespace std; using namespace generator::tests_support; namespace search diff --git a/search/search_tests_support/test_results_matching.hpp b/search/search_tests_support/test_results_matching.hpp index fe62995574..3d7a54de0c 100644 --- a/search/search_tests_support/test_results_matching.hpp +++ b/search/search_tests_support/test_results_matching.hpp @@ -4,9 +4,11 @@ #include "indexer/mwm_set.hpp" -#include "std/shared_ptr.hpp" -#include "std/string.hpp" -#include "std/vector.hpp" +#include +#include +#include +#include +#include class FeatureType; class Index; @@ -29,7 +31,7 @@ public: virtual ~MatchingRule() = default; virtual bool Matches(FeatureType const & feature) const = 0; - virtual string ToString() const = 0; + virtual std::string ToString() const = 0; }; class ExactMatchingRule : public MatchingRule @@ -40,7 +42,7 @@ public: // MatchingRule overrides: bool Matches(FeatureType const & feature) const override; - string ToString() const override; + std::string ToString() const override; private: MwmSet::MwmId m_mwmId; @@ -50,35 +52,35 @@ private: class AlternativesMatchingRule : public MatchingRule { public: - AlternativesMatchingRule(initializer_list> rules); + AlternativesMatchingRule(std::initializer_list> rules); // MatchingRule overrides: bool Matches(FeatureType const & feature) const override; - string ToString() const override; + std::string ToString() const override; private: - vector> m_rules; + std::vector> m_rules; }; template -shared_ptr ExactMatch(TArgs &&... args) +std::shared_ptr ExactMatch(TArgs &&... args) { - return make_shared(forward(args)...); + return std::make_shared(forward(args)...); } template -shared_ptr AlternativesMatch(TArgs &&... args) +std::shared_ptr AlternativesMatch(TArgs &&... args) { - return make_shared(forward(args)...); + return std::make_shared(std::forward(args)...); } -bool MatchResults(Index const & index, vector> rules, - vector const & actual); -bool MatchResults(Index const & index, vector> rules, - search::Results const & actual); -bool ResultMatches(Index const & index, shared_ptr rule, - search::Result const & result); +bool MatchResults(Index const & index, std::vector> rules, + std::vector const & actual); +bool MatchResults(Index const & index, std::vector> rules, + search::Results const & actual); +bool ResultMatches(Index const & index, std::shared_ptr rule, + search::Result const & result); -string DebugPrint(MatchingRule const & rule); +std::string DebugPrint(MatchingRule const & rule); } // namespace tests_support } // namespace search