diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-01-22 08:39:10 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-01-22 09:34:29 +0200 |
commit | 6e91cb7cdb0c4f000a79d20d8578890d56bcdc84 (patch) | |
tree | 7ba42ef488534c19bf2eafbd8d289e08036f11b7 /libbuild2/variable.ixx | |
parent | d51892e33a0fe69e743e02d9620312133a7ac61d (diff) |
Add support for optional pair halves in variable values
Diffstat (limited to 'libbuild2/variable.ixx')
-rw-r--r-- | libbuild2/variable.ixx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libbuild2/variable.ixx b/libbuild2/variable.ixx index c8f9541..9b24b9d 100644 --- a/libbuild2/variable.ixx +++ b/libbuild2/variable.ixx @@ -728,6 +728,31 @@ namespace build2 : s); } + // optional<T> + // + template <typename T> + inline int value_traits<optional<T>>:: + compare (const optional<T>& l, const optional<T>& r) + { + return l + ? (r ? value_traits<T>::compare (*l, *r) : 1) + : (r ? -1 : 0); + } + + // pair<F, S> value + // + template <typename F, typename S> + inline int value_traits<pair<F, S>>:: + compare (const pair<F, S>& l, const pair<F, S>& r) + { + int i (value_traits<F>::compare (l.first, r.first)); + + if (i == 0) + i = value_traits<S>::compare (l.second, r.second); + + return i; + } + // vector<T> value // template <typename T> |