From 67d799852492743a93a464002395ccb624514fb8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 30 Jan 2021 11:25:42 +0200 Subject: Add std::{map, multimap} to types.hxx Seeing that std::map is becoming a common Buildfile variable type. --- libbuild2/bin/init.cxx | 2 -- libbuild2/cc/guess.cxx | 1 - libbuild2/cc/link-rule.cxx | 2 -- libbuild2/cc/module.cxx | 1 - libbuild2/cc/types.hxx | 3 +-- libbuild2/config/module.hxx | 4 +--- libbuild2/config/operation.cxx | 2 -- libbuild2/function.hxx | 3 +-- libbuild2/module.hxx | 4 +--- libbuild2/rule-map.hxx | 4 +--- libbuild2/scope.hxx | 6 ++---- libbuild2/target-key.hxx | 1 - libbuild2/target-type.hxx | 6 ++---- libbuild2/test/script/parser.hxx | 1 + libbuild2/types.hxx | 3 +++ libbuild2/utility.hxx | 3 +-- libbuild2/variable.cxx | 10 +++++----- libbuild2/variable.hxx | 21 ++++++++++----------- libbuild2/variable.ixx | 6 +++--- libbuild2/variable.txx | 14 ++------------ libbuild2/version/module.hxx | 4 +--- 21 files changed, 35 insertions(+), 66 deletions(-) diff --git a/libbuild2/bin/init.cxx b/libbuild2/bin/init.cxx index fb82d21..51066cb 100644 --- a/libbuild2/bin/init.cxx +++ b/libbuild2/bin/init.cxx @@ -3,8 +3,6 @@ #include -#include - #include #include #include diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx index d068c20..1e0c77a 100644 --- a/libbuild2/cc/guess.cxx +++ b/libbuild2/cc/guess.cxx @@ -65,7 +65,6 @@ # include #endif -#include #include // strlen(), strchr(), strstr() #include diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 9b75e8d..5b12876 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -3,7 +3,6 @@ #include -#include #include // exit() #include // strlen() @@ -24,7 +23,6 @@ #include // c, pc* #include -using std::map; using std::exit; using namespace butl; diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx index 1709c23..971f175 100644 --- a/libbuild2/cc/module.cxx +++ b/libbuild2/cc/module.cxx @@ -3,7 +3,6 @@ #include -#include #include // left, setw() #include diff --git a/libbuild2/cc/types.hxx b/libbuild2/cc/types.hxx index 70a6340..1297b7b 100644 --- a/libbuild2/cc/types.hxx +++ b/libbuild2/cc/types.hxx @@ -4,7 +4,6 @@ #ifndef LIBBUILD2_CC_TYPES_HXX #define LIBBUILD2_CC_TYPES_HXX -#include #include #include @@ -149,7 +148,7 @@ namespace build2 // The key is either an absolute and normalized header path or a reference // to an importable_headers group (e.g., , std). // - using translatable_headers = std::map>; + using translatable_headers = map>; // Special translatable header groups. // diff --git a/libbuild2/config/module.hxx b/libbuild2/config/module.hxx index 857a30c..3afe721 100644 --- a/libbuild2/config/module.hxx +++ b/libbuild2/config/module.hxx @@ -4,8 +4,6 @@ #ifndef LIBBUILD2_CONFIG_MODULE_HXX #define LIBBUILD2_CONFIG_MODULE_HXX -#include - #include #include @@ -55,7 +53,7 @@ namespace build2 // Priority order with INT32_MIN being the highest. Modules with the // same priority are saved in the order inserted. // - std::multimap order; + multimap order; pair insert (string name, int prio = 0) diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx index b9856be..f9d83da 100644 --- a/libbuild2/config/operation.cxx +++ b/libbuild2/config/operation.cxx @@ -82,8 +82,6 @@ namespace build2 } } - using project_set = set; // Use pointers to get comparison. - // Return (first) whether an unused/inherited variable should be saved // according to the config.config.persist value and (second) whether the // user should be warned about it. diff --git a/libbuild2/function.hxx b/libbuild2/function.hxx index 8fdf8f4..6654257 100644 --- a/libbuild2/function.hxx +++ b/libbuild2/function.hxx @@ -4,7 +4,6 @@ #ifndef LIBBUILD2_FUNCTION_HXX #define LIBBUILD2_FUNCTION_HXX -#include #include // index_sequence #include // aligned_storage @@ -196,7 +195,7 @@ namespace build2 class LIBBUILD2_SYMEXPORT function_map { public: - using map_type = std::map; + using map_type = map; using iterator = map_type::iterator; using const_iterator = map_type::const_iterator; diff --git a/libbuild2/module.hxx b/libbuild2/module.hxx index 770e694..8223bae 100644 --- a/libbuild2/module.hxx +++ b/libbuild2/module.hxx @@ -4,8 +4,6 @@ #ifndef LIBBUILD2_MODULE_HXX #define LIBBUILD2_MODULE_HXX -#include - #include #include #include @@ -275,7 +273,7 @@ namespace build2 // A NULL entry for the main module indicates that a module library was not // found. // - using loaded_module_map = std::map; + using loaded_module_map = map; // The loaded_modules map is locked per top-level (as opposed to nested) // context (see context.hxx for details). diff --git a/libbuild2/rule-map.hxx b/libbuild2/rule-map.hxx index df59548..8014d02 100644 --- a/libbuild2/rule-map.hxx +++ b/libbuild2/rule-map.hxx @@ -4,8 +4,6 @@ #ifndef LIBBUILD2_RULE_MAP_HXX #define LIBBUILD2_RULE_MAP_HXX -#include - #include #include @@ -19,7 +17,7 @@ namespace build2 using hint_rule_map = butl::prefix_map, '.'>; - using target_type_rule_map = std::map; + using target_type_rule_map = map; // This is an "indexed map" with operation_id being the index. Entry // with id 0 is a wildcard. diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index d441267..bd82853 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -4,7 +4,6 @@ #ifndef LIBBUILD2_SCOPE_HXX #define LIBBUILD2_SCOPE_HXX -#include #include #include @@ -27,7 +26,7 @@ namespace build2 { class dir; - using subprojects = std::map; + using subprojects = map; LIBBUILD2_SYMEXPORT ostream& operator<< (ostream&, const subprojects&); // Print as name@dir sequence. @@ -416,8 +415,7 @@ namespace build2 function post; }; - using operation_callback_map = std::multimap; + using operation_callback_map = multimap; operation_callback_map operation_callbacks; diff --git a/libbuild2/target-key.hxx b/libbuild2/target-key.hxx index 62bcc25..2cc58f9 100644 --- a/libbuild2/target-key.hxx +++ b/libbuild2/target-key.hxx @@ -4,7 +4,6 @@ #ifndef LIBBUILD2_TARGET_KEY_HXX #define LIBBUILD2_TARGET_KEY_HXX -#include #include // strcmp() #include diff --git a/libbuild2/target-type.hxx b/libbuild2/target-type.hxx index 88171f5..913432e 100644 --- a/libbuild2/target-type.hxx +++ b/libbuild2/target-type.hxx @@ -4,8 +4,6 @@ #ifndef LIBBUILD2_TARGET_TYPE_HXX #define LIBBUILD2_TARGET_TYPE_HXX -#include - #include #include #include @@ -203,8 +201,8 @@ namespace build2 bool d_; }; - std::map type_map_; - std::map> file_map_; + map type_map_; + map> file_map_; }; } diff --git a/libbuild2/test/script/parser.hxx b/libbuild2/test/script/parser.hxx index f8c3f21..f118ad3 100644 --- a/libbuild2/test/script/parser.hxx +++ b/libbuild2/test/script/parser.hxx @@ -4,6 +4,7 @@ #ifndef LIBBUILD2_TEST_SCRIPT_PARSER_HXX #define LIBBUILD2_TEST_SCRIPT_PARSER_HXX +#include #include #include diff --git a/libbuild2/types.hxx b/libbuild2/types.hxx index 60101b3..6877f92 100644 --- a/libbuild2/types.hxx +++ b/libbuild2/types.hxx @@ -13,6 +13,7 @@ # include #endif +#include #include #include #include @@ -92,6 +93,8 @@ namespace build2 using std::shared_ptr; using std::weak_ptr; + using std::map; + using std::multimap; using std::array; using std::vector; using butl::vector_view; // diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index 3ffc7b2..4cfdf15 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -4,7 +4,6 @@ #ifndef LIBBUILD2_UTILITY_HXX #define LIBBUILD2_UTILITY_HXX -#include #include // make_tuple() #include // make_shared() #include // to_string() @@ -566,7 +565,7 @@ namespace build2 } private: - std::map cache_; + map cache_; mutable mutex mutex_; }; diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx index 6f45e90..8cd6404 100644 --- a/libbuild2/variable.cxx +++ b/libbuild2/variable.cxx @@ -1841,17 +1841,17 @@ namespace build2 value_traits>>>; template struct LIBBUILD2_DEFEXPORT - value_traits>; + value_traits>; template struct LIBBUILD2_DEFEXPORT - value_traits>>; + value_traits>>; template struct LIBBUILD2_DEFEXPORT - value_traits, string>>; + value_traits, string>>; template struct LIBBUILD2_DEFEXPORT - value_traits>>; + value_traits>>; template struct LIBBUILD2_DEFEXPORT - value_traits>; + value_traits>; } diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx index a04e0a9..2d85af3 100644 --- a/libbuild2/variable.hxx +++ b/libbuild2/variable.hxx @@ -4,7 +4,6 @@ #ifndef LIBBUILD2_VARIABLE_HXX #define LIBBUILD2_VARIABLE_HXX -#include #include #include // aligned_storage #include @@ -1126,9 +1125,9 @@ namespace build2 struct map_value_type; template - struct value_traits> + struct value_traits> { - template using map = std::map; + template using map = map; static_assert (sizeof (map) <= value::size_, "insufficient space"); @@ -1167,19 +1166,19 @@ namespace build2 value_traits>>>; extern template struct LIBBUILD2_DECEXPORT - value_traits>; + value_traits>; extern template struct LIBBUILD2_DECEXPORT - value_traits>>; + value_traits>>; extern template struct LIBBUILD2_DECEXPORT - value_traits, string>>; + value_traits, string>>; extern template struct LIBBUILD2_DECEXPORT - value_traits>>; + value_traits>>; extern template struct LIBBUILD2_DECEXPORT - value_traits>; // var_subprojects + value_traits>; // var_subprojects // Project-wide (as opposed to global) variable overrides (see context ctor // for details). @@ -1712,7 +1711,7 @@ namespace build2 stem_version (sver) {} }; - using map_type = std::map; + using map_type = map; map_type m_; }; @@ -1734,7 +1733,7 @@ namespace build2 class variable_pattern_map { public: - using map_type = std::map; + using map_type = map; using const_iterator = map_type::const_iterator; using const_reverse_iterator = map_type::const_reverse_iterator; @@ -1762,7 +1761,7 @@ namespace build2 class LIBBUILD2_SYMEXPORT variable_type_map { public: - using map_type = std::map, + using map_type = map, variable_pattern_map>; using const_iterator = map_type::const_iterator; diff --git a/libbuild2/variable.ixx b/libbuild2/variable.ixx index fd78842..a84c012 100644 --- a/libbuild2/variable.ixx +++ b/libbuild2/variable.ixx @@ -853,7 +853,7 @@ namespace build2 // map value // template - inline void value_traits>:: + inline void value_traits>:: assign (value& v, map&& x) { if (v) @@ -863,7 +863,7 @@ namespace build2 } template - inline void value_traits>:: + inline void value_traits>:: append (value& v, map&& x) { if (v) @@ -884,7 +884,7 @@ namespace build2 } template - inline void value_traits>:: + inline void value_traits>:: prepend (value& v, map&& x) { if (v) diff --git a/libbuild2/variable.txx b/libbuild2/variable.txx index e1808fc..3e4a9f3 100644 --- a/libbuild2/variable.txx +++ b/libbuild2/variable.txx @@ -813,8 +813,6 @@ namespace build2 void map_append (value& v, names&& ns, const variable* var) { - using std::map; - map& p (v ? v.as> () : *new (&v.data_) map ()); @@ -840,8 +838,6 @@ namespace build2 void map_prepend (value& v, names&& ns, const variable* var) { - using std::map; - map& p (v ? v.as> () : *new (&v.data_) map ()); @@ -869,8 +865,6 @@ namespace build2 void map_assign (value& v, names&& ns, const variable* var) { - using std::map; - if (v) v.as> ().clear (); @@ -881,8 +875,6 @@ namespace build2 static names_view map_reverse (const value& v, names& s) { - using std::map; - auto& vm (v.as> ()); s.reserve (2 * vm.size ()); @@ -896,8 +888,6 @@ namespace build2 static int map_compare (const value& l, const value& r) { - using std::map; - auto& lm (l.as> ()); auto& rm (r.as> ()); @@ -975,11 +965,11 @@ namespace build2 }; template - const std::map value_traits>::empty_instance; + const map value_traits>::empty_instance; template const map_value_type - value_traits>::value_type = build2::value_type // VC14 wants = + value_traits>::value_type = build2::value_type // VC14 wants = { nullptr, // Patched above. sizeof (map), diff --git a/libbuild2/version/module.hxx b/libbuild2/version/module.hxx index 26bd48a..e80870e 100644 --- a/libbuild2/version/module.hxx +++ b/libbuild2/version/module.hxx @@ -4,8 +4,6 @@ #ifndef LIBBUILD2_VERSION_MODULE_HXX #define LIBBUILD2_VERSION_MODULE_HXX -#include - #include #include @@ -26,7 +24,7 @@ namespace build2 string constraint; }; - using dependencies = std::map; + using dependencies = map; struct module: build2::module { -- cgit v1.1