From 5cb5b09b198932a0d3bd985fd52fd9fbcb1c2af5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Jun 2015 11:55:27 +0200 Subject: Move some utilities from build2 to libbutl --- build/algorithm.cxx | 3 +++ build/cxx/rule.cxx | 2 +- build/target | 16 ++++++++-------- build/utility | 54 ----------------------------------------------------- 4 files changed, 12 insertions(+), 63 deletions(-) (limited to 'build') diff --git a/build/algorithm.cxx b/build/algorithm.cxx index e52d7f5..fe85c4e 100644 --- a/build/algorithm.cxx +++ b/build/algorithm.cxx @@ -9,6 +9,8 @@ #include // move #include +#include // reverse_iterate + #include #include #include @@ -20,6 +22,7 @@ #include using namespace std; +using namespace butl; namespace build { diff --git a/build/cxx/rule.cxx b/build/cxx/rule.cxx index 095c98a..c0e6550 100644 --- a/build/cxx/rule.cxx +++ b/build/cxx/rule.cxx @@ -11,6 +11,7 @@ #include // move() #include +#include // reverse_iterate #include #include @@ -22,7 +23,6 @@ #include #include - #include using namespace std; diff --git a/build/target b/build/target index 1770d9c..06aa227 100644 --- a/build/target +++ b/build/target @@ -16,6 +16,8 @@ #include // move() #include +#include // compare_c_string + #include #include // map_iterator_adapter #include @@ -24,7 +26,7 @@ #include #include #include -#include // compare_*, extension_pool +#include // extension_pool namespace build { @@ -439,20 +441,18 @@ namespace build extern target_set targets; - class target_type_map: public std::map< + using target_type_map_base = std::map< const char*, std::reference_wrapper, - compare_c_string> + butl::compare_c_string>; + + class target_type_map: public target_type_map_base { public: - typedef std::map, - compare_c_string> base; - void insert (const target_type& tt) {emplace (tt.name, tt);} - using base::find; + using target_type_map_base::find; // Given a name, figure out its type, taking into account extensions, // special names (e.g., '.' and '..'), or anything else that might be diff --git a/build/utility b/build/utility index 87a0e44..717a9ed 100644 --- a/build/utility +++ b/build/utility @@ -8,7 +8,6 @@ #include #include #include -#include // strcmp() #include #include @@ -22,59 +21,6 @@ namespace build extern const path empty_path; extern const dir_path empty_dir_path; - // Comparators. - // - struct compare_c_string - { - bool operator() (const char* x, const char* y) const - { - return std::strcmp (x, y) < 0; - } - }; - - struct compare_pointer_target - { - template - bool operator() (const P& x, const P& y) const {return *x < *y;} - }; - - // Support for reverse iteration using range-based for-loop: - // - // for (... : reverse_iterate (x)) ... - // - template - class reverse_range - { - T& x_; - - public: - reverse_range (T& x): x_ (x) {} - - auto begin () -> decltype (this->x_.rbegin ()) - { - return x_.rbegin (); - } - - auto end () -> decltype (this->x_.rend ()) - { - return x_.rend (); - } - }; - - template - inline reverse_range - reverse_iterate (T& x) - { - return reverse_range (x); - } - - template - inline reverse_range - reverse_iterate (const T& x) - { - return reverse_range (x); - } - // Call a function if there is an exception. // -- cgit v1.1