diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-11-12 22:27:49 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-11-13 17:28:35 +0300 |
commit | 161a8e6a768679bde7054fef96dcbb936c866151 (patch) | |
tree | fa52c1e44c57faedaf7309fd849b9980818989fa | |
parent | 0bc2aa6c55e0dcaf5d64224cf76baba1a9c220d3 (diff) |
Add add constructor and remove comparison for path_name_value class
-rw-r--r-- | libbutl/path.ixx | 8 | ||||
-rw-r--r-- | libbutl/path.mxx | 29 |
2 files changed, 13 insertions, 24 deletions
diff --git a/libbutl/path.ixx b/libbutl/path.ixx index e7000ca..b91102a 100644 --- a/libbutl/path.ixx +++ b/libbutl/path.ixx @@ -707,14 +707,14 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. template <typename P> inline basic_path_name_value<P>:: basic_path_name_value (basic_path_name_value&& p) - : basic_path_name_value (std::move (p.path_), std::move (p.name)) + : basic_path_name_value (std::move (p.path), std::move (p.name)) { } template <typename P> inline basic_path_name_value<P>:: basic_path_name_value (const basic_path_name_value& p) - : basic_path_name_value (p.path_, p.name) + : basic_path_name_value (p.path, p.name) { } @@ -724,7 +724,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. { if (this != &p) { - path_ = std::move (p.path_); + path = std::move (p.path); this->name = std::move (p.name); } @@ -737,7 +737,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. { if (this != &p) { - path_ = p.path_; + path = p.path; this->name = p.name; } diff --git a/libbutl/path.mxx b/libbutl/path.mxx index 2374fb5..4ed6989 100644 --- a/libbutl/path.mxx +++ b/libbutl/path.mxx @@ -1382,35 +1382,24 @@ LIBBUTL_MODEXPORT namespace butl using path_type = typename base::path_type; using string_type = typename base::string_type; + path_type path; + explicit basic_path_name_value (path_type p, optional<string_type> n = nullopt) - : base (&path_, std::move (n)), path_ (std::move (p)) {} - - int - compare (const basic_path_name_value& x) const - { - if (int r = path_.compare (x.path_)) - return r; + : base (&path, std::move (n)), path (std::move (p)) {} - return this->name < x.name ? -1 : this->name > x.name ? 1 : 0; - } + // Note that a NULL path is converted to empty path. + // + explicit + basic_path_name_value (const basic_path_name<P>& v) + : base (&path, v.name), + path (v.path != nullptr ? *v.path : path_type ()) {} basic_path_name_value (basic_path_name_value&&); basic_path_name_value (const basic_path_name_value&); basic_path_name_value& operator= (basic_path_name_value&&); basic_path_name_value& operator= (const basic_path_name_value&); - - private: - P path_; }; - - template <typename P> - inline bool - operator< (const basic_path_name_value<P>& x, - const basic_path_name_value<P>& y) - { - return x.compare (y) < 0; - } } LIBBUTL_MODEXPORT namespace std |